Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/Makefile.kmk
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/Makefile.kmk	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/Makefile.kmk	(revision 28475)
@@ -137,5 +137,4 @@
     wined3d/arb_program_shader.c \
     wined3d/ati_fragment_shader.c \
-    wined3d/baseshader.c \
 	wined3d/basetexture.c \
 	wined3d/buffer.c \
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8/d3d8_main.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8/d3d8_main.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8/d3d8_main.c	(revision 28475)
@@ -89,5 +89,10 @@
 {
   HRESULT ret;
-  FIXME("(%p %p %p %d %p): stub\n", vertexshader, reserved1, reserved2, bool, toto);
+  static BOOL warned;
+
+  if (TRACE_ON(d3d8) || !warned) {
+      FIXME("(%p %p %p %d %p): stub\n", vertexshader, reserved1, reserved2, bool, toto);
+      warned = TRUE;
+  }
 
   if (!vertexshader)
@@ -119,5 +124,10 @@
 {
   HRESULT ret;
-  FIXME("(%p %p %d %p): stub\n", pixelshader, reserved1, bool, toto);
+  static BOOL warned;
+
+  if (TRACE_ON(d3d8) || !warned) {
+      FIXME("(%p %p %d %p): stub\n", pixelshader, reserved1, bool, toto);
+      warned = TRUE;
+  }
 
   if (!pixelshader)
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8/d3d8_private.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8/d3d8_private.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8/d3d8_private.h	(revision 28475)
@@ -285,16 +285,4 @@
         DWORD usage, D3DPOOL pool, D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality) DECLSPEC_HIDDEN;
 
-/* ------------------ */
-/* IDirect3DResource8 */
-/* ------------------ */
-
-/*****************************************************************************
- * Predeclare the interface implementation structures
- */
-extern const IDirect3DResource8Vtbl Direct3DResource8_Vtbl DECLSPEC_HIDDEN;
-
-/*****************************************************************************
- * IDirect3DResource8 implementation structure
- */
 struct IDirect3DResource8Impl
 {
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8/device.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8/device.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8/device.c	(revision 28475)
@@ -181,9 +181,10 @@
     if (t->free_entries)
     {
+        DWORD index = t->free_entries - t->entries;
         /* Use a free handle */
         entry = t->free_entries;
         if (entry->type != D3D8_HANDLE_FREE)
         {
-            ERR("Handle %u(%p) is in the free list, but has type %#x.\n", (entry - t->entries), entry, entry->type);
+            ERR("Handle %u(%p) is in the free list, but has type %#x.\n", index, entry, entry->type);
             return D3D8_INVALID_HANDLE;
         }
@@ -192,5 +193,5 @@
         entry->type = type;
 
-        return entry - t->entries;
+        return index;
     }
 
@@ -334,4 +335,5 @@
 
         IWineD3DDevice_Uninit3D(This->WineD3DDevice, D3D8CB_DestroySwapChain);
+        IWineD3DDevice_ReleaseFocusWindow(This->WineD3DDevice);
         IWineD3DDevice_Release(This->WineD3DDevice);
         HeapFree(GetProcessHeap(), 0, This->handle_table.entries);
@@ -2801,4 +2803,17 @@
     }
 
+    if (!parameters->Windowed)
+    {
+        if (!focus_window) focus_window = parameters->hDeviceWindow;
+        if (FAILED(hr = IWineD3DDevice_AcquireFocusWindow(device->WineD3DDevice, focus_window)))
+        {
+            ERR("Failed to acquire focus window, hr %#x.\n", hr);
+            IWineD3DDevice_Release(device->WineD3DDevice);
+            wined3d_mutex_unlock();
+            HeapFree(GetProcessHeap(), 0, device->handle_table.entries);
+            return hr;
+        }
+    }
+
     if (flags & D3DCREATE_MULTITHREADED) IWineD3DDevice_SetMultithreaded(device->WineD3DDevice);
 
@@ -2823,4 +2838,5 @@
     {
         WARN("Failed to initialize 3D, hr %#x.\n", hr);
+        IWineD3DDevice_ReleaseFocusWindow(device->WineD3DDevice);
         IWineD3DDevice_Release(device->WineD3DDevice);
         wined3d_mutex_unlock();
@@ -2865,4 +2881,5 @@
     wined3d_mutex_lock();
     IWineD3DDevice_Uninit3D(device->WineD3DDevice, D3D8CB_DestroySwapChain);
+    IWineD3DDevice_ReleaseFocusWindow(device->WineD3DDevice);
     IWineD3DDevice_Release(device->WineD3DDevice);
     wined3d_mutex_unlock();
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8/version.rc
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8/version.rc	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8/version.rc	(revision 28475)
@@ -26,22 +26,4 @@
  */
 
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
- */
-
 #define WINE_FILEDESCRIPTION_STR "Wine Direct3D"
 #define WINE_FILENAME_STR "d3d8.dll"
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8/vertexdeclaration.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8/vertexdeclaration.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8/vertexdeclaration.c	(revision 28475)
@@ -19,4 +19,7 @@
  */
 
+/* IDirect3DVertexDeclaration8 is internal to our implementation.
+ * It's not visible in the API. */
+
 /*
  * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
@@ -27,7 +30,4 @@
  * of the LGPL is applied is otherwise unspecified.
  */
-
-/* IDirect3DVertexDeclaration8 is internal to our implementation.
- * It's not visible in the API. */
 
 #include "config.h"
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/d3d9_private.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/d3d9_private.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/d3d9_private.h	(revision 28475)
@@ -197,9 +197,4 @@
         UINT iSwapChain, IDirect3DSwapChain9 **pSwapChain) DECLSPEC_HIDDEN;
 extern UINT WINAPI IDirect3DDevice9Impl_GetNumberOfSwapChains(IDirect3DDevice9Ex *iface) DECLSPEC_HIDDEN;
-extern HRESULT WINAPI IDirect3DDevice9Impl_CreateStateBlock(IDirect3DDevice9Ex *iface,
-        D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9 **ppSB) DECLSPEC_HIDDEN;
-extern HRESULT WINAPI IDirect3DDevice9Impl_BeginStateBlock(IDirect3DDevice9Ex *iface) DECLSPEC_HIDDEN;
-extern HRESULT WINAPI IDirect3DDevice9Impl_EndStateBlock(IDirect3DDevice9Ex *iface,
-        IDirect3DStateBlock9 **ppSB) DECLSPEC_HIDDEN;
 extern HRESULT WINAPI IDirect3DDevice9Impl_SetVertexDeclaration(IDirect3DDevice9Ex *iface,
         IDirect3DVertexDeclaration9 *pDecl) DECLSPEC_HIDDEN;
@@ -238,7 +233,4 @@
 extern HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantB(IDirect3DDevice9Ex *iface,
         UINT StartRegister, BOOL *pConstantData, UINT BoolCount) DECLSPEC_HIDDEN;
-extern HRESULT WINAPI IDirect3DDevice9Impl_CreateQuery(IDirect3DDevice9Ex *iface,
-        D3DQUERYTYPE Type, IDirect3DQuery9 **ppQuery) DECLSPEC_HIDDEN;
-
 
 /* ---------------- */
@@ -480,4 +472,6 @@
 } IDirect3DStateBlock9Impl;
 
+HRESULT stateblock_init(IDirect3DStateBlock9Impl *stateblock, IDirect3DDevice9Impl *device,
+        D3DSTATEBLOCKTYPE type, IWineD3DStateBlock *wined3d_stateblock) DECLSPEC_HIDDEN;
 
 /* --------------------------- */
@@ -574,3 +568,6 @@
 } IDirect3DQuery9Impl;
 
+HRESULT query_init(IDirect3DQuery9Impl *query, IDirect3DDevice9Impl *device,
+        D3DQUERYTYPE type) DECLSPEC_HIDDEN;
+
 #endif /* __WINE_D3D9_PRIVATE_H */
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/device.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/device.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/device.c	(revision 28475)
@@ -281,4 +281,5 @@
 
       IWineD3DDevice_Uninit3D(This->WineD3DDevice, D3D9CB_DestroySwapChain);
+      IWineD3DDevice_ReleaseFocusWindow(This->WineD3DDevice);
       IWineD3DDevice_Release(This->WineD3DDevice);
       wined3d_mutex_unlock();
@@ -1431,4 +1432,95 @@
 
     return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_CreateStateBlock(IDirect3DDevice9Ex *iface,
+        D3DSTATEBLOCKTYPE type, IDirect3DStateBlock9 **stateblock)
+{
+    IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+    IDirect3DStateBlock9Impl *object;
+    HRESULT hr;
+
+    TRACE("iface %p, type %#x, stateblock %p.\n", iface, type, stateblock);
+
+    if (type != D3DSBT_ALL && type != D3DSBT_PIXELSTATE && type != D3DSBT_VERTEXSTATE)
+    {
+        WARN("Unexpected stateblock type, returning D3DERR_INVALIDCALL.\n");
+        return D3DERR_INVALIDCALL;
+    }
+
+    object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+    if (!object)
+    {
+        ERR("Failed to allocate stateblock memory.\n");
+        return E_OUTOFMEMORY;
+    }
+
+    hr = stateblock_init(object, This, type, NULL);
+    if (FAILED(hr))
+    {
+        WARN("Failed to initialize stateblock, hr %#x.\n", hr);
+        HeapFree(GetProcessHeap(), 0, object);
+        return hr;
+    }
+
+    TRACE("Created stateblock %p.\n", object);
+    *stateblock = (IDirect3DStateBlock9 *)object;
+
+    return D3D_OK;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_BeginStateBlock(IDirect3DDevice9Ex *iface)
+{
+    IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+    HRESULT hr;
+
+    TRACE("iface %p.\n", iface);
+
+    wined3d_mutex_lock();
+    hr = IWineD3DDevice_BeginStateBlock(This->WineD3DDevice);
+    wined3d_mutex_unlock();
+
+    return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_EndStateBlock(IDirect3DDevice9Ex *iface, IDirect3DStateBlock9 **stateblock)
+{
+    IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+    IWineD3DStateBlock *wined3d_stateblock;
+    IDirect3DStateBlock9Impl *object;
+    HRESULT hr;
+
+    TRACE("iface %p, stateblock %p.\n", iface, stateblock);
+
+    wined3d_mutex_lock();
+    hr = IWineD3DDevice_EndStateBlock(This->WineD3DDevice, &wined3d_stateblock);
+    wined3d_mutex_unlock();
+    if (FAILED(hr))
+    {
+       WARN("IWineD3DDevice_EndStateBlock() failed, hr %#x.\n", hr);
+       return hr;
+    }
+
+    object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+    if (!object)
+    {
+        ERR("Failed to allocate stateblock memory.\n");
+        IWineD3DStateBlock_Release(wined3d_stateblock);
+        return E_OUTOFMEMORY;
+    }
+
+    hr = stateblock_init(object, This, 0, wined3d_stateblock);
+    if (FAILED(hr))
+    {
+        WARN("Failed to initialize stateblock, hr %#x.\n", hr);
+        IWineD3DStateBlock_Release(wined3d_stateblock);
+        HeapFree(GetProcessHeap(), 0, object);
+        return hr;
+    }
+
+    TRACE("Created stateblock %p.\n", object);
+    *stateblock = (IDirect3DStateBlock9 *)object;
+
+    return D3D_OK;
 }
 
@@ -2195,4 +2287,35 @@
 
     return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_CreateQuery(IDirect3DDevice9Ex *iface,
+        D3DQUERYTYPE type, IDirect3DQuery9 **query)
+{
+    IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+    IDirect3DQuery9Impl *object;
+    HRESULT hr;
+
+    TRACE("iface %p, type %#x, query %p.\n", iface, type, query);
+
+    object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+    if (!object)
+    {
+        ERR("Failed to allocate query memory.\n");
+        return E_OUTOFMEMORY;
+    }
+
+    hr = query_init(object, This, type);
+    if (FAILED(hr))
+    {
+        WARN("Failed to initialize query, hr %#x.\n", hr);
+        HeapFree(GetProcessHeap(), 0, object);
+        return hr;
+    }
+
+    TRACE("Created query %p.\n", object);
+    if (query) *query = (IDirect3DQuery9 *)object;
+    else IDirect3DQuery9_Release((IDirect3DQuery9 *)object);
+
+    return D3D_OK;
 }
 
@@ -2739,4 +2862,16 @@
     }
 
+    if (!parameters->Windowed)
+    {
+        if (!focus_window) focus_window = parameters->hDeviceWindow;
+        if (FAILED(hr = IWineD3DDevice_AcquireFocusWindow(device->WineD3DDevice, focus_window)))
+        {
+            ERR("Failed to acquire focus window, hr %#x.\n", hr);
+            IWineD3DDevice_Release(device->WineD3DDevice);
+            wined3d_mutex_unlock();
+            return hr;
+        }
+    }
+
     if (flags & D3DCREATE_ADAPTERGROUP_DEVICE)
     {
@@ -2782,4 +2917,5 @@
     {
         WARN("Failed to initialize 3D, hr %#x.\n", hr);
+        IWineD3DDevice_ReleaseFocusWindow(device->WineD3DDevice);
         HeapFree(GetProcessHeap(), 0, wined3d_parameters);
         IWineD3DDevice_Release(device->WineD3DDevice);
@@ -2818,4 +2954,5 @@
         wined3d_mutex_lock();
         IWineD3DDevice_Uninit3D(device->WineD3DDevice, D3D9CB_DestroySwapChain);
+        IWineD3DDevice_ReleaseFocusWindow(device->WineD3DDevice);
         IWineD3DDevice_Release(device->WineD3DDevice);
         wined3d_mutex_unlock();
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/query.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/query.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/query.c	(revision 28475)
@@ -160,48 +160,23 @@
 };
 
+HRESULT query_init(IDirect3DQuery9Impl *query, IDirect3DDevice9Impl *device, D3DQUERYTYPE type)
+{
+    HRESULT hr;
 
-/* IDirect3DDevice9 IDirect3DQuery9 Methods follow: */
-HRESULT WINAPI IDirect3DDevice9Impl_CreateQuery(LPDIRECT3DDEVICE9EX iface, D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery) {
-    IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
-    IDirect3DQuery9Impl *object = NULL;
-    HRESULT hr = D3D_OK;
+    query->lpVtbl = &Direct3DQuery9_Vtbl;
+    query->ref = 1;
 
-    TRACE("iface %p, type %#x, query %p.\n", iface, Type, ppQuery);
-
-    if (!ppQuery)
+    wined3d_mutex_lock();
+    hr = IWineD3DDevice_CreateQuery(device->WineD3DDevice, type, &query->wineD3DQuery, (IUnknown *)query);
+    wined3d_mutex_unlock();
+    if (FAILED(hr))
     {
-        wined3d_mutex_lock();
-        hr = IWineD3DDevice_CreateQuery(This->WineD3DDevice, Type, NULL, NULL);
-        wined3d_mutex_unlock();
-
+        WARN("Failed to create wined3d query, hr %#x.\n", hr);
         return hr;
     }
 
-    /* Allocate the storage for the device */
-    object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DQuery9Impl));
-    if (NULL == object) {
-        ERR("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n");
-        return D3DERR_OUTOFVIDEOMEMORY;
-    }
+    query->parentDevice = (IDirect3DDevice9Ex *)device;
+    IDirect3DDevice9Ex_AddRef(query->parentDevice);
 
-    object->lpVtbl = &Direct3DQuery9_Vtbl;
-    object->ref = 1;
-
-    wined3d_mutex_lock();
-    hr = IWineD3DDevice_CreateQuery(This->WineD3DDevice, Type, &object->wineD3DQuery, (IUnknown *)object);
-    wined3d_mutex_unlock();
-
-    if (FAILED(hr)) {
-
-        /* free up object */
-        WARN("(%p) call to IWineD3DDevice_CreateQuery failed\n", This);
-        HeapFree(GetProcessHeap(), 0, object);
-    } else {
-        IDirect3DDevice9Ex_AddRef(iface);
-        object->parentDevice = iface;
-        *ppQuery = (LPDIRECT3DQUERY9) object;
-        TRACE("(%p) : Created query %p\n", This , object);
-    }
-    TRACE("(%p) : returning %x\n", This, hr);
-    return hr;
+    return D3D_OK;
 }
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/stateblock.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/stateblock.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/stateblock.c	(revision 28475)
@@ -133,86 +133,32 @@
 };
 
-
-/* IDirect3DDevice9 IDirect3DStateBlock9 Methods follow: */
-HRESULT WINAPI IDirect3DDevice9Impl_CreateStateBlock(LPDIRECT3DDEVICE9EX iface, D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9** ppStateBlock) {
-   IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
-   IDirect3DStateBlock9Impl* object;
-   HRESULT hrc = D3D_OK;
-
-   TRACE("iface %p, type %#x, stateblock %p.\n", iface, Type, ppStateBlock);
-
-   if(Type != D3DSBT_ALL         && Type != D3DSBT_PIXELSTATE &&
-      Type != D3DSBT_VERTEXSTATE                              ) {
-       WARN("Unexpected stateblock type, returning D3DERR_INVALIDCALL\n");
-       return D3DERR_INVALIDCALL;
-   }
-
-   object  = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DStateBlock9Impl));
-   if (NULL == object) return E_OUTOFMEMORY;
-   object->lpVtbl = &Direct3DStateBlock9_Vtbl;
-   object->ref = 1;
-
-   wined3d_mutex_lock();
-   hrc = IWineD3DDevice_CreateStateBlock(This->WineD3DDevice, (WINED3DSTATEBLOCKTYPE)Type, &object->wineD3DStateBlock, (IUnknown*)object);
-   wined3d_mutex_unlock();
-
-   if(hrc != D3D_OK){
-       FIXME("(%p) Call to IWineD3DDevice_CreateStateBlock failed.\n", This);
-       HeapFree(GetProcessHeap(), 0, object);
-   } else {
-        IDirect3DDevice9Ex_AddRef(iface);
-        object->parentDevice = iface;
-        *ppStateBlock = (IDirect3DStateBlock9*)object;
-        TRACE("(%p) : Created stateblock %p\n", This, object);
-   }
-   TRACE("(%p) returning token (ptr to stateblock) of %p\n", This, object);
-   return hrc;
-}
-
-HRESULT WINAPI IDirect3DDevice9Impl_BeginStateBlock(IDirect3DDevice9Ex *iface)
+HRESULT stateblock_init(IDirect3DStateBlock9Impl *stateblock, IDirect3DDevice9Impl *device,
+        D3DSTATEBLOCKTYPE type, IWineD3DStateBlock *wined3d_stateblock)
 {
-    IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
     HRESULT hr;
 
-    TRACE("iface %p.\n", iface);
+    stateblock->lpVtbl = &Direct3DStateBlock9_Vtbl;
+    stateblock->ref = 1;
 
-    wined3d_mutex_lock();
-    hr = IWineD3DDevice_BeginStateBlock(This->WineD3DDevice);
-    wined3d_mutex_unlock();
+    if (wined3d_stateblock)
+    {
+        stateblock->wineD3DStateBlock = wined3d_stateblock;
+    }
+    else
+    {
+        wined3d_mutex_lock();
+        hr = IWineD3DDevice_CreateStateBlock(device->WineD3DDevice, (WINED3DSTATEBLOCKTYPE)type,
+                &stateblock->wineD3DStateBlock, (IUnknown *)stateblock);
+        wined3d_mutex_unlock();
+        if (FAILED(hr))
+        {
+            WARN("Failed to create wined3d stateblock, hr %#x.\n", hr);
+            return hr;
+        }
+    }
 
-    return hr;
-}
+    stateblock->parentDevice = (IDirect3DDevice9Ex *)device;
+    IDirect3DDevice9Ex_AddRef(stateblock->parentDevice);
 
-HRESULT WINAPI IDirect3DDevice9Impl_EndStateBlock(IDirect3DDevice9Ex *iface, IDirect3DStateBlock9 **ppSB)
-{
-    IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
-    IWineD3DStateBlock *wineD3DStateBlock;
-    IDirect3DStateBlock9Impl *object;
-    HRESULT hr;
-
-    TRACE("iface %p, stateblock %p.\n", iface, ppSB);
-
-    /* Tell wineD3D to endstateblock before anything else (in case we run out
-     * of memory later and cause locking problems) */
-    wined3d_mutex_lock();
-    hr=IWineD3DDevice_EndStateBlock(This->WineD3DDevice,&wineD3DStateBlock);
-    wined3d_mutex_unlock();
-
-    if (hr!= D3D_OK)
-    {
-       WARN("IWineD3DDevice_EndStateBlock returned an error\n");
-       return hr;
-    }
-    /* allocate a new IDirectD3DStateBlock */
-    object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DStateBlock9Impl));
-    if (!object) return E_OUTOFMEMORY;
-    object->ref = 1;
-    object->lpVtbl = &Direct3DStateBlock9_Vtbl;
-    object->wineD3DStateBlock = wineD3DStateBlock;
-
-    IDirect3DDevice9Ex_AddRef(iface);
-    object->parentDevice = iface;
-    *ppSB=(IDirect3DStateBlock9*)object;
-    TRACE("(%p) Returning *ppSB %p, wineD3DStateBlock %p\n", This, *ppSB, wineD3DStateBlock);
     return D3D_OK;
 }
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/Makefile.in
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/Makefile.in	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/Makefile.in	(revision 28475)
@@ -15,12 +15,17 @@
 	amstream.idl \
 	amvideo.idl \
+	audioclient.idl \
+	audiopolicy.idl \
 	austream.idl \
 	bits.idl \
 	bits1_5.idl \
 	comcat.idl \
+	commoncontrols.idl \
 	control.idl \
+	ctfutb.idl \
 	ctxtcall.idl \
 	d3d10.idl \
 	ddstream.idl \
+	devicetopology.idl \
 	dimm.idl \
 	dispex.idl \
@@ -29,4 +34,5 @@
 	dxgi.idl \
 	dxgitype.idl \
+	endpointvolume.idl \
 	exdisp.idl \
 	fusion.idl \
@@ -69,4 +75,5 @@
 	sensevts.idl \
 	servprov.idl \
+	shdeprecated.idl \
 	shldisp.idl \
 	shobjidl.idl \
@@ -86,5 +93,6 @@
 	wuapi.idl \
 	xmldom.idl \
-	xmldso.idl
+	xmldso.idl \
+	xmllite.idl
 
 IDL_TLB_SRCS = \
@@ -95,11 +103,18 @@
 	$(PUBLIC_IDL_H_SRCS) \
 	accctrl.h \
+	access.idl \
 	aclapi.h \
 	aclui.h \
 	adshlp.h \
 	advpub.h \
+	af_irda.h \
+	amaudio.h \
 	appmgmt.h \
+	asynot.idl \
+	asysta.idl \
 	audevcod.h \
+	audiosessiontypes.h \
 	aviriff.h \
+	avrt.h \
 	axcore.idl \
 	axextend.idl \
@@ -107,4 +122,5 @@
 	basetyps.h \
 	bcrypt.h \
+	binres.idl \
 	bitsmsg.h \
 	cderr.h \
@@ -113,4 +129,6 @@
 	cierror.h \
 	clusapi.h \
+	cmdbas.idl \
+	cmdtxt.idl \
 	commctrl.h \
 	commctrl.rh \
@@ -144,8 +162,10 @@
 	d3dx9.h \
 	d3dx9core.h \
+	d3dx9effect.h \
 	d3dx9math.h \
 	d3dx9math.inl \
 	d3dx9mesh.h \
 	d3dx9shader.h \
+	d3dx9shape.h \
 	d3dx9tex.h \
 	dbghelp.h \
@@ -178,4 +198,6 @@
 	devenum.idl \
 	devguid.h \
+	devpkey.h \
+	devpropdef.h \
 	digitalv.h \
 	dinput.h \
@@ -362,5 +384,7 @@
 	oleauto.h \
 	olectl.h \
+	oledberr.h \
 	oledlg.h \
+	opnrst.idl \
 	pdh.h \
 	pdhmsg.h \
@@ -369,4 +393,6 @@
 	powrprof.h \
 	profinfo.h \
+	propkey.h \
+	propkeydef.h \
 	propvarutil.h \
 	prsht.h \
@@ -530,4 +556,2 @@
 	esac; done
 	-rmdir $(INSTALLDIRS)
-
-@DEPENDENCIES@  # everything below this line is overwritten by make depend
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/axcore.idl
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/axcore.idl	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/axcore.idl	(revision 28475)
@@ -57,5 +57,8 @@
 cpp_quote("#define MAX_FILTER_NAME 128")
 
+cpp_quote("#ifndef REFERENCE_TIME_DEFINED")
+cpp_quote("#define REFERENCE_TIME_DEFINED")
 typedef LONGLONG REFERENCE_TIME;
+cpp_quote("#endif")
 
 cpp_quote("#ifndef REFTIME_DEFINED")
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/commdlg.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/commdlg.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/commdlg.h	(revision 28475)
@@ -274,5 +274,5 @@
 #define FR_MATCHALEFHAMZA               0x80000000
 
-typedef UINT (CALLBACK *LPCFHOOKPROC)(HWND,UINT,WPARAM,LPARAM);
+typedef UINT_PTR (CALLBACK *LPCFHOOKPROC)(HWND,UINT,WPARAM,LPARAM);
 
 typedef struct tagCHOOSEFONTA
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/config.h.in
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/config.h.in	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/config.h.in	(revision 28475)
@@ -1,4 +1,5 @@
 /* include/config.h.in.  Generated from configure.ac by autoheader.  */
 
+#ifndef WINE_CROSSTEST
 #define __WINE_CONFIG_H
 
@@ -23,4 +24,17 @@
 /* Define to 1 if you have the <asm/types.h> header file. */
 #undef HAVE_ASM_TYPES_H
+
+/* Define to 1 if you have the `AudioFileStreamOpen' function. */
+#undef HAVE_AUDIOFILESTREAMOPEN
+
+/* Define to 1 if you have the <AudioToolbox/AudioConverter.h> header file. */
+#undef HAVE_AUDIOTOOLBOX_AUDIOCONVERTER_H
+
+/* Define to 1 if you have the <AudioToolbox/AudioFileStream.h> header file.
+   */
+#undef HAVE_AUDIOTOOLBOX_AUDIOFILESTREAM_H
+
+/* Define to 1 if you have the <AudioToolbox/AudioFile.h> header file. */
+#undef HAVE_AUDIOTOOLBOX_AUDIOFILE_H
 
 /* Define to 1 if you have the <AudioUnit/AudioUnit.h> header file. */
@@ -241,4 +255,7 @@
 #undef HAVE_IEEEFP_H
 
+/* Define to 1 if you have the <ifaddrs.h> header file. */
+#undef HAVE_IFADDRS_H
+
 /* Define to 1 if you have the <inet/mib2.h> header file. */
 #undef HAVE_INET_MIB2_H
@@ -538,4 +555,7 @@
 #undef HAVE_ONE_ARG_MKDIR
 
+/* Define to 1 if OpenAL is available */
+#undef HAVE_OPENAL
+
 /* Define if OpenGL is present on the system */
 #undef HAVE_OPENGL
@@ -559,4 +579,7 @@
 #undef HAVE_PNG_H
 
+/* Define to 1 if libpng has the png_set_expand_gray_1_2_4_to_8 function. */
+#undef HAVE_PNG_SET_EXPAND_GRAY_1_2_4_TO_8
+
 /* Define to 1 if you have the `poll' function. */
 #undef HAVE_POLL
@@ -736,65 +759,68 @@
 #undef HAVE_STRTOULL
 
-/* Define to 1 if `direction' is member of `struct ff_effect'. */
+/* Define to 1 if `direction' is a member of `struct ff_effect'. */
 #undef HAVE_STRUCT_FF_EFFECT_DIRECTION
 
-/* Define to 1 if `icps_outhist' is member of `struct icmpstat'. */
+/* Define to 1 if `icps_outhist' is a member of `struct icmpstat'. */
 #undef HAVE_STRUCT_ICMPSTAT_ICPS_OUTHIST
 
-/* Define to 1 if `msg_accrights' is member of `struct msghdr'. */
+/* Define to 1 if `ifr_hwaddr' is a member of `struct ifreq'. */
+#undef HAVE_STRUCT_IFREQ_IFR_HWADDR
+
+/* Define to 1 if `msg_accrights' is a member of `struct msghdr'. */
 #undef HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS
 
-/* Define to 1 if `mt_blkno' is member of `struct mtget'. */
+/* Define to 1 if `mt_blkno' is a member of `struct mtget'. */
 #undef HAVE_STRUCT_MTGET_MT_BLKNO
 
-/* Define to 1 if `mt_blksiz' is member of `struct mtget'. */
+/* Define to 1 if `mt_blksiz' is a member of `struct mtget'. */
 #undef HAVE_STRUCT_MTGET_MT_BLKSIZ
 
-/* Define to 1 if `mt_gstat' is member of `struct mtget'. */
+/* Define to 1 if `mt_gstat' is a member of `struct mtget'. */
 #undef HAVE_STRUCT_MTGET_MT_GSTAT
 
-/* Define to 1 if `name' is member of `struct option'. */
+/* Define to 1 if `name' is a member of `struct option'. */
 #undef HAVE_STRUCT_OPTION_NAME
 
-/* Define to 1 if `sin6_scope_id' is member of `struct sockaddr_in6'. */
+/* Define to 1 if `sin6_scope_id' is a member of `struct sockaddr_in6'. */
 #undef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID
 
-/* Define to 1 if `sa_len' is member of `struct sockaddr'. */
+/* Define to 1 if `sa_len' is a member of `struct sockaddr'. */
 #undef HAVE_STRUCT_SOCKADDR_SA_LEN
 
-/* Define to 1 if `sun_len' is member of `struct sockaddr_un'. */
+/* Define to 1 if `sun_len' is a member of `struct sockaddr_un'. */
 #undef HAVE_STRUCT_SOCKADDR_UN_SUN_LEN
 
-/* Define to 1 if `f_bavail' is member of `struct statfs'. */
+/* Define to 1 if `f_bavail' is a member of `struct statfs'. */
 #undef HAVE_STRUCT_STATFS_F_BAVAIL
 
-/* Define to 1 if `f_bfree' is member of `struct statfs'. */
+/* Define to 1 if `f_bfree' is a member of `struct statfs'. */
 #undef HAVE_STRUCT_STATFS_F_BFREE
 
-/* Define to 1 if `f_favail' is member of `struct statfs'. */
+/* Define to 1 if `f_favail' is a member of `struct statfs'. */
 #undef HAVE_STRUCT_STATFS_F_FAVAIL
 
-/* Define to 1 if `f_ffree' is member of `struct statfs'. */
+/* Define to 1 if `f_ffree' is a member of `struct statfs'. */
 #undef HAVE_STRUCT_STATFS_F_FFREE
 
-/* Define to 1 if `f_frsize' is member of `struct statfs'. */
+/* Define to 1 if `f_frsize' is a member of `struct statfs'. */
 #undef HAVE_STRUCT_STATFS_F_FRSIZE
 
-/* Define to 1 if `f_namelen' is member of `struct statfs'. */
+/* Define to 1 if `f_namelen' is a member of `struct statfs'. */
 #undef HAVE_STRUCT_STATFS_F_NAMELEN
 
-/* Define to 1 if `f_blocks' is member of `struct statvfs'. */
+/* Define to 1 if `f_blocks' is a member of `struct statvfs'. */
 #undef HAVE_STRUCT_STATVFS_F_BLOCKS
 
-/* Define to 1 if `st_atim' is member of `struct stat'. */
+/* Define to 1 if `st_atim' is a member of `struct stat'. */
 #undef HAVE_STRUCT_STAT_ST_ATIM
 
-/* Define to 1 if `st_blocks' is member of `struct stat'. */
+/* Define to 1 if `st_blocks' is a member of `struct stat'. */
 #undef HAVE_STRUCT_STAT_ST_BLOCKS
 
-/* Define to 1 if `st_ctim' is member of `struct stat'. */
+/* Define to 1 if `st_ctim' is a member of `struct stat'. */
 #undef HAVE_STRUCT_STAT_ST_CTIM
 
-/* Define to 1 if `st_mtim' is member of `struct stat'. */
+/* Define to 1 if `st_mtim' is a member of `struct stat'. */
 #undef HAVE_STRUCT_STAT_ST_MTIM
 
@@ -967,4 +993,7 @@
 #undef HAVE_THR_KILL2
 
+/* Define to 1 if you have the <tiffio.h> header file. */
+#undef HAVE_TIFFIO_H
+
 /* Define to 1 if you have the `timegm' function. */
 #undef HAVE_TIMEGM
@@ -1144,4 +1173,7 @@
 #undef SONAME_LIBODBC
 
+/* Define to the soname of the libopenal library. */
+#undef SONAME_LIBOPENAL
+
 /* Define to the soname of the libpng library. */
 #undef SONAME_LIBPNG
@@ -1152,4 +1184,10 @@
 /* Define to the soname of the libssl library. */
 #undef SONAME_LIBSSL
+
+/* Define to the soname of the libtiff library. */
+#undef SONAME_LIBTIFF
+
+/* Define to the soname of the libv4l1 library. */
+#undef SONAME_LIBV4L1
 
 /* Define to the soname of the libX11 library. */
@@ -1223,2 +1261,4 @@
 #undef inline
 #endif
+
+#endif /* WINE_CROSSTEST */
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/cvconst.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/cvconst.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/cvconst.h	(revision 28475)
@@ -521,4 +521,6 @@
     CV_AMD64_MM71       = CV_REG_MM71,
 
+    CV_AMD64_XMM8       = 252,           /* this includes XMM9 to XMM15 */
+
     CV_AMD64_RAX        = 328,
     CV_AMD64_RBX        = 329,
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3d10effect.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3d10effect.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3d10effect.h	(revision 28475)
@@ -109,4 +109,15 @@
 } D3D10_EFFECT_DESC;
 
+typedef struct _D3D10_EFFECT_SHADER_DESC
+{
+    const BYTE *pInputSignature;
+    BOOL IsInline;
+    const BYTE *pBytecode;
+    UINT BytecodeLength;
+    LPCSTR SODecl;
+    UINT NumInputSignatureEntries;
+    UINT NumOutputSignatureEntries;
+} D3D10_EFFECT_SHADER_DESC;
+
 typedef struct _D3D10_PASS_DESC
 {
@@ -210,4 +221,98 @@
     STDMETHOD(SetTextureBuffer)(THIS_ ID3D10ShaderResourceView *view) PURE;
     STDMETHOD(GetTextureBuffer)(THIS_ ID3D10ShaderResourceView **view) PURE;
+};
+#undef INTERFACE
+
+DEFINE_GUID(IID_ID3D10EffectScalarVariable, 0x00e48f7b, 0xd2c8, 0x49e8, 0xa8, 0x6c, 0x02, 0x2d, 0xee, 0x53, 0x43, 0x1f);
+
+#define INTERFACE ID3D10EffectScalarVariable
+DECLARE_INTERFACE_(ID3D10EffectScalarVariable, ID3D10EffectVariable)
+{
+    /* ID3D10EffectVariable methods */
+    STDMETHOD_(BOOL, IsValid)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectType *, GetType)(THIS) PURE;
+    STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_VARIABLE_DESC *desc) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetAnnotationByIndex)(THIS_ UINT index) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetAnnotationByName)(THIS_ LPCSTR name) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetMemberByIndex)(THIS_ UINT index) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetMemberByName)(THIS_ LPCSTR name) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetMemberBySemantic)(THIS_ LPCSTR semantic) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetElement)(THIS_ UINT index) PURE;
+    STDMETHOD_(struct ID3D10EffectConstantBuffer *, GetParentConstantBuffer)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectScalarVariable *, AsScalar)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectVectorVariable *, AsVector)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectMatrixVariable *, AsMatrix)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectStringVariable *, AsString)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectShaderResourceVariable *, AsShaderResource)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectRenderTargetViewVariable *, AsRenderTargetView)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectDepthStencilViewVariable *, AsDepthStencilView)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectConstantBuffer *, AsConstantBuffer)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectShaderVariable *, AsShader)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectBlendVariable *, AsBlend)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectDepthStencilVariable *, AsDepthStencil)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectRasterizerVariable *, AsRasterizer)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectSamplerVariable *, AsSampler)(THIS) PURE;
+    STDMETHOD(SetRawValue)(THIS_ void *data, UINT offset, UINT count) PURE;
+    STDMETHOD(GetRawValue)(THIS_ void *data, UINT offset, UINT count) PURE;
+    /* ID3D10EffectScalarVariable methods */
+    STDMETHOD(SetFloat)(THIS_ float value) PURE;
+    STDMETHOD(GetFloat)(THIS_ float *value) PURE;
+    STDMETHOD(SetFloatArray)(THIS_ float *values, UINT offset, UINT count) PURE;
+    STDMETHOD(GetFloatArray)(THIS_ float *values, UINT offset, UINT count) PURE;
+    STDMETHOD(SetInt)(THIS_ int value) PURE;
+    STDMETHOD(GetInt)(THIS_ int *value) PURE;
+    STDMETHOD(SetIntArray)(THIS_ int *values, UINT offset, UINT count) PURE;
+    STDMETHOD(GetIntArray)(THIS_ int *values, UINT offset, UINT count) PURE;
+    STDMETHOD(SetBool)(THIS_ BOOL value) PURE;
+    STDMETHOD(GetBool)(THIS_ BOOL *value) PURE;
+    STDMETHOD(SetBoolArray)(THIS_ BOOL *values, UINT offset, UINT count) PURE;
+    STDMETHOD(GetBoolArray)(THIS_ BOOL *values, UINT offset, UINT count) PURE;
+};
+#undef INTERFACE
+
+DEFINE_GUID(IID_ID3D10EffectVectorVariable, 0x62b98c44, 0x1f82, 0x4c67, 0xbc, 0xd0, 0x72, 0xcf, 0x8f, 0x21, 0x7e, 0x81);
+
+#define INTERFACE ID3D10EffectVectorVariable
+DECLARE_INTERFACE_(ID3D10EffectVectorVariable, ID3D10EffectVariable)
+{
+    /* ID3D10EffectVariable methods */
+    STDMETHOD_(BOOL, IsValid)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectType *, GetType)(THIS) PURE;
+    STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_VARIABLE_DESC *desc) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetAnnotationByIndex)(THIS_ UINT index) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetAnnotationByName)(THIS_ LPCSTR name) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetMemberByIndex)(THIS_ UINT index) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetMemberByName)(THIS_ LPCSTR name) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetMemberBySemantic)(THIS_ LPCSTR semantic) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetElement)(THIS_ UINT index) PURE;
+    STDMETHOD_(struct ID3D10EffectConstantBuffer *, GetParentConstantBuffer)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectScalarVariable *, AsScalar)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectVectorVariable *, AsVector)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectMatrixVariable *, AsMatrix)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectStringVariable *, AsString)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectShaderResourceVariable *, AsShaderResource)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectRenderTargetViewVariable *, AsRenderTargetView)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectDepthStencilViewVariable *, AsDepthStencilView)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectConstantBuffer *, AsConstantBuffer)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectShaderVariable *, AsShader)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectBlendVariable *, AsBlend)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectDepthStencilVariable *, AsDepthStencil)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectRasterizerVariable *, AsRasterizer)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectSamplerVariable *, AsSampler)(THIS) PURE;
+    STDMETHOD(SetRawValue)(THIS_ void *data, UINT offset, UINT count) PURE;
+    STDMETHOD(GetRawValue)(THIS_ void *data, UINT offset, UINT count) PURE;
+    /* ID3D10EffectVectorVariable methods */
+    STDMETHOD(SetBoolVector)(THIS_ BOOL *value) PURE;
+    STDMETHOD(SetIntVector)(THIS_ int *value) PURE;
+    STDMETHOD(SetFloatVector)(THIS_ float *value) PURE;
+    STDMETHOD(GetBoolVector)(THIS_ BOOL *value) PURE;
+    STDMETHOD(GetIntVector)(THIS_ int *value) PURE;
+    STDMETHOD(GetFloatVector)(THIS_ float *value) PURE;
+    STDMETHOD(SetBoolVectorArray)(THIS_ BOOL *values, UINT offset, UINT count) PURE;
+    STDMETHOD(SetIntVectorArray)(THIS_ int *values, UINT offset, UINT count) PURE;
+    STDMETHOD(SetFloatVectorArray)(THIS_ float *values, UINT offset, UINT count) PURE;
+    STDMETHOD(GetBoolVectorArray)(THIS_ BOOL *values, UINT offset, UINT count) PURE;
+    STDMETHOD(GetIntVectorArray)(THIS_ int *values, UINT offset, UINT count) PURE;
+    STDMETHOD(GetFloatVectorArray)(THIS_ float *values, UINT offset, UINT count) PURE;
 };
 #undef INTERFACE
@@ -253,4 +358,355 @@
     STDMETHOD(SetMatrixTransposeArray)(THIS_ float *data, UINT offset, UINT count) PURE;
     STDMETHOD(GetMatrixTransposeArray)(THIS_ float *data, UINT offset, UINT count) PURE;
+};
+#undef INTERFACE
+
+DEFINE_GUID(IID_ID3D10EffectStringVariable, 0x71417501, 0x8df9, 0x4e0a, 0xa7, 0x8a, 0x25, 0x5f, 0x97, 0x56, 0xba, 0xff);
+
+#define INTERFACE ID3D10EffectStringVariable
+DECLARE_INTERFACE_(ID3D10EffectStringVariable, ID3D10EffectVariable)
+{
+    /* ID3D10EffectVariable methods */
+    STDMETHOD_(BOOL, IsValid)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectType *, GetType)(THIS) PURE;
+    STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_VARIABLE_DESC *desc) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetAnnotationByIndex)(THIS_ UINT index) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetAnnotationByName)(THIS_ LPCSTR name) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetMemberByIndex)(THIS_ UINT index) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetMemberByName)(THIS_ LPCSTR name) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetMemberBySemantic)(THIS_ LPCSTR semantic) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetElement)(THIS_ UINT index) PURE;
+    STDMETHOD_(struct ID3D10EffectConstantBuffer *, GetParentConstantBuffer)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectScalarVariable *, AsScalar)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectVectorVariable *, AsVector)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectMatrixVariable *, AsMatrix)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectStringVariable *, AsString)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectShaderResourceVariable *, AsShaderResource)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectRenderTargetViewVariable *, AsRenderTargetView)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectDepthStencilViewVariable *, AsDepthStencilView)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectConstantBuffer *, AsConstantBuffer)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectShaderVariable *, AsShader)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectBlendVariable *, AsBlend)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectDepthStencilVariable *, AsDepthStencil)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectRasterizerVariable *, AsRasterizer)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectSamplerVariable *, AsSampler)(THIS) PURE;
+    STDMETHOD(SetRawValue)(THIS_ void *data, UINT offset, UINT count) PURE;
+    STDMETHOD(GetRawValue)(THIS_ void *data, UINT offset, UINT count) PURE;
+    /* ID3D10EffectStringVariable methods */
+    STDMETHOD(GetString)(THIS_ LPCSTR *str) PURE;
+    STDMETHOD(GetStringArray)(THIS_ LPCSTR *strs, UINT offset, UINT count) PURE;
+};
+#undef INTERFACE
+
+DEFINE_GUID(IID_ID3D10EffectShaderResourceVariable,
+        0xc0a7157b, 0xd872, 0x4b1d, 0x80, 0x73, 0xef, 0xc2, 0xac, 0xd4, 0xb1, 0xfc);
+
+#define INTERFACE ID3D10EffectShaderResourceVariable
+DECLARE_INTERFACE_(ID3D10EffectShaderResourceVariable, ID3D10EffectVariable)
+{
+    /* ID3D10EffectVariable methods */
+    STDMETHOD_(BOOL, IsValid)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectType *, GetType)(THIS) PURE;
+    STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_VARIABLE_DESC *desc) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetAnnotationByIndex)(THIS_ UINT index) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetAnnotationByName)(THIS_ LPCSTR name) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetMemberByIndex)(THIS_ UINT index) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetMemberByName)(THIS_ LPCSTR name) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetMemberBySemantic)(THIS_ LPCSTR semantic) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetElement)(THIS_ UINT index) PURE;
+    STDMETHOD_(struct ID3D10EffectConstantBuffer *, GetParentConstantBuffer)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectScalarVariable *, AsScalar)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectVectorVariable *, AsVector)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectMatrixVariable *, AsMatrix)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectStringVariable *, AsString)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectShaderResourceVariable *, AsShaderResource)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectRenderTargetViewVariable *, AsRenderTargetView)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectDepthStencilViewVariable *, AsDepthStencilView)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectConstantBuffer *, AsConstantBuffer)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectShaderVariable *, AsShader)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectBlendVariable *, AsBlend)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectDepthStencilVariable *, AsDepthStencil)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectRasterizerVariable *, AsRasterizer)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectSamplerVariable *, AsSampler)(THIS) PURE;
+    STDMETHOD(SetRawValue)(THIS_ void *data, UINT offset, UINT count) PURE;
+    STDMETHOD(GetRawValue)(THIS_ void *data, UINT offset, UINT count) PURE;
+    /* ID3D10EffectShaderResourceVariable methods */
+    STDMETHOD(SetResource)(THIS_ ID3D10ShaderResourceView *resource) PURE;
+    STDMETHOD(GetResource)(THIS_ ID3D10ShaderResourceView **resource) PURE;
+    STDMETHOD(SetResourceArray)(THIS_ ID3D10ShaderResourceView **resources, UINT offset, UINT count) PURE;
+    STDMETHOD(GetResourceArray)(THIS_ ID3D10ShaderResourceView **resources, UINT offset, UINT count) PURE;
+};
+#undef INTERFACE
+
+DEFINE_GUID(IID_ID3D10EffectRenderTargetViewVariable,
+        0x28ca0cc3, 0xc2c9, 0x40bb, 0xb5, 0x7f, 0x67, 0xb7, 0x37, 0x12, 0x2b, 0x17);
+
+#define INTERFACE ID3D10EffectRenderTargetViewVariable
+DECLARE_INTERFACE_(ID3D10EffectRenderTargetViewVariable, ID3D10EffectVariable)
+{
+    /* ID3D10EffectVariable methods */
+    STDMETHOD_(BOOL, IsValid)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectType *, GetType)(THIS) PURE;
+    STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_VARIABLE_DESC *desc) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetAnnotationByIndex)(THIS_ UINT index) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetAnnotationByName)(THIS_ LPCSTR name) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetMemberByIndex)(THIS_ UINT index) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetMemberByName)(THIS_ LPCSTR name) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetMemberBySemantic)(THIS_ LPCSTR semantic) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetElement)(THIS_ UINT index) PURE;
+    STDMETHOD_(struct ID3D10EffectConstantBuffer *, GetParentConstantBuffer)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectScalarVariable *, AsScalar)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectVectorVariable *, AsVector)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectMatrixVariable *, AsMatrix)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectStringVariable *, AsString)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectShaderResourceVariable *, AsShaderResource)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectRenderTargetViewVariable *, AsRenderTargetView)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectDepthStencilViewVariable *, AsDepthStencilView)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectConstantBuffer *, AsConstantBuffer)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectShaderVariable *, AsShader)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectBlendVariable *, AsBlend)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectDepthStencilVariable *, AsDepthStencil)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectRasterizerVariable *, AsRasterizer)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectSamplerVariable *, AsSampler)(THIS) PURE;
+    STDMETHOD(SetRawValue)(THIS_ void *data, UINT offset, UINT count) PURE;
+    STDMETHOD(GetRawValue)(THIS_ void *data, UINT offset, UINT count) PURE;
+    /* ID3D10EffectRenderTargetViewVariable methods */
+    STDMETHOD(SetRenderTarget)(THIS_ ID3D10RenderTargetView *view) PURE;
+    STDMETHOD(GetRenderTarget)(THIS_ ID3D10RenderTargetView **view) PURE;
+    STDMETHOD(SetRenderTargetArray)(THIS_ ID3D10RenderTargetView **views, UINT offset, UINT count) PURE;
+    STDMETHOD(GetRenderTargetArray)(THIS_ ID3D10RenderTargetView **views, UINT offset, UINT count) PURE;
+};
+#undef INTERFACE
+
+DEFINE_GUID(IID_ID3D10EffectDepthStencilViewVariable,
+        0x3e02c918, 0xcc79, 0x4985, 0xb6, 0x22, 0x2d, 0x92, 0xad, 0x70, 0x16, 0x23);
+
+#define INTERFACE ID3D10EffectDepthStencilViewVariable
+DECLARE_INTERFACE_(ID3D10EffectDepthStencilViewVariable, ID3D10EffectVariable)
+{
+    /* ID3D10EffectVariable methods */
+    STDMETHOD_(BOOL, IsValid)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectType *, GetType)(THIS) PURE;
+    STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_VARIABLE_DESC *desc) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetAnnotationByIndex)(THIS_ UINT index) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetAnnotationByName)(THIS_ LPCSTR name) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetMemberByIndex)(THIS_ UINT index) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetMemberByName)(THIS_ LPCSTR name) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetMemberBySemantic)(THIS_ LPCSTR semantic) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetElement)(THIS_ UINT index) PURE;
+    STDMETHOD_(struct ID3D10EffectConstantBuffer *, GetParentConstantBuffer)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectScalarVariable *, AsScalar)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectVectorVariable *, AsVector)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectMatrixVariable *, AsMatrix)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectStringVariable *, AsString)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectShaderResourceVariable *, AsShaderResource)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectRenderTargetViewVariable *, AsRenderTargetView)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectDepthStencilViewVariable *, AsDepthStencilView)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectConstantBuffer *, AsConstantBuffer)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectShaderVariable *, AsShader)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectBlendVariable *, AsBlend)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectDepthStencilVariable *, AsDepthStencil)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectRasterizerVariable *, AsRasterizer)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectSamplerVariable *, AsSampler)(THIS) PURE;
+    STDMETHOD(SetRawValue)(THIS_ void *data, UINT offset, UINT count) PURE;
+    STDMETHOD(GetRawValue)(THIS_ void *data, UINT offset, UINT count) PURE;
+    /* ID3D10EffectDepthStencilViewVariable methods */
+    STDMETHOD(SetDepthStencil)(THIS_ ID3D10DepthStencilView *view) PURE;
+    STDMETHOD(GetDepthStencil)(THIS_ ID3D10DepthStencilView **view) PURE;
+    STDMETHOD(SetDepthStencilArray)(THIS_ ID3D10DepthStencilView **views, UINT offset, UINT count) PURE;
+    STDMETHOD(GetDepthStencilArray)(THIS_ ID3D10DepthStencilView **views, UINT offset, UINT count) PURE;
+};
+#undef INTERFACE
+
+DEFINE_GUID(IID_ID3D10EffectShaderVariable, 0x80849279, 0xc799, 0x4797, 0x8c, 0x33, 0x04, 0x07, 0xa0, 0x7d, 0x9e, 0x06);
+
+#define INTERFACE ID3D10EffectShaderVariable
+DECLARE_INTERFACE_(ID3D10EffectShaderVariable, ID3D10EffectVariable)
+{
+    /* ID3D10EffectVariable methods */
+    STDMETHOD_(BOOL, IsValid)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectType *, GetType)(THIS) PURE;
+    STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_VARIABLE_DESC *desc) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetAnnotationByIndex)(THIS_ UINT index) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetAnnotationByName)(THIS_ LPCSTR name) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetMemberByIndex)(THIS_ UINT index) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetMemberByName)(THIS_ LPCSTR name) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetMemberBySemantic)(THIS_ LPCSTR semantic) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetElement)(THIS_ UINT index) PURE;
+    STDMETHOD_(struct ID3D10EffectConstantBuffer *, GetParentConstantBuffer)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectScalarVariable *, AsScalar)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectVectorVariable *, AsVector)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectMatrixVariable *, AsMatrix)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectStringVariable *, AsString)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectShaderResourceVariable *, AsShaderResource)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectRenderTargetViewVariable *, AsRenderTargetView)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectDepthStencilViewVariable *, AsDepthStencilView)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectConstantBuffer *, AsConstantBuffer)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectShaderVariable *, AsShader)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectBlendVariable *, AsBlend)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectDepthStencilVariable *, AsDepthStencil)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectRasterizerVariable *, AsRasterizer)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectSamplerVariable *, AsSampler)(THIS) PURE;
+    STDMETHOD(SetRawValue)(THIS_ void *data, UINT offset, UINT count) PURE;
+    STDMETHOD(GetRawValue)(THIS_ void *data, UINT offset, UINT count) PURE;
+    /* ID3D10EffectShaderVariable methods */
+    STDMETHOD(GetShaderDesc)(THIS_ UINT index, D3D10_EFFECT_SHADER_DESC *desc) PURE;
+    STDMETHOD(GetVertexShader)(THIS_ UINT index, ID3D10VertexShader **shader) PURE;
+    STDMETHOD(GetGeometryShader)(THIS_ UINT index, ID3D10GeometryShader **shader) PURE;
+    STDMETHOD(GetPixelShader)(THIS_ UINT index, ID3D10PixelShader **shader) PURE;
+    STDMETHOD(GetInputSignatureElementDesc)(THIS_ UINT shader_index, UINT element_index,
+            D3D10_SIGNATURE_PARAMETER_DESC *desc) PURE;
+    STDMETHOD(GetOutputSignatureElementDesc)(THIS_ UINT shader_index, UINT element_index,
+            D3D10_SIGNATURE_PARAMETER_DESC *desc) PURE;
+};
+#undef INTERFACE
+
+DEFINE_GUID(IID_ID3D10EffectBlendVariable, 0x1fcd2294, 0xdf6d, 0x4eae, 0x86, 0xb3, 0x0e, 0x91, 0x60, 0xcf, 0xb0, 0x7b);
+
+#define INTERFACE ID3D10EffectBlendVariable
+DECLARE_INTERFACE_(ID3D10EffectBlendVariable, ID3D10EffectVariable)
+{
+    /* ID3D10EffectVariable methods */
+    STDMETHOD_(BOOL, IsValid)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectType *, GetType)(THIS) PURE;
+    STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_VARIABLE_DESC *desc) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetAnnotationByIndex)(THIS_ UINT index) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetAnnotationByName)(THIS_ LPCSTR name) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetMemberByIndex)(THIS_ UINT index) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetMemberByName)(THIS_ LPCSTR name) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetMemberBySemantic)(THIS_ LPCSTR semantic) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetElement)(THIS_ UINT index) PURE;
+    STDMETHOD_(struct ID3D10EffectConstantBuffer *, GetParentConstantBuffer)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectScalarVariable *, AsScalar)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectVectorVariable *, AsVector)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectMatrixVariable *, AsMatrix)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectStringVariable *, AsString)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectShaderResourceVariable *, AsShaderResource)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectRenderTargetViewVariable *, AsRenderTargetView)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectDepthStencilViewVariable *, AsDepthStencilView)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectConstantBuffer *, AsConstantBuffer)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectShaderVariable *, AsShader)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectBlendVariable *, AsBlend)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectDepthStencilVariable *, AsDepthStencil)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectRasterizerVariable *, AsRasterizer)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectSamplerVariable *, AsSampler)(THIS) PURE;
+    STDMETHOD(SetRawValue)(THIS_ void *data, UINT offset, UINT count) PURE;
+    STDMETHOD(GetRawValue)(THIS_ void *data, UINT offset, UINT count) PURE;
+    /* ID3D10EffectBlendVariable methods */
+    STDMETHOD(GetBlendState)(THIS_ UINT index, ID3D10BlendState **blend_state) PURE;
+    STDMETHOD(GetBackingStore)(THIS_ UINT index, D3D10_BLEND_DESC *desc) PURE;
+};
+#undef INTERFACE
+
+DEFINE_GUID(IID_ID3D10EffectDepthStencilVariable,
+        0xaf482368, 0x330a, 0x46a5, 0x9a, 0x5c, 0x01, 0xc7, 0x1a, 0xf2, 0x4c, 0x8d);
+
+#define INTERFACE ID3D10EffectDepthStencilVariable
+DECLARE_INTERFACE_(ID3D10EffectDepthStencilVariable, ID3D10EffectVariable)
+{
+    /* ID3D10EffectVariable methods */
+    STDMETHOD_(BOOL, IsValid)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectType *, GetType)(THIS) PURE;
+    STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_VARIABLE_DESC *desc) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetAnnotationByIndex)(THIS_ UINT index) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetAnnotationByName)(THIS_ LPCSTR name) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetMemberByIndex)(THIS_ UINT index) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetMemberByName)(THIS_ LPCSTR name) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetMemberBySemantic)(THIS_ LPCSTR semantic) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetElement)(THIS_ UINT index) PURE;
+    STDMETHOD_(struct ID3D10EffectConstantBuffer *, GetParentConstantBuffer)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectScalarVariable *, AsScalar)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectVectorVariable *, AsVector)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectMatrixVariable *, AsMatrix)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectStringVariable *, AsString)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectShaderResourceVariable *, AsShaderResource)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectRenderTargetViewVariable *, AsRenderTargetView)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectDepthStencilViewVariable *, AsDepthStencilView)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectConstantBuffer *, AsConstantBuffer)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectShaderVariable *, AsShader)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectBlendVariable *, AsBlend)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectDepthStencilVariable *, AsDepthStencil)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectRasterizerVariable *, AsRasterizer)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectSamplerVariable *, AsSampler)(THIS) PURE;
+    STDMETHOD(SetRawValue)(THIS_ void *data, UINT offset, UINT count) PURE;
+    STDMETHOD(GetRawValue)(THIS_ void *data, UINT offset, UINT count) PURE;
+    /* ID3D10EffectDepthStencilVariable methods */
+    STDMETHOD(GetDepthStencilState)(THIS_ UINT index, ID3D10DepthStencilState **depth_stencil_state) PURE;
+    STDMETHOD(GetBackingStore)(THIS_ UINT index, D3D10_DEPTH_STENCIL_DESC *desc) PURE;
+};
+#undef INTERFACE
+
+DEFINE_GUID(IID_ID3D10EffectRasterizerVariable,
+        0x21af9f0e, 0x4d94, 0x4ea9, 0x97, 0x85, 0x2c, 0xb7, 0x6b, 0x8c, 0x0b, 0x34);
+
+#define INTERFACE ID3D10EffectRasterizerVariable
+DECLARE_INTERFACE_(ID3D10EffectRasterizerVariable, ID3D10EffectVariable)
+{
+    /* ID3D10EffectVariable methods */
+    STDMETHOD_(BOOL, IsValid)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectType *, GetType)(THIS) PURE;
+    STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_VARIABLE_DESC *desc) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetAnnotationByIndex)(THIS_ UINT index) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetAnnotationByName)(THIS_ LPCSTR name) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetMemberByIndex)(THIS_ UINT index) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetMemberByName)(THIS_ LPCSTR name) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetMemberBySemantic)(THIS_ LPCSTR semantic) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetElement)(THIS_ UINT index) PURE;
+    STDMETHOD_(struct ID3D10EffectConstantBuffer *, GetParentConstantBuffer)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectScalarVariable *, AsScalar)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectVectorVariable *, AsVector)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectMatrixVariable *, AsMatrix)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectStringVariable *, AsString)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectShaderResourceVariable *, AsShaderResource)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectRenderTargetViewVariable *, AsRenderTargetView)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectDepthStencilViewVariable *, AsDepthStencilView)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectConstantBuffer *, AsConstantBuffer)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectShaderVariable *, AsShader)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectBlendVariable *, AsBlend)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectDepthStencilVariable *, AsDepthStencil)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectRasterizerVariable *, AsRasterizer)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectSamplerVariable *, AsSampler)(THIS) PURE;
+    STDMETHOD(SetRawValue)(THIS_ void *data, UINT offset, UINT count) PURE;
+    STDMETHOD(GetRawValue)(THIS_ void *data, UINT offset, UINT count) PURE;
+    /* ID3D10EffectRasterizerVariable methods */
+    STDMETHOD(GetRasterizerState)(THIS_ UINT index, ID3D10RasterizerState **rasterizer_state) PURE;
+    STDMETHOD(GetBackingStore)(THIS_ UINT index, D3D10_RASTERIZER_DESC *desc) PURE;
+};
+#undef INTERFACE
+
+DEFINE_GUID(IID_ID3D10EffectSamplerVariable,
+        0x6530d5c7, 0x07e9, 0x4271, 0xa4, 0x18, 0xe7, 0xce, 0x4b, 0xd1, 0xe4, 0x80);
+
+#define INTERFACE ID3D10EffectSamplerVariable
+DECLARE_INTERFACE_(ID3D10EffectSamplerVariable, ID3D10EffectVariable)
+{
+    /* ID3D10EffectVariable methods */
+    STDMETHOD_(BOOL, IsValid)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectType *, GetType)(THIS) PURE;
+    STDMETHOD(GetDesc)(THIS_ D3D10_EFFECT_VARIABLE_DESC *desc) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetAnnotationByIndex)(THIS_ UINT index) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetAnnotationByName)(THIS_ LPCSTR name) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetMemberByIndex)(THIS_ UINT index) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetMemberByName)(THIS_ LPCSTR name) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetMemberBySemantic)(THIS_ LPCSTR semantic) PURE;
+    STDMETHOD_(struct ID3D10EffectVariable *, GetElement)(THIS_ UINT index) PURE;
+    STDMETHOD_(struct ID3D10EffectConstantBuffer *, GetParentConstantBuffer)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectScalarVariable *, AsScalar)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectVectorVariable *, AsVector)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectMatrixVariable *, AsMatrix)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectStringVariable *, AsString)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectShaderResourceVariable *, AsShaderResource)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectRenderTargetViewVariable *, AsRenderTargetView)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectDepthStencilViewVariable *, AsDepthStencilView)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectConstantBuffer *, AsConstantBuffer)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectShaderVariable *, AsShader)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectBlendVariable *, AsBlend)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectDepthStencilVariable *, AsDepthStencil)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectRasterizerVariable *, AsRasterizer)(THIS) PURE;
+    STDMETHOD_(struct ID3D10EffectSamplerVariable *, AsSampler)(THIS) PURE;
+    STDMETHOD(SetRawValue)(THIS_ void *data, UINT offset, UINT count) PURE;
+    STDMETHOD(GetRawValue)(THIS_ void *data, UINT offset, UINT count) PURE;
+    /* ID3D10EffectSamplerVariable methods */
+    STDMETHOD(GetSampler)(THIS_ UINT index, ID3D10SamplerState **sampler) PURE;
+    STDMETHOD(GetBackingStore)(THIS_ UINT index, D3D10_SAMPLER_DESC *desc) PURE;
 };
 #undef INTERFACE
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3drm.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3drm.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3drm.h	(revision 28475)
@@ -1,4 +1,5 @@
 /*
  * Copyright (C) 2005 Peter Berg Larsen
+ * Copyright (C) 2010 Christian Costa
  *
  * This library is free software; you can redistribute it and/or
@@ -30,4 +31,7 @@
 
 #include <ddraw.h>
+
+typedef struct IDirect3DRM *LPDIRECT3DRM;
+
 #include <d3drmobj.h>
 
@@ -40,6 +44,4 @@
 DEFINE_GUID(IID_IDirect3DRM2,               0x4516ecc8, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x00, 0x00, 0xc0, 0x78, 0x1b, 0xc3);
 DEFINE_GUID(IID_IDirect3DRM3,               0x4516ec83, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x00, 0x00, 0xc0, 0x78, 0x1b, 0xc3);
-
-typedef void *LPDIRECT3DRM;
 
 HRESULT WINAPI Direct3DRMCreate(LPDIRECT3DRM* ppDirect3DRM);
@@ -179,4 +181,293 @@
 #endif
 
+/*****************************************************************************
+ * IDirect3DRM2 interface
+ */
+#ifdef WINE_NO_UNICODE_MACROS
+#undef GetClassName
+#endif
+#define INTERFACE IDirect3DRM2
+DECLARE_INTERFACE_(IDirect3DRM2,IUnknown)
+{
+    /*** IUnknown methods ***/
+    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
+    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+    STDMETHOD_(ULONG,Release)(THIS) PURE;
+    /*** IDirect3DRM2 methods ***/
+    STDMETHOD(CreateObject)(THIS_ REFCLSID rclsid, LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj) PURE;
+    STDMETHOD(CreateFrame)(THIS_ LPDIRECT3DRMFRAME, LPDIRECT3DRMFRAME2 *) PURE;
+    STDMETHOD(CreateMesh)(THIS_ LPDIRECT3DRMMESH *) PURE;
+    STDMETHOD(CreateMeshBuilder)(THIS_ LPDIRECT3DRMMESHBUILDER2 *) PURE;
+    STDMETHOD(CreateFace)(THIS_ LPDIRECT3DRMFACE *) PURE;
+    STDMETHOD(CreateAnimation)(THIS_ LPDIRECT3DRMANIMATION *) PURE;
+    STDMETHOD(CreateAnimationSet)(THIS_ LPDIRECT3DRMANIMATIONSET *) PURE;
+    STDMETHOD(CreateTexture)(THIS_ LPD3DRMIMAGE, LPDIRECT3DRMTEXTURE2 *) PURE;
+    STDMETHOD(CreateLight)(THIS_ D3DRMLIGHTTYPE, D3DCOLOR, LPDIRECT3DRMLIGHT *) PURE;
+    STDMETHOD(CreateLightRGB)(THIS_ D3DRMLIGHTTYPE, D3DVALUE, D3DVALUE, D3DVALUE, LPDIRECT3DRMLIGHT *) PURE;
+    STDMETHOD(CreateMaterial)(THIS_ D3DVALUE, LPDIRECT3DRMMATERIAL *) PURE;
+    STDMETHOD(CreateDevice)(THIS_ DWORD, DWORD, LPDIRECT3DRMDEVICE2 *) PURE;
+    STDMETHOD(CreateDeviceFromSurface)(THIS_ LPGUID pGUID, LPDIRECTDRAW pDD, LPDIRECTDRAWSURFACE pDDSBack,
+        LPDIRECT3DRMDEVICE2 *) PURE;
+    STDMETHOD(CreateDeviceFromD3D)(THIS_ LPDIRECT3D2 pD3D, LPDIRECT3DDEVICE2 pD3DDev, LPDIRECT3DRMDEVICE2 *) PURE;
+    STDMETHOD(CreateDeviceFromClipper)(THIS_ LPDIRECTDRAWCLIPPER pDDClipper, LPGUID pGUID, int width, int height,
+        LPDIRECT3DRMDEVICE2 *) PURE;
+    STDMETHOD(CreateTextureFromSurface)(THIS_ LPDIRECTDRAWSURFACE pDDS, LPDIRECT3DRMTEXTURE2 *) PURE;
+    STDMETHOD(CreateShadow)(THIS_ LPDIRECT3DRMVISUAL, LPDIRECT3DRMLIGHT, D3DVALUE px, D3DVALUE py, D3DVALUE pz,
+        D3DVALUE nx, D3DVALUE ny, D3DVALUE nz, LPDIRECT3DRMVISUAL *) PURE;
+    STDMETHOD(CreateViewport)(THIS_ LPDIRECT3DRMDEVICE, LPDIRECT3DRMFRAME, DWORD, DWORD, DWORD, DWORD,
+        LPDIRECT3DRMVIEWPORT *) PURE;
+    STDMETHOD(CreateWrap)(THIS_ D3DRMWRAPTYPE, LPDIRECT3DRMFRAME, D3DVALUE ox, D3DVALUE oy, D3DVALUE oz,
+        D3DVALUE dx, D3DVALUE dy, D3DVALUE dz, D3DVALUE ux, D3DVALUE uy, D3DVALUE uz, D3DVALUE ou, D3DVALUE ov,
+        D3DVALUE su, D3DVALUE sv, LPDIRECT3DRMWRAP *) PURE;
+    STDMETHOD(CreateUserVisual)(THIS_ D3DRMUSERVISUALCALLBACK, LPVOID pArg, LPDIRECT3DRMUSERVISUAL *) PURE;
+    STDMETHOD(LoadTexture)(THIS_ const char *, LPDIRECT3DRMTEXTURE2 *) PURE;
+    STDMETHOD(LoadTextureFromResource)(THIS_ HMODULE hModule, LPCSTR /* LPCTSTR */ strName, LPCSTR /* LPCTSTR */ strType, LPDIRECT3DRMTEXTURE2 *) PURE;
+    STDMETHOD(SetSearchPath)(THIS_ LPCSTR) PURE;
+    STDMETHOD(AddSearchPath)(THIS_ LPCSTR) PURE;
+    STDMETHOD(GetSearchPath)(THIS_ DWORD *size_return, LPSTR path_return) PURE;
+    STDMETHOD(SetDefaultTextureColors)(THIS_ DWORD) PURE;
+    STDMETHOD(SetDefaultTextureShades)(THIS_ DWORD) PURE;
+    STDMETHOD(GetDevices)(THIS_ LPDIRECT3DRMDEVICEARRAY *) PURE;
+    STDMETHOD(GetNamedObject)(THIS_ const char *, LPDIRECT3DRMOBJECT *) PURE;
+    STDMETHOD(EnumerateObjects)(THIS_ D3DRMOBJECTCALLBACK, LPVOID) PURE;
+    STDMETHOD(Load)(THIS_ LPVOID, LPVOID, LPIID *, DWORD, D3DRMLOADOPTIONS, D3DRMLOADCALLBACK, LPVOID,
+        D3DRMLOADTEXTURECALLBACK, LPVOID, LPDIRECT3DRMFRAME) PURE;
+    STDMETHOD(Tick)(THIS_ D3DVALUE) PURE;
+    STDMETHOD(CreateProgressiveMesh)(THIS_ LPDIRECT3DRMPROGRESSIVEMESH) PURE;
+};
+#undef INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IDirect3DRM2_QueryInterface(p,a,b)                         (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DRM2_AddRef(p)                                     (p)->lpVtbl->AddRef(p)
+#define IDirect3DRM2_Release(p)                                    (p)->lpVtbl->Release(p)
+/*** IDirect3DRM2 methods ***/
+#define IDirect3DRM2_CreateObject(p,a,b,c,d)                       (p)->lpVtbl->CreateObject(p,a,b,d)
+#define IDirect3DRM2_CreateFrame(p,a,b)                            (p)->lpVtbl->CreateFrame(p,a,b)
+#define IDirect3DRM2_CreateMesh(p,a)                               (p)->lpVtbl->CreateMesh(p,a)
+#define IDirect3DRM2_CreateMeshBuilder(p,a)                        (p)->lpVtbl->CreateMeshBuilder(p,a)
+#define IDirect3DRM2_CreateFace(p,a)                               (p)->lpVtbl->CreateFace(p,a)
+#define IDirect3DRM2_CreateAnimation(p,a)                          (p)->lpVtbl->CreateAnimation(p,a)
+#define IDirect3DRM2_CreateAnimationSet(p,a)                       (p)->lpVtbl->CreateAnimationSet(p,a)
+#define IDirect3DRM2_CreateTexture(p,a,b)                          (p)->lpVtbl->CreateTexture(p,a,b)
+#define IDirect3DRM2_CreateLight(p,a,b,c)                          (p)->lpVtbl->CreateLight(p,a,b,c)
+#define IDirect3DRM2_CreateLightRGB(p,a,b,c,d,e)                   (p)->lpVtbl->CreateLightRGB(p,a,b,c,d,e)
+#define IDirect3DRM2_CreateMaterial(p,a,b)                         (p)->lpVtbl->CreateMaterial(p,a,b)
+#define IDirect3DRM2_CreateDevice(p,a,b,c)                         (p)->lpVtbl->CreateDevice(p,a,b,c)
+#define IDirect3DRM2_CreateDeviceFromSurface(p,a,b,c,d)            (p)->lpVtbl->CreateDeviceFromSurface(p,a,b,c,d)
+#define IDirect3DRM2_CreateDeviceFromD3D(p,a,b,c)                  (p)->lpVtbl->CreateDeviceFromD3D(p,a,b,c)
+#define IDirect3DRM2_CreateDeviceFromClipper(p,a,b,c,d,e)          (p)->lpVtbl->CreateDeviceFromClipper(p,a,b,c,d,e)
+#define IDirect3DRM2_CreateTextureFromSurface(p,a,b)               (p)->lpVtbl->CreateTextureFromSurface(p,a,b)
+#define IDirect3DRM2_CreateShadow(p,a,b,c,d,e,f,g,h,i)             (p)->lpVtbl->CreateShadow(p,a,b,c,d,e,f,g,h,i)
+#define IDirect3DRM2_CreateViewport(p,a,b,c,d,e,f,g)               (p)->lpVtbl->CreateViewport(p,a,b,c,d,e,f,g)
+#define IDirect3DRM2_CreateWrap(p,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,q) (p)->lpVtbl->CreateWrap(p,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,q)
+#define IDirect3DRM2_CreateUserVisual(p,a,b,c)                     (p)->lpVtbl->CreateUserVisual(p,a,b,c)
+#define IDirect3DRM2_LoadTexture(p,a,b)                            (p)->lpVtbl->LoadTexture(p,a,b)
+#define IDirect3DRM2_LoadTextureFromResource(p,a,b,c,d)            (p)->lpVtbl->LoadTextureFromResource(p,a,b,c,d)
+#define IDirect3DRM2_SetSearchPath(p,a)                            (p)->lpVtbl->SetSearchPath(p,a)
+#define IDirect3DRM2_AddSearchPath(p,a)                            (p)->lpVtbl->AddSearchPath(p,a)
+#define IDirect3DRM2_GetSearchPath(p,a,b)                          (p)->lpVtbl->GetSearchPath(p,a,b)
+#define IDirect3DRM2_SetDefaultTextureColors(p,a)                  (p)->lpVtbl->SetDefaultTextureColors(p,a)
+#define IDirect3DRM2_SetDefaultTextureShades(p,a)                  (p)->lpVtbl->SetDefaultTextureShades(p,a)
+#define IDirect3DRM2_GetDevices(p,a)                               (p)->lpVtbl->GetDevices(p,a)
+#define IDirect3DRM2_GetNamedObject(p,a,b)                         (p)->lpVtbl->GetNamedObject(p,a,b)
+#define IDirect3DRM2_EnumerateObjects(p,a,b)                       (p)->lpVtbl->EnumerateObjects(p,a,b)
+#define IDirect3DRM2_Load(p,a,b,c,d,e,f,g,h,i,j)                   (p)->lpVtbl->Load(p,a,b,c,d,e,f,g,h,i,j)
+#define IDirect3DRM2_Tick(p,a)                                     (p)->lpVtbl->Tick(p,a)
+#define IDirect3DRM2_CreateProgressiveMesh(p,a)                    (p)->lpVtbl->CreateProgressiveMesh(p,a)
+#else
+/*** IUnknown methods ***/
+#define IDirect3DRM2_QueryInterface(p,a,b)                         (p)->QueryInterface(a,b)
+#define IDirect3DRM2_AddRef(p)                                     (p)->AddRef()
+#define IDirect3DRM2_Release(p)                                    (p)->Release()
+/*** IDirect3DRM2 methods ***/
+#define IDirect3DRM2_CreateObject(p,a,b,c,d)                       (p)->CreateObject(a,b,d)
+#define IDirect3DRM2_CreateFrame(p,a,b)                            (p)->CreateFrame(a,b)
+#define IDirect3DRM2_CreateMesh(p,a)                               (p)->CreateMesh(a)
+#define IDirect3DRM2_CreateMeshBuilder(p,a)                        (p)->CreateMeshBuilder(a)
+#define IDirect3DRM2_CreateFace(p,a)                               (p)->CreateFace(a)
+#define IDirect3DRM2_CreateAnimation(p,a)                          (p)->CreateAnimation(a)
+#define IDirect3DRM2_CreateAnimationSet(p,a)                       (p)->CreateAnimationSet(a)
+#define IDirect3DRM2_CreateTexture(p,a,b)                          (p)->CreateTexture(a,b)
+#define IDirect3DRM2_CreateLight(p,a,b,c)                          (p)->CreateLight(a,b,c)
+#define IDirect3DRM2_CreateLightRGB(p,a,b,c,d,e)                   (p)->CreateLightRGB(a,b,c,d,e)
+#define IDirect3DRM2_CreateMaterial(p,a,b)                         (p)->CreateMaterial(a,b)
+#define IDirect3DRM2_CreateDevice(p,a,b,c)                         (p)->CreateDevice(a,b,c)
+#define IDirect3DRM2_CreateDeviceFromSurface(p,a,b,c,d)            (p)->CreateDeviceFromSurface(a,b,c,d)
+#define IDirect3DRM2_CreateDeviceFromD3D(p,a,b,c)                  (p)->CreateDeviceFromD3D(a,b,c)
+#define IDirect3DRM2_CreateDeviceFromClipper(p,a,b,c,d,e)          (p)->CreateDeviceFromClipper(a,b,c,d,e)
+#define IDirect3DRM2_CreateTextureFromSurface(p,a,b)               (p)->CreateTextureFromSurface(a,b)
+#define IDirect3DRM2_CreateShadow(p,a,b,c,d,e,f,g,h,i)             (p)->CreateShadow(a,b,c,d,e,f,g,h,i)
+#define IDirect3DRM2_CreateViewport(p,a,b,c,d,e,f,g)               (p)->CreateViewport(a,b,c,d,e,f,g)
+#define IDirect3DRM2_CreateWrap(p,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) (p)->CreateWrap(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p)
+#define IDirect3DRM2_CreateUserVisual(p,a,b,c)                     (p)->CreateUserVisual(a,b,c)
+#define IDirect3DRM2_LoadTexture(p,a,b)                            (p)->LoadTexture(a,b)
+#define IDirect3DRM2_LoadTextureFromResource(p,a,b)                (p)->LoadTextureFromResource(a,b)
+#define IDirect3DRM2_SetSearchPath(p,a)                            (p)->SetSearchPath(a)
+#define IDirect3DRM2_AddSearchPath(p,a)                            (p)->AddSearchPath(a)
+#define IDirect3DRM2_GetSearchPath(p,a,b)                          (p)->GetSearchPath(a,b)
+#define IDirect3DRM2_SetDefaultTextureColors(p,a)                  (p)->SetDefaultTextureColors(a)
+#define IDirect3DRM2_SetDefaultTextureShades(p,a)                  (p)->SetDefaultTextureShades(a)
+#define IDirect3DRM2_GetDevices(p,a)                               (p)->GetDevices(a)
+#define IDirect3DRM2_GetNamedObject(p,a,b)                         (p)->GetNamedObject(a,b)
+#define IDirect3DRM2_EnumerateObjects(p,a,b)                       (p)->EnumerateObjects(a,b)
+#define IDirect3DRM2_Load(p,a,b,c,d,e,f,g,h,i,j)                   (p)->Load(a,b,c,d,e,f,g,h,i,j)
+#define IDirect3DRM2_Tick(p,a)                                     (p)->Tick(a)
+#define IDirect3DRM2_CreateProgressiveMesh(p,a)                    (p)->CreateProgressiveMesh(p,a)
+#endif
+
+/*****************************************************************************
+ * IDirect3DRM3 interface
+ */
+#ifdef WINE_NO_UNICODE_MACROS
+#undef GetClassName
+#endif
+#define INTERFACE IDirect3DRM3
+DECLARE_INTERFACE_(IDirect3DRM3,IUnknown)
+{
+    /*** IUnknown methods ***/
+    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
+    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+    STDMETHOD_(ULONG,Release)(THIS) PURE;
+    /*** IDirect3DRM2 methods ***/
+    STDMETHOD(CreateObject)(THIS_ REFCLSID rclsid, LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj) PURE;
+    STDMETHOD(CreateFrame)(THIS_ LPDIRECT3DRMFRAME3, LPDIRECT3DRMFRAME3 *) PURE;
+    STDMETHOD(CreateMesh)(THIS_ LPDIRECT3DRMMESH *) PURE;
+    STDMETHOD(CreateMeshBuilder)(THIS_ LPDIRECT3DRMMESHBUILDER3 *) PURE;
+    STDMETHOD(CreateFace)(THIS_ LPDIRECT3DRMFACE2 *) PURE;
+    STDMETHOD(CreateAnimation)(THIS_ LPDIRECT3DRMANIMATION2 *) PURE;
+    STDMETHOD(CreateAnimationSet)(THIS_ LPDIRECT3DRMANIMATIONSET2 *) PURE;
+    STDMETHOD(CreateTexture)(THIS_ LPD3DRMIMAGE, LPDIRECT3DRMTEXTURE3 *) PURE;
+    STDMETHOD(CreateLight)(THIS_ D3DRMLIGHTTYPE, D3DCOLOR, LPDIRECT3DRMLIGHT *) PURE;
+    STDMETHOD(CreateLightRGB)(THIS_ D3DRMLIGHTTYPE, D3DVALUE, D3DVALUE, D3DVALUE, LPDIRECT3DRMLIGHT *) PURE;
+    STDMETHOD(CreateMaterial)(THIS_ D3DVALUE, LPDIRECT3DRMMATERIAL2 *) PURE;
+    STDMETHOD(CreateDevice)(THIS_ DWORD, DWORD, LPDIRECT3DRMDEVICE3 *) PURE;
+    STDMETHOD(CreateDeviceFromSurface)(THIS_ LPGUID pGUID, LPDIRECTDRAW pDD, LPDIRECTDRAWSURFACE pDDSBack,
+        LPDIRECT3DRMDEVICE3 *) PURE;
+    STDMETHOD(CreateDeviceFromD3D)(THIS_ LPDIRECT3D2 pD3D, LPDIRECT3DDEVICE2 pD3DDev, LPDIRECT3DRMDEVICE3 *) PURE;
+    STDMETHOD(CreateDeviceFromClipper)(THIS_ LPDIRECTDRAWCLIPPER pDDClipper, LPGUID pGUID, int width, int height,
+        LPDIRECT3DRMDEVICE3 *) PURE;
+    STDMETHOD(CreateTextureFromSurface)(THIS_ LPDIRECTDRAWSURFACE pDDS, LPDIRECT3DRMTEXTURE3 *) PURE;
+    STDMETHOD(CreateShadow)(THIS_ LPUNKNOWN, LPDIRECT3DRMLIGHT, D3DVALUE px, D3DVALUE py, D3DVALUE pz,
+        D3DVALUE nx, D3DVALUE ny, D3DVALUE nz, LPDIRECT3DRMSHADOW2 *) PURE;
+    STDMETHOD(CreateViewport)(THIS_ LPDIRECT3DRMDEVICE3, LPDIRECT3DRMFRAME3, DWORD, DWORD, DWORD, DWORD,
+        LPDIRECT3DRMVIEWPORT2 *) PURE;
+    STDMETHOD(CreateWrap)(THIS_ D3DRMWRAPTYPE, LPDIRECT3DRMFRAME3, D3DVALUE ox, D3DVALUE oy, D3DVALUE oz,
+        D3DVALUE dx, D3DVALUE dy, D3DVALUE dz, D3DVALUE ux, D3DVALUE uy, D3DVALUE uz, D3DVALUE ou, D3DVALUE ov,
+        D3DVALUE su, D3DVALUE sv, LPDIRECT3DRMWRAP *) PURE;
+    STDMETHOD(CreateUserVisual)(THIS_ D3DRMUSERVISUALCALLBACK, LPVOID pArg, LPDIRECT3DRMUSERVISUAL *) PURE;
+    STDMETHOD(LoadTexture)(THIS_ const char *, LPDIRECT3DRMTEXTURE3 *) PURE;
+    STDMETHOD(LoadTextureFromResource)(THIS_ HMODULE hModule, LPCSTR /* LPCTSTR */ strName, LPCSTR  /* LPCTSTR */ strType, LPDIRECT3DRMTEXTURE3 *) PURE;
+    STDMETHOD(SetSearchPath)(THIS_ LPCSTR) PURE;
+    STDMETHOD(AddSearchPath)(THIS_ LPCSTR) PURE;
+    STDMETHOD(GetSearchPath)(THIS_ DWORD *size_return, LPSTR path_return) PURE;
+    STDMETHOD(SetDefaultTextureColors)(THIS_ DWORD) PURE;
+    STDMETHOD(SetDefaultTextureShades)(THIS_ DWORD) PURE;
+    STDMETHOD(GetDevices)(THIS_ LPDIRECT3DRMDEVICEARRAY *) PURE;
+    STDMETHOD(GetNamedObject)(THIS_ const char *, LPDIRECT3DRMOBJECT *) PURE;
+    STDMETHOD(EnumerateObjects)(THIS_ D3DRMOBJECTCALLBACK, LPVOID) PURE;
+    STDMETHOD(Load)(THIS_ LPVOID, LPVOID, LPIID *, DWORD, D3DRMLOADOPTIONS, D3DRMLOADCALLBACK, LPVOID,
+        D3DRMLOADTEXTURECALLBACK, LPVOID, LPDIRECT3DRMFRAME3) PURE;
+    STDMETHOD(Tick)(THIS_ D3DVALUE) PURE;
+    STDMETHOD(CreateProgressiveMesh)(THIS_ LPDIRECT3DRMPROGRESSIVEMESH) PURE;
+    STDMETHOD(RegisterClient)(THIS_ REFGUID rguid, LPDWORD lpdwID) PURE;
+    STDMETHOD(UnregisterClient)(THIS_ REFGUID rguid) PURE;
+    STDMETHOD(CreateClippedVisual)(THIS_ LPDIRECT3DRMVISUAL, LPDIRECT3DRMCLIPPEDVISUAL *) PURE;
+    STDMETHOD(SetOptions)(THIS_ DWORD) PURE;
+    STDMETHOD(GetOptions)(THIS_ LPDWORD) PURE;
+};
+#undef INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IDirect3DRM3_QueryInterface(p,a,b)                         (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DRM3_AddRef(p)                                     (p)->lpVtbl->AddRef(p)
+#define IDirect3DRM3_Release(p)                                    (p)->lpVtbl->Release(p)
+/*** IDirect3DRM3 methods ***/
+#define IDirect3DRM3_CreateObject(p,a,b,c,d)                       (p)->lpVtbl->CreateObject(p,a,b,d)
+#define IDirect3DRM3_CreateFrame(p,a,b)                            (p)->lpVtbl->CreateFrame(p,a,b)
+#define IDirect3DRM3_CreateMesh(p,a)                               (p)->lpVtbl->CreateMesh(p,a)
+#define IDirect3DRM3_CreateMeshBuilder(p,a)                        (p)->lpVtbl->CreateMeshBuilder(p,a)
+#define IDirect3DRM3_CreateFace(p,a)                               (p)->lpVtbl->CreateFace(p,a)
+#define IDirect3DRM3_CreateAnimation(p,a)                          (p)->lpVtbl->CreateAnimation(p,a)
+#define IDirect3DRM3_CreateAnimationSet(p,a)                       (p)->lpVtbl->CreateAnimationSet(p,a)
+#define IDirect3DRM3_CreateTexture(p,a,b)                          (p)->lpVtbl->CreateTexture(p,a,b)
+#define IDirect3DRM3_CreateLight(p,a,b,c)                          (p)->lpVtbl->CreateLight(p,a,b,c)
+#define IDirect3DRM3_CreateLightRGB(p,a,b,c,d,e)                   (p)->lpVtbl->CreateLightRGB(p,a,b,c,d,e)
+#define IDirect3DRM3_CreateMaterial(p,a,b)                         (p)->lpVtbl->CreateMaterial(p,a,b)
+#define IDirect3DRM3_CreateDevice(p,a,b,c)                         (p)->lpVtbl->CreateDevice(p,a,b,c)
+#define IDirect3DRM3_CreateDeviceFromSurface(p,a,b,c,d)            (p)->lpVtbl->CreateDeviceFromSurface(p,a,b,c,d)
+#define IDirect3DRM3_CreateDeviceFromD3D(p,a,b,c)                  (p)->lpVtbl->CreateDeviceFromD3D(p,a,b,c)
+#define IDirect3DRM3_CreateDeviceFromClipper(p,a,b,c,d,e)          (p)->lpVtbl->CreateDeviceFromClipper(p,a,b,c,d,e)
+#define IDirect3DRM3_CreateTextureFromSurface(p,a,b)               (p)->lpVtbl->CreateTextureFromSurface(p,a,b)
+#define IDirect3DRM3_CreateShadow(p,a,b,c,d,e,f,g,h,i)             (p)->lpVtbl->CreateShadow(p,a,b,c,d,e,f,g,h,i)
+#define IDirect3DRM3_CreateViewport(p,a,b,c,d,e,f,g)               (p)->lpVtbl->CreateViewport(p,a,b,c,d,e,f,g)
+#define IDirect3DRM3_CreateWrap(p,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,q) (p)->lpVtbl->CreateWrap(p,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,q)
+#define IDirect3DRM3_CreateUserVisual(p,a,b,c)                     (p)->lpVtbl->CreateUserVisual(p,a,b,c)
+#define IDirect3DRM3_LoadTexture(p,a,b)                            (p)->lpVtbl->LoadTexture(p,a,b)
+#define IDirect3DRM3_LoadTextureFromResource(p,a,b,c,d)            (p)->lpVtbl->LoadTextureFromResource(p,a,b,c,d)
+#define IDirect3DRM3_SetSearchPath(p,a)                            (p)->lpVtbl->SetSearchPath(p,a)
+#define IDirect3DRM3_AddSearchPath(p,a)                            (p)->lpVtbl->AddSearchPath(p,a)
+#define IDirect3DRM3_GetSearchPath(p,a,b)                          (p)->lpVtbl->GetSearchPath(p,a,b)
+#define IDirect3DRM3_SetDefaultTextureColors(p,a)                  (p)->lpVtbl->SetDefaultTextureColors(p,a)
+#define IDirect3DRM3_SetDefaultTextureShades(p,a)                  (p)->lpVtbl->SetDefaultTextureShades(p,a)
+#define IDirect3DRM3_GetDevices(p,a)                               (p)->lpVtbl->GetDevices(p,a)
+#define IDirect3DRM3_GetNamedObject(p,a,b)                         (p)->lpVtbl->GetNamedObject(p,a,b)
+#define IDirect3DRM3_EnumerateObjects(p,a,b)                       (p)->lpVtbl->EnumerateObjects(p,a,b)
+#define IDirect3DRM3_Load(p,a,b,c,d,e,f,g,h,i,j)                   (p)->lpVtbl->Load(p,a,b,c,d,e,f,g,h,i,j)
+#define IDirect3DRM3_Tick(p,a)                                     (p)->lpVtbl->Tick(p,a)
+#define IDirect3DRM3_CreateProgressiveMesh(p,a)                    (p)->lpVtbl->CreateProgressiveMesh(p,a)
+#define IDirect3DRM3_RegisterClient(p,a,b)                         (p)->lpVtbl->RegisterClient(p,a,b)
+#define IDirect3DRM3_UnregisterClient(p,a)                         (p)->lpVtbl->UnregisterClient(p,a)
+#define IDirect3DRM3_CreateClippedVisual(p,ab)                     (p)->lpVtbl->CreateClippedVisual(p,a,b)
+#define IDirect3DRM3_SetOptions(p,a)                               (p)->lpVtbl->SetOptions(p,a)
+#define IDirect3DRM3_GetOptions(p,a)                               (p)->lpVtbl->GetOptions(p,a)
+#else
+/*** IUnknown methods ***/
+#define IDirect3DRM3_QueryInterface(p,a,b)                         (p)->QueryInterface(a,b)
+#define IDirect3DRM3_AddRef(p)                                     (p)->AddRef()
+#define IDirect3DRM3_Release(p)                                    (p)->Release()
+/*** IDirect3DRM3 methods ***/
+#define IDirect3DRM3_CreateObject(p,a,b,c,d)                       (p)->CreateObject(a,b,d)
+#define IDirect3DRM3_CreateFrame(p,a,b)                            (p)->CreateFrame(a,b)
+#define IDirect3DRM3_CreateMesh(p,a)                               (p)->CreateMesh(a)
+#define IDirect3DRM3_CreateMeshBuilder(p,a)                        (p)->CreateMeshBuilder(a)
+#define IDirect3DRM3_CreateFace(p,a)                               (p)->CreateFace(a)
+#define IDirect3DRM3_CreateAnimation(p,a)                          (p)->CreateAnimation(a)
+#define IDirect3DRM3_CreateAnimationSet(p,a)                       (p)->CreateAnimationSet(a)
+#define IDirect3DRM3_CreateTexture(p,a,b)                          (p)->CreateTexture(a,b)
+#define IDirect3DRM3_CreateLight(p,a,b,c)                          (p)->CreateLight(a,b,c)
+#define IDirect3DRM3_CreateLightRGB(p,a,b,c,d,e)                   (p)->CreateLightRGB(a,b,c,d,e)
+#define IDirect3DRM3_CreateMaterial(p,a,b)                         (p)->CreateMaterial(a,b)
+#define IDirect3DRM3_CreateDevice(p,a,b,c)                         (p)->CreateDevice(a,b,c)
+#define IDirect3DRM3_CreateDeviceFromSurface(p,a,b,c,d)            (p)->CreateDeviceFromSurface(a,b,c,d)
+#define IDirect3DRM3_CreateDeviceFromD3D(p,a,b,c)                  (p)->CreateDeviceFromD3D(a,b,c)
+#define IDirect3DRM3_CreateDeviceFromClipper(p,a,b,c,d,e)          (p)->CreateDeviceFromClipper(a,b,c,d,e)
+#define IDirect3DRM3_CreateTextureFromSurface(p,a,b)               (p)->CreateTextureFromSurface(a,b)
+#define IDirect3DRM3_CreateShadow(p,a,b,c,d,e,f,g,h,i)             (p)->CreateShadow(a,b,c,d,e,f,g,h,i)
+#define IDirect3DRM3_CreateViewport(p,a,b,c,d,e,f,g)               (p)->CreateViewport(a,b,c,d,e,f,g)
+#define IDirect3DRM3_CreateWrap(p,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) (p)->CreateWrap(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p)
+#define IDirect3DRM3_CreateUserVisual(p,a,b,c)                     (p)->CreateUserVisual(a,b,c)
+#define IDirect3DRM3_LoadTexture(p,a,b)                            (p)->LoadTexture(a,b)
+#define IDirect3DRM3_LoadTextureFromResource(p,a,b,c,d)            (p)->LoadTextureFromResource(a,b,c,d)
+#define IDirect3DRM3_SetSearchPath(p,a)                            (p)->SetSearchPath(a)
+#define IDirect3DRM3_AddSearchPath(p,a)                            (p)->AddSearchPath(a)
+#define IDirect3DRM3_GetSearchPath(p,a,b)                          (p)->GetSearchPath(a,b)
+#define IDirect3DRM3_SetDefaultTextureColors(p,a)                  (p)->SetDefaultTextureColors(a)
+#define IDirect3DRM3_SetDefaultTextureShades(p,a)                  (p)->SetDefaultTextureShades(a)
+#define IDirect3DRM3_GetDevices(p,a)                               (p)->GetDevices(a)
+#define IDirect3DRM3_GetNamedObject(p,a,b)                         (p)->GetNamedObject(a,b)
+#define IDirect3DRM3_EnumerateObjects(p,a,b)                       (p)->EnumerateObjects(a,b)
+#define IDirect3DRM3_Load(p,a,b,c,d,e,f,g,h,i,j)                   (p)->Load(a,b,c,d,e,f,g,h,i,j)
+#define IDirect3DRM3_Tick(p,a)                                     (p)->Tick(a)
+#define IDirect3DRM3_CreateProgressiveMesh(p,a)                    (p)->CreateProgressiveMesh(p,a)
+#define IDirect3DRM3_RegisterClient(p,a,b)                         (p)->RegisterClient(p,a,b)
+#define IDirect3DRM3_UnregisterClient(p,a)                         (p)->UnregisterClient(p,a)
+#define IDirect3DRM3_CreateClippedVisual(p,ab)                     (p)->CreateClippedVisual(p,a,b)
+#define IDirect3DRM3_SetOptions(p,a)                               (p)->SetOptions(p,a)
+#define IDirect3DRM3_GetOptions(p,a)                               (p)->GetOptions(p,a)
+#endif
+
 #define D3DRM_OK                        DD_OK
 #define D3DRMERR_BADOBJECT              MAKE_DDHRESULT(781)
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3drmdef.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3drmdef.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3drmdef.h	(revision 28475)
@@ -2,4 +2,5 @@
  * Copyright 2007 Vijay Kiran Kamuju
  * Copyright 2007 David ADAM
+ * Copyright 2010 Christian Costa
  *
  * This library is free software; you can redistribute it and/or
@@ -37,4 +38,12 @@
 #endif
 
+typedef struct _D3DRMVECTOR4D
+{
+    D3DVALUE x;
+    D3DVALUE y;
+    D3DVALUE z;
+    D3DVALUE w;
+} D3DRMVECTOR4D, *LPD3DRMVECTOR4D;
+
 typedef D3DVALUE D3DRMMATRIX4D[4][4];
 
@@ -43,4 +52,14 @@
     D3DVECTOR v;
 } D3DRMQUATERNION, *LPD3DRMQUATERNION;
+
+typedef struct _D3DRMRAY {
+    D3DVECTOR dvDir;
+    D3DVECTOR dvPos;
+} D3DRMRAY, *LPD3DRMRAY;
+
+typedef struct _D3DRMBOX {
+    D3DVECTOR min;
+    D3DVECTOR max;
+} D3DRMBOX, *LPD3DRMBOX;
 
 typedef enum _D3DRMLIGHTTYPE {
@@ -51,4 +70,21 @@
     D3DRMLIGHT_PARALLELPOINT
 } D3DRMLIGHTTYPE, *LPD3DRMLIGHTTYPE;
+
+typedef DWORD D3DRMRENDERQUALITY, *LPD3DRMRENDERQUALITY;
+
+typedef enum _D3DRMTEXTUREQUALITY {
+    D3DRMTEXTURE_NEAREST,
+    D3DRMTEXTURE_LINEAR,
+    D3DRMTEXTURE_MIPNEAREST,
+    D3DRMTEXTURE_MIPLINEAR,
+    D3DRMTEXTURE_LINEARMIPNEAREST,
+    D3DRMTEXTURE_LINEARMIPLINEAR
+} D3DRMTEXTUREQUALITY, *LPD3DRMTEXTUREQUALITY;
+
+typedef enum _D3DRMCOMBINETYPE {
+    D3DRMCOMBINE_REPLACE,
+    D3DRMCOMBINE_BEFORE,
+    D3DRMCOMBINE_AFTER
+} D3DRMCOMBINETYPE, *LPD3DRMCOMBINETYPE;
 
 typedef struct _D3DRMPALETTEENTRY {
@@ -86,5 +122,106 @@
 } D3DRMWRAPTYPE, *LPD3DRMWRAPTYPE;
 
+typedef enum _D3DRMPROJECTIONTYPE
+{
+    D3DRMPROJECT_PERSPECTIVE,
+    D3DRMPROJECT_ORTHOGRAPHIC,
+    D3DRMPROJECT_RIGHTHANDPERSPECTIVE,
+    D3DRMPROJECT_RIGHTHANDORTHOGRAPHIC
+} D3DRMPROJECTIONTYPE, *LPD3DRMPROJECTIONTYPE;
+
+typedef enum _D3DRMXOFFORMAT {
+    D3DRMXOF_BINARY,
+    D3DRMXOF_COMPRESSED,
+    D3DRMXOF_TEXT
+} D3DRMXOFFORMAT, *LPD3DRMXOFFORMAT;
+
+typedef DWORD D3DRMSAVEOPTIONS;
+
+typedef enum _D3DRMCOLORSOURCE {
+    D3DRMCOLOR_FROMFACE,
+    D3DRMCOLOR_FROMVERTEX
+} D3DRMCOLORSOURCE, *LPD3DRMCOLORSOURCE;
+
+typedef enum _D3DRMFRAMECONSTRAINT {
+    D3DRMCONSTRAIN_Z,
+    D3DRMCONSTRAIN_Y,
+    D3DRMCONSTRAIN_X
+} D3DRMFRAMECONSTRAINT, *LPD3DRMFRAMECONSTRAINT;
+
+typedef enum _D3DRMMATERIALMODE {
+    D3DRMMATERIAL_FROMMESH,
+    D3DRMMATERIAL_FROMPARENT,
+    D3DRMMATERIAL_FROMFRAME
+} D3DRMMATERIALMODE, *LPD3DRMMATERIALMODE;
+
+typedef enum _D3DRMFOGMODE {
+    D3DRMFOG_LINEAR,
+    D3DRMFOG_EXPONENTIAL,
+    D3DRMFOG_EXPONENTIALSQUARED
+} D3DRMFOGMODE, *LPD3DRMFOGMODE;
+
+typedef enum _D3DRMZBUFFERMODE {
+    D3DRMZBUFFER_FROMPARENT,
+    D3DRMZBUFFER_ENABLE,
+    D3DRMZBUFFER_DISABLE
+} D3DRMZBUFFERMODE, *LPD3DRMZBUFFERMODE;
+
+typedef enum _D3DRMSORTMODE {
+    D3DRMSORT_FROMPARENT,
+    D3DRMSORT_NONE,
+    D3DRMSORT_FRONTTOBACK,
+    D3DRMSORT_BACKTOFRONT
+} D3DRMSORTMODE, *LPD3DRMSORTMODE;
+
+typedef struct _D3DRMMATERIALOVERRIDE {
+    DWORD         dwSize;
+    DWORD         dwFlags;
+    D3DCOLORVALUE dcDiffuse;
+    D3DCOLORVALUE dcAmbient;
+    D3DCOLORVALUE dcEmissive;
+    D3DCOLORVALUE dcSpecular;
+    D3DVALUE      dvPower;
+    LPUNKNOWN     lpD3DRMTex;
+} D3DRMMATERIALOVERRIDE, *LPD3DRMMATERIALOVERRIDE;
+
 typedef DWORD D3DRMLOADOPTIONS;
+
+#define D3DRMLOAD_FROMFILE             0x000L
+#define D3DRMLOAD_FROMRESOURCE         0x001L
+#define D3DRMLOAD_FROMMEMORY           0x002L
+#define D3DRMLOAD_FROMSTREAM           0x004L
+#define D3DRMLOAD_FROMURL              0x008L
+
+#define D3DRMLOAD_BYNAME               0x010L
+#define D3DRMLOAD_BYPOSITION           0x020L
+#define D3DRMLOAD_BYGUID               0x040L
+#define D3DRMLOAD_FIRST                0x080L
+
+#define D3DRMLOAD_INSTANCEBYREFERENCE  0x100L
+#define D3DRMLOAD_INSTANCEBYCOPYING    0x200L
+
+#define D3DRMLOAD_ASYNCHRONOUS         0x400L
+
+typedef struct _D3DRMLOADRESOURCE {
+    HMODULE hModule;
+    LPCSTR /*LPCTSTR*/ lpName;
+    LPCSTR /*LPCTSTR*/ lpType;
+} D3DRMLOADRESOURCE, *LPD3DRMLOADRESOURCE;
+
+typedef struct _D3DRMLOADMEMORY {
+    LPVOID lpMemory;
+    DWORD dSize;
+} D3DRMLOADMEMORY, *LPD3DRMLOADMEMORY;
+
+typedef struct _D3DRMPMESHLOADSTATUS {
+    DWORD dwSize;
+    DWORD dwPMeshSize;
+    DWORD dwBaseMeshSize;
+    DWORD dwBytesLoaded;
+    DWORD dwVerticesLoaded;
+    DWORD dwFacesLoaded;
+    HRESULT dwLoadResult;
+    DWORD dwFlags;
+} D3DRMPMESHLOADSTATUS, *LPD3DRMPMESHLOADSTATUS;
 
 typedef enum _D3DRMUSERVISUALREASON {
@@ -92,4 +229,16 @@
     D3DRMUSERVISUAL_RENDER
 } D3DRMUSERVISUALREASON, *LPD3DRMUSERVISUALREASON;
+
+typedef DWORD D3DRMMAPPING;
+
+typedef struct _D3DRMVERTEX {
+    D3DVECTOR position;
+    D3DVECTOR normal;
+    D3DVALUE  tu;
+    D3DVALUE  tv;
+    D3DCOLOR  color;
+} D3DRMVERTEX, *LPD3DRMVERTEX;
+
+typedef LONG D3DRMGROUPINDEX;
 
 void WINAPI D3DRMMatrixFromQuaternion(D3DRMMATRIX4D, LPD3DRMQUATERNION);
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3drmobj.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3drmobj.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3drmobj.h	(revision 28475)
@@ -1,4 +1,5 @@
 /*
  * Copyright (C) 2008 Vijay Kiran Kamuju
+ * Copyright (C) 2010 Christian Costa
  *
  * This library is free software; you can redistribute it and/or
@@ -43,22 +44,92 @@
 
 DEFINE_GUID(IID_IDirect3DRMObject,          0xeb16cb00, 0xd271, 0x11ce, 0xac, 0x48, 0x00, 0x00, 0xc0, 0x38, 0x25, 0xa1);
+DEFINE_GUID(IID_IDirect3DRMObject2,         0x4516ec7c, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x00, 0x00, 0xc0, 0x78, 0x1b, 0xc3);
+DEFINE_GUID(IID_IDirect3DRMDevice,          0xe9e19280, 0x6e05, 0x11cf, 0xac, 0x4a, 0x00, 0x00, 0xc0, 0x38, 0x25, 0xa1);
+DEFINE_GUID(IID_IDirect3DRMDevice2,         0x4516ec78, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x00, 0x00, 0xc0, 0x78, 0x1b, 0xc3);
+DEFINE_GUID(IID_IDirect3DRMDevice3,         0x549f498b, 0xbfeb, 0x11d1, 0x8e, 0xd8, 0x00, 0xa0, 0xc9, 0x67, 0xa4, 0x82);
+DEFINE_GUID(IID_IDirect3DRMViewport,        0xeb16cb02, 0xd271, 0x11ce, 0xac, 0x48, 0x00, 0x00, 0xc0, 0x38, 0x25, 0xa1);
+DEFINE_GUID(IID_IDirect3DRMViewport2,       0x4a1b1be6, 0xbfed, 0x11d1, 0x8e, 0xd8, 0x00, 0xa0, 0xc9, 0x67, 0xa4, 0x82);
+DEFINE_GUID(IID_IDirect3DRMFrame,           0xeb16cb03, 0xd271, 0x11ce, 0xac, 0x48, 0x00, 0x00, 0xc0, 0x38, 0x25, 0xa1);
+DEFINE_GUID(IID_IDirect3DRMFrame2,          0xc3dfbd60, 0x3988, 0x11d0, 0x9e, 0xc2, 0x00, 0x00, 0xc0, 0x29, 0x1a, 0xc3);
+DEFINE_GUID(IID_IDirect3DRMFrame3,          0xff6b7f70, 0xa40e, 0x11d1, 0x91, 0xf9, 0x00, 0x00, 0xf8, 0x75, 0x8e, 0x66);
 DEFINE_GUID(IID_IDirect3DRMVisual,          0xeb16cb04, 0xd271, 0x11ce, 0xac, 0x48, 0x00, 0x00, 0xc0, 0x38, 0x25, 0xa1);
+DEFINE_GUID(IID_IDirect3DRMMesh,            0xa3a80d01, 0x6e12, 0x11cf, 0xac, 0x4a, 0x00, 0x00, 0xc0, 0x38, 0x25, 0xa1);
+DEFINE_GUID(IID_IDirect3DRMMeshBuilder,     0xa3a80d02, 0x6e12, 0x11cf, 0xac, 0x4a, 0x00, 0x00, 0xc0, 0x38, 0x25, 0xa1);
+DEFINE_GUID(IID_IDirect3DRMMeshBuilder2,    0x4516ec77, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x00, 0x00, 0xc0, 0x78, 0x1b, 0xc3);
+DEFINE_GUID(IID_IDirect3DRMMeshBuilder3,    0x4516ec82, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x00, 0x00, 0xc0, 0x78, 0x1b, 0xc3);
+DEFINE_GUID(IID_IDirect3DRMFace,            0xeb16cb07, 0xd271, 0x11ce, 0xac, 0x48, 0x00, 0x00, 0xc0, 0x38, 0x25, 0xa1);
+DEFINE_GUID(IID_IDirect3DRMFace2,           0x4516ec81, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x00, 0x00, 0xc0, 0x78, 0x1b, 0xc3);
+DEFINE_GUID(IID_IDirect3DRMLight,           0xeb16cb08, 0xd271, 0x11ce, 0xac, 0x48, 0x00, 0x00, 0xc0, 0x38, 0x25, 0xa1);
+DEFINE_GUID(IID_IDirect3DRMTexture,         0xeb16cb09, 0xd271, 0x11ce, 0xac, 0x48, 0x00, 0x00, 0xc0, 0x38, 0x25, 0xa1);
+DEFINE_GUID(IID_IDirect3DRMTexture2,        0x120f30c0, 0x1629, 0x11d0, 0x94, 0x1c, 0x00, 0x80, 0xc8, 0x0c, 0xfa, 0x7b);
+DEFINE_GUID(IID_IDirect3DRMTexture3,        0xff6b7f73, 0xa40e, 0x11d1, 0x91, 0xf9, 0x00, 0x00, 0xf8, 0x75, 0x8e, 0x66);
+DEFINE_GUID(IID_IDirect3DRMWrap,            0xeb16cb0a, 0xd271, 0x11ce, 0xac, 0x48, 0x00, 0x00, 0xc0, 0x38, 0x25, 0xa1);
+DEFINE_GUID(IID_IDirect3DRMMaterial,        0xeb16cb0b, 0xd271, 0x11ce, 0xac, 0x48, 0x00, 0x00, 0xc0, 0x38, 0x25, 0xa1);
+DEFINE_GUID(IID_IDirect3DRMMaterial2,       0xff6b7f75, 0xa40e, 0x11d1, 0x91, 0xf9, 0x00, 0x00, 0xf8, 0x75, 0x8e, 0x66);
+DEFINE_GUID(IID_IDirect3DRMAnimation,       0xeb16cb0d, 0xd271, 0x11ce, 0xac, 0x48, 0x00, 0x00, 0xc0, 0x38, 0x25, 0xa1);
+DEFINE_GUID(IID_IDirect3DRMAnimation2,      0xff6b7f77, 0xa40e, 0x11d1, 0x91, 0xf9, 0x00, 0x00, 0xf8, 0x75, 0x8e, 0x66);
+DEFINE_GUID(IID_IDirect3DRMAnimationSet,    0xeb16cb0e, 0xd271, 0x11ce, 0xac, 0x48, 0x00, 0x00, 0xc0, 0x38, 0x25, 0xa1);
+DEFINE_GUID(IID_IDirect3DRMAnimationSet2,   0xff6b7f79, 0xa40e, 0x11d1, 0x91, 0xf9, 0x00, 0x00, 0xf8, 0x75, 0x8e, 0x66);
+DEFINE_GUID(IID_IDirect3DRMObjectArray,     0x242f6bc2, 0x3849, 0x11d0, 0x9b, 0x6d, 0x00, 0x00, 0xc0, 0x78, 0x1b, 0xc3);
+DEFINE_GUID(IID_IDirect3DRMDeviceArray,     0xeb16cb10, 0xd271, 0x11ce, 0xac, 0x48, 0x00, 0x00, 0xc0, 0x38, 0x25, 0xa1);
+DEFINE_GUID(IID_IDirect3DRMViewportArray,   0xeb16cb11, 0xd271, 0x11ce, 0xac, 0x48, 0x00, 0x00, 0xc0, 0x38, 0x25, 0xa1);
+DEFINE_GUID(IID_IDirect3DRMFrameArray,      0xeb16cb12, 0xd271, 0x11ce, 0xac, 0x48, 0x00, 0x00, 0xc0, 0x38, 0x25, 0xa1);
+DEFINE_GUID(IID_IDirect3DRMVisualArray,     0xeb16cb13, 0xd271, 0x11ce, 0xac, 0x48, 0x00, 0x00, 0xc0, 0x38, 0x25, 0xa1);
+DEFINE_GUID(IID_IDirect3DRMLightArray,      0xeb16cb14, 0xd271, 0x11ce, 0xac, 0x48, 0x00, 0x00, 0xc0, 0x38, 0x25, 0xa1);
+DEFINE_GUID(IID_IDirect3DRMPickedArray,     0xeb16cb16, 0xd271, 0x11ce, 0xac, 0x48, 0x00, 0x00, 0xc0, 0x38, 0x25, 0xa1);
+DEFINE_GUID(IID_IDirect3DRMFaceArray,       0xeb16cb17, 0xd271, 0x11ce, 0xac, 0x48, 0x00, 0x00, 0xc0, 0x38, 0x25, 0xa1);
+DEFINE_GUID(IID_IDirect3DRMAnimationArray,  0xd5f1cae0, 0x4bd7, 0x11d1, 0xb9, 0x74, 0x00, 0x60, 0x08, 0x3e, 0x45, 0xf3);
+DEFINE_GUID(IID_IDirect3DRMUserVisual,      0x59163de0, 0x6d43, 0x11cf, 0xac, 0x4a, 0x00, 0x00, 0xc0, 0x38, 0x25, 0xa1);
+DEFINE_GUID(IID_IDirect3DRMShadow,          0xaf359780, 0x6ba3, 0x11cf, 0xac, 0x4a, 0x00, 0x00, 0xc0, 0x38, 0x25, 0xa1);
+DEFINE_GUID(IID_IDirect3DRMShadow2,         0x86b44e25, 0x9c82, 0x11d1, 0xbb, 0x0b, 0x00, 0xa0, 0xc9, 0x81, 0xa0, 0xa6);
+DEFINE_GUID(IID_IDirect3DRMInterpolator,    0x242f6bc1, 0x3849, 0x11d0, 0x9b, 0x6d, 0x00, 0x00, 0xc0, 0x78, 0x1b, 0xc3);
+DEFINE_GUID(IID_IDirect3DRMProgressiveMesh, 0x4516ec79, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x00, 0x00, 0xc0, 0x78, 0x1b, 0xc3);
+DEFINE_GUID(IID_IDirect3DRMPicked2Array,    0x4516ec7b, 0x8f20, 0x11d0, 0x9b, 0x6d, 0x00, 0x00, 0xc0, 0x78, 0x1b, 0xc3);
+DEFINE_GUID(IID_IDirect3DRMClippedVisual,   0x5434e733, 0x6d66, 0x11d1, 0xbb, 0x0b, 0x00, 0x00, 0xf8, 0x75, 0x86, 0x5a);
 
 typedef struct IDirect3DRMObject          *LPDIRECT3DRMOBJECT, **LPLPDIRECT3DRMOBJECT;
+typedef struct IDirect3DRMObject2         *LPDIRECT3DRMOBJECT2, **LPLPDIRECT3DRMOBJECT2;
 typedef struct IDirect3DRMDevice          *LPDIRECT3DRMDEVICE, **LPLPDIRECT3DRMDEVICE;
+typedef struct IDirect3DRMDevice2         *LPDIRECT3DRMDEVICE2, **LPLPDIRECT3DRMDEVICE2;
+typedef struct IDirect3DRMDevice3         *LPDIRECT3DRMDEVICE3, **LPLPDIRECT3DRMDEVICE3;
 typedef struct IDirect3DRMViewport        *LPDIRECT3DRMVIEWPORT, **LPLPDIRECT3DRMVIEWPORT;
+typedef struct IDirect3DRMViewport2       *LPDIRECT3DRMVIEWPORT2, **LPLPDIRECT3DRMVIEWPORT2;
 typedef struct IDirect3DRMFrame           *LPDIRECT3DRMFRAME, **LPLPDIRECT3DRMFRAME;
+typedef struct IDirect3DRMFrame2          *LPDIRECT3DRMFRAME2, **LPLPDIRECT3DRMFRAME2;
+typedef struct IDirect3DRMFrame3          *LPDIRECT3DRMFRAME3, **LPLPDIRECT3DRMFRAME3;
 typedef struct IDirect3DRMVisual          *LPDIRECT3DRMVISUAL, **LPLPDIRECT3DRMVISUAL;
 typedef struct IDirect3DRMMesh            *LPDIRECT3DRMMESH, **LPLPDIRECT3DRMMESH;
 typedef struct IDirect3DRMMeshBuilder     *LPDIRECT3DRMMESHBUILDER, **LPLPDIRECT3DRMMESHBUILDER;
+typedef struct IDirect3DRMMeshBuilder2    *LPDIRECT3DRMMESHBUILDER2, **LPLPDIRECT3DRMMESHBUILDER2;
+typedef struct IDirect3DRMMeshBuilder3    *LPDIRECT3DRMMESHBUILDER3, **LPLPDIRECT3DRMMESHBUILDER3;
 typedef struct IDirect3DRMFace            *LPDIRECT3DRMFACE, **LPLPDIRECT3DRMFACE;
+typedef struct IDirect3DRMFace2           *LPDIRECT3DRMFACE2, **LPLPDIRECT3DRMFACE2;
 typedef struct IDirect3DRMLight           *LPDIRECT3DRMLIGHT, **LPLPDIRECT3DRMLIGHT;
 typedef struct IDirect3DRMTexture         *LPDIRECT3DRMTEXTURE, **LPLPDIRECT3DRMTEXTURE;
+typedef struct IDirect3DRMTexture2        *LPDIRECT3DRMTEXTURE2, **LPLPDIRECT3DRMTEXTURE2;
+typedef struct IDirect3DRMTexture3        *LPDIRECT3DRMTEXTURE3, **LPLPDIRECT3DRMTEXTURE3;
 typedef struct IDirect3DRMWrap            *LPDIRECT3DRMWRAP, **LPLPDIRECT3DRMWRAP;
 typedef struct IDirect3DRMMaterial        *LPDIRECT3DRMMATERIAL, **LPLPDIRECT3DRMMATERIAL;
+typedef struct IDirect3DRMMaterial2       *LPDIRECT3DRMMATERIAL2, **LPLPDIRECT3DRMMATERIAL2;
 typedef struct IDirect3DRMAnimation       *LPDIRECT3DRMANIMATION, **LPLPDIRECT3DRMANIMATION;
+typedef struct IDirect3DRMAnimation2      *LPDIRECT3DRMANIMATION2, **LPLPDIRECT3DRMANIMATION2;
 typedef struct IDirect3DRMAnimationSet    *LPDIRECT3DRMANIMATIONSET, **LPLPDIRECT3DRMANIMATIONSET;
+typedef struct IDirect3DRMAnimationSet2   *LPDIRECT3DRMANIMATIONSET2, **LPLPDIRECT3DRMANIMATIONSET2;
 typedef struct IDirect3DRMUserVisual      *LPDIRECT3DRMUSERVISUAL, **LPLPDIRECT3DRMUSERVISUAL;
+typedef struct IDirect3DRMShadow          *LPDIRECT3DRMSHADOW, **LPLPDIRECT3DRMSHADOW;
+typedef struct IDirect3DRMShadow2         *LPDIRECT3DRMSHADOW2, **LPLPDIRECT3DRMSHADOW2;
+typedef struct IDirect3DRMArray           *LPDIRECT3DRMARRAY, **LPLPDIRECT3DRMARRAY;
+typedef struct IDirect3DRMObjectArray     *LPDIRECT3DRMOBJECTARRAY, **LPLPDIRECT3DRMOBJECTARRAY;
 typedef struct IDirect3DRMDeviceArray     *LPDIRECT3DRMDEVICEARRAY, **LPLPDIRECT3DRMDEVICEARRAY;
+typedef struct IDirect3DRMFaceArray       *LPDIRECT3DRMFACEARRAY, **LPLPDIRECT3DRMFACEARRAY;
+typedef struct IDirect3DRMViewportArray   *LPDIRECT3DRMVIEWPORTARRAY, **LPLPDIRECT3DRMVIEWPORTARRAY;
+typedef struct IDirect3DRMFrameArray      *LPDIRECT3DRMFRAMEARRAY, **LPLPDIRECT3DRMFRAMEARRAY;
+typedef struct IDirect3DRMAnimationArray  *LPDIRECT3DRMANIMATIONARRAY, **LPLPDIRECT3DRMANIMATIONARRAY;
+typedef struct IDirect3DRMVisualArray     *LPDIRECT3DRMVISUALARRAY, **LPLPDIRECT3DRMVISUALARRAY;
+typedef struct IDirect3DRMPickedArray     *LPDIRECT3DRMPICKEDARRAY, **LPLPDIRECT3DRMPICKEDARRAY;
+typedef struct IDirect3DRMPicked2Array    *LPDIRECT3DRMPICKED2ARRAY, **LPLPDIRECT3DRMPICKED2ARRAY;
+typedef struct IDirect3DRMLightArray      *LPDIRECT3DRMLIGHTARRAY, **LPLPDIRECT3DRMLIGHTARRAY;
+typedef struct IDirect3DRMProgressiveMesh *LPDIRECT3DRMPROGRESSIVEMESH, **LPLPDIRECT3DRMPROGRESSIVEMESH;
+typedef struct IDirect3DRMClippedVisual   *LPDIRECT3DRMCLIPPEDVISUAL, **LPLPDIRECT3DRMCLIPPEDVISUAL;
 
 /* ********************************************************************
@@ -67,7 +138,11 @@
 
 typedef void (__cdecl *D3DRMOBJECTCALLBACK)(LPDIRECT3DRMOBJECT obj, LPVOID arg);
+typedef void (__cdecl *D3DRMFRAMEMOVECALLBACK)(LPDIRECT3DRMFRAME obj, LPVOID arg, D3DVALUE delta);
+typedef void (__cdecl *D3DRMFRAME3MOVECALLBACK)(LPDIRECT3DRMFRAME3 obj, LPVOID arg, D3DVALUE delta);
+typedef void (__cdecl *D3DRMUPDATECALLBACK)(LPDIRECT3DRMDEVICE obj, LPVOID arg, int, LPD3DRECT);
 typedef int (__cdecl *D3DRMUSERVISUALCALLBACK)(LPDIRECT3DRMUSERVISUAL obj, LPVOID arg,
     D3DRMUSERVISUALREASON reason, LPDIRECT3DRMDEVICE dev, LPDIRECT3DRMVIEWPORT view);
 typedef HRESULT (__cdecl *D3DRMLOADTEXTURECALLBACK)(char *tex_name, void *arg, LPDIRECT3DRMTEXTURE *);
+typedef HRESULT (__cdecl *D3DRMLOADTEXTURE3CALLBACK)(char *tex_name, void *arg, LPDIRECT3DRMTEXTURE3 *);
 typedef void (__cdecl *D3DRMLOADCALLBACK)(LPDIRECT3DRMOBJECT object, REFIID objectguid, LPVOID arg);
 
@@ -146,4 +221,62 @@
 
 /*****************************************************************************
+ * IDirect3DRMObject2 interface
+ */
+#ifdef WINE_NO_UNICODE_MACROS
+#undef GetClassName
+#endif
+#define INTERFACE IDirect3DRMObject2
+DECLARE_INTERFACE_(IDirect3DRMObject2,IUnknown)
+{
+    /*** IUnknown methods ***/
+    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
+    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+    STDMETHOD_(ULONG,Release)(THIS) PURE;
+    /*** IDirect3DRMObject2 methods ***/
+    STDMETHOD(AddDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK pFunc, LPVOID pArg) PURE;
+    STDMETHOD(Clone)(THIS_ LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj) PURE;
+    STDMETHOD(DeleteDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK pFunc, LPVOID pArg) PURE;
+    STDMETHOD(GetClientData)(THIS_ DWORD id, LPVOID* ppData) PURE;
+    STDMETHOD(GetDirect3DRM)(THIS_ LPDIRECT3DRM* ppDirect3DRM) PURE;
+    STDMETHOD(GetName)(THIS_ LPDWORD pSize, LPSTR pName) PURE;
+    STDMETHOD(SetClientData)(THIS_ DWORD id, LPVOID pData, DWORD flags) PURE;
+    STDMETHOD(SetName)(THIS_ LPCSTR pName) PURE;
+    STDMETHOD(GetAge)(THIS_ DWORD flags, LPDWORD pAge) PURE;
+};
+#undef INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IDirect3DRMObject2_QueryInterface(p,a,b)        (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DRMObject2_AddRef(p)                    (p)->lpVtbl->AddRef(p)
+#define IDirect3DRMObject2_Release(p)                   (p)->lpVtbl->Release(p)
+/*** IDirect3DRMObject2 methods ***/
+#define IDirect3DRMObject2_AddDestroyCallback(p,a,b)    (p)->lpVtbl->AddDestroyCallback(p,a,b)
+#define IDirect3DRMObject2_Clone(p,a,b,c)               (p)->lpVtbl->Clone(p,a,b,c)
+#define IDirect3DRMObject2_DeleteDestroyCallback(p,a,b) (p)->lpVtbl->DeleteDestroyCallback(p,a,b)
+#define IDirect3DRMObject2_GetClientData(p,a,b)         (p)->lpVtbl->SetClientData(p,a,b)
+#define IDirect3DRMObject2_GetDirect3DRM(p,a)           (p)->lpVtbl->GetDirect3DRM(p,a)
+#define IDirect3DRMObject2_GetName(p,a,b)               (p)->lpVtbl->GetName(p,a,b)
+#define IDirect3DRMObject2_SetClientData(p,a,b,c)       (p)->lpVtbl->SetClientData(p,a,b,c)
+#define IDirect3DRMObject2_SetName(p,a)                 (p)->lpVtbl->SetName(p,a)
+#define IDirect3DRMObject2_GetAge(p,a,b)                (p)->lpVtbl->GetAge(p,a,b)
+#else
+/*** IUnknown methods ***/
+#define IDirect3DRMObject2_QueryInterface(p,a,b)        (p)->QueryInterface(a,b)
+#define IDirect3DRMObject2_AddRef(p)                    (p)->AddRef()
+#define IDirect3DRMObject2_Release(p)                   (p)->Release()
+/*** IDirect3DRMObject2 methods ***/
+#define IDirect3DRMObject2_AddDestroyCallback(p,a,b)    (p)->AddDestroyCallback(a,b)
+#define IDirect3DRMObject2_Clone(p,a,b,c)               (p)->Clone(a,b,c)
+#define IDirect3DRMObject2_DeleteDestroyCallback(p,a,b) (p)->DeleteDestroyCallback(a,b)
+#define IDirect3DRMObject2_GetClientData(p,a,b)         (p)->SetClientData(a,b)
+#define IDirect3DRMObject2_GetDirect3DRM(p,a)           (p)->GetDirect3DRM(a)
+#define IDirect3DRMObject2_GetName(p,a,b)               (p)->GetName(a,b)
+#define IDirect3DRMObject2_SetClientData(p,a,b,c)       (p)->SetClientData(a,b,c)
+#define IDirect3DRMObject2_SetName(p,a)                 (p)->SetName(a)
+#define IDirect3DRMObject2_GetAge(p,a,b)                (p)->GetAge(a,b)
+#endif
+
+/*****************************************************************************
  * IDirect3DRMVisual interface
  */
@@ -197,4 +330,2710 @@
 #endif
 
+/*****************************************************************************
+ * IDirect3DRMDevice interface
+ */
+#ifdef WINE_NO_UNICODE_MACROS
+#undef GetClassName
+#endif
+#define INTERFACE IDirect3DRMDevice
+DECLARE_INTERFACE_(IDirect3DRMDevice,IUnknown)
+{
+    /*** IUnknown methods ***/
+    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
+    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+    STDMETHOD_(ULONG,Release)(THIS) PURE;
+    /*** IDirect3DRMObject methods ***/
+    STDMETHOD(Clone)(THIS_ LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj) PURE;
+    STDMETHOD(AddDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK pFunc, LPVOID pArg) PURE;
+    STDMETHOD(DeleteDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK pFunc, LPVOID pArg) PURE;
+    STDMETHOD(SetAppData)(THIS_ DWORD data) PURE;
+    STDMETHOD_(DWORD, GetAppData)(THIS) PURE;
+    STDMETHOD(SetName)(THIS_ LPCSTR) PURE;
+    STDMETHOD(GetName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE;
+    STDMETHOD(GetClassName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE;
+    /*** IDirect3DRMDevice methods ***/
+    STDMETHOD(Init)(THIS_ ULONG width, ULONG height) PURE;
+    STDMETHOD(InitFromD3D)(THIS_ LPDIRECT3D pD3D, LPDIRECT3DDEVICE pD3DDev) PURE;
+    STDMETHOD(InitFromClipper)(THIS_ LPDIRECTDRAWCLIPPER pDDClipper, LPGUID pGUID, int width, int height) PURE;
+    STDMETHOD(Update)(THIS) PURE;
+    STDMETHOD(AddUpdateCallback)(THIS_ D3DRMUPDATECALLBACK, LPVOID arg) PURE;
+    STDMETHOD(DeleteUpdateCallback)(THIS_ D3DRMUPDATECALLBACK, LPVOID arg) PURE;
+    STDMETHOD(SetBufferCount)(THIS_ DWORD) PURE;
+    STDMETHOD_(DWORD, GetBufferCount)(THIS) PURE;
+    STDMETHOD(SetDither)(THIS_ BOOL) PURE;
+    STDMETHOD(SetShades)(THIS_ DWORD) PURE;
+    STDMETHOD(SetQuality)(THIS_ D3DRMRENDERQUALITY) PURE;
+    STDMETHOD(SetTextureQuality)(THIS_ D3DRMTEXTUREQUALITY) PURE;
+    STDMETHOD(GetViewports)(THIS_ LPDIRECT3DRMVIEWPORTARRAY *return_views) PURE;
+    STDMETHOD_(BOOL, GetDither)(THIS) PURE;
+    STDMETHOD_(DWORD, GetShades)(THIS) PURE;
+    STDMETHOD_(DWORD, GetHeight)(THIS) PURE;
+    STDMETHOD_(DWORD, GetWidth)(THIS) PURE;
+    STDMETHOD_(DWORD, GetTrianglesDrawn)(THIS) PURE;
+    STDMETHOD_(DWORD, GetWireframeOptions)(THIS) PURE;
+    STDMETHOD_(D3DRMRENDERQUALITY, GetQuality)(THIS) PURE;
+    STDMETHOD_(D3DCOLORMODEL, GetColorModel)(THIS) PURE;
+    STDMETHOD_(D3DRMTEXTUREQUALITY, GetTextureQuality)(THIS) PURE;
+    STDMETHOD(GetDirect3DDevice)(THIS_ LPDIRECT3DDEVICE *) PURE;
+};
+#undef INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IDirect3DRMDevice_QueryInterface(p,a,b)        (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DRMDevice_AddRef(p)                    (p)->lpVtbl->AddRef(p)
+#define IDirect3DRMDevice_Release(p)                   (p)->lpVtbl->Release(p)
+/*** IDirect3DRMObject methods ***/
+#define IDirect3DRMDevice_Clone(p,a,b,c)               (p)->lpVtbl->Clone(p,a,b,c)
+#define IDirect3DRMDevice_AddDestroyCallback(p,a,b)    (p)->lpVtbl->AddDestroyCallback(p,a,b)
+#define IDirect3DRMDevice_DeleteDestroyCallback(p,a,b) (p)->lpVtbl->DeleteDestroyCallback(p,a,b)
+#define IDirect3DRMDevice_SetAppData(p,a)              (p)->lpVtbl->SetAppData(p,a)
+#define IDirect3DRMDevice_GetAppData(p)                (p)->lpVtbl->GetAppData(p)
+#define IDirect3DRMDevice_SetName(p,a)                 (p)->lpVtbl->SetName(p,a)
+#define IDirect3DRMDevice_GetName(p,a,b)               (p)->lpVtbl->GetName(p,a,b)
+#define IDirect3DRMDevice_GetClassName(p,a,b)          (p)->lpVtbl->GetClassName(p,a,b)
+/*** IDirect3DRMDevice methods ***/
+#define IDirect3DRMDevice_Init(p,a,b)                  (p)->lpVtbl->Init(p,a,b)
+#define IDirect3DRMDevice_InitFromD3D(p,a,b)           (p)->lpVtbl->InitFromD3D(p,a,b)
+#define IDirect3DRMDevice_InitFromClipper(p,a,b,c,d)   (p)->lpVtbl->InitFromClipper(p,a,b,c,d)
+#define IDirect3DRMDevice_Update(p)                    (p)->lpVtbl->Update(p)
+#define IDirect3DRMDevice_AddUpdateCallback(p,a,b)     (p)->lpVtbl->AddUpdateCallback(p,a,b)
+#define IDirect3DRMDevice_DeleteUpdateCallback(p,a,b)  (p)->lpVtbl->DeleteUpdateCallback(p,a,b,c)
+#define IDirect3DRMDevice_SetBufferCount(p,a)          (p)->lpVtbl->SetBufferCount(p,a)
+#define IDirect3DRMDevice_GetBufferCount(p)            (p)->lpVtbl->GetBufferCount(p)
+#define IDirect3DRMDevice_SetDither(p,a)               (p)->lpVtbl->SetDither(p,a)
+#define IDirect3DRMDevice_SetShades(p,a)               (p)->lpVtbl->SetShades(p,a)
+#define IDirect3DRMDevice_SetQuality(p,a)              (p)->lpVtbl->SetQuality(p,a)
+#define IDirect3DRMDevice_SetTextureQuality(p,a)       (p)->lpVtbl->SetTextureQuality(p,a)
+#define IDirect3DRMDevice_GetViewports(p,a)            (p)->lpVtbl->GetViewports(p,a)
+#define IDirect3DRMDevice_GetDither(p)                 (p)->lpVtbl->GetDither(p)
+#define IDirect3DRMDevice_GetShades(p)                 (p)->lpVtbl->GetShades(p)
+#define IDirect3DRMDevice_GetHeight(p)                 (p)->lpVtbl->GetHeight(p)
+#define IDirect3DRMDevice_GetWidth(p)                  (p)->lpVtbl->GetWidth(p)
+#define IDirect3DRMDevice_GetTrianglesDrawn(p)         (p)->lpVtbl->GetTrianglesDrawn(p)
+#define IDirect3DRMDevice_GetWireframeOptions(p)       (p)->lpVtbl->GetWireframeOptions(p)
+#define IDirect3DRMDevice_GetQuality(p)                (p)->lpVtbl->GetQuality(p)
+#define IDirect3DRMDevice_GetColorModel(p)             (p)->lpVtbl->GetColorModel(p)
+#define IDirect3DRMDevice_GetTextureQuality(p)         (p)->lpVtbl->GetTextureQuality(p)
+#define IDirect3DRMDevice_GetDirect3DDevice(p,a)       (p)->lpVtbl->GetDirect3DDevice(p,a)
+#else
+/*** IUnknown methods ***/
+#define IDirect3DRMDevice_QueryInterface(p,a,b)        (p)->QueryInterface(a,b)
+#define IDirect3DRMDevice_AddRef(p)                    (p)->AddRef()
+#define IDirect3DRMDevice_Release(p)                   (p)->Release()
+/*** IDirect3DRMObject methods ***/
+#define IDirect3DRMDevice_Clone(p,a,b,c)               (p)->Clone(a,b,c)
+#define IDirect3DRMDevice_AddDestroyCallback(p,a,b)    (p)->AddDestroyCallback(a,b)
+#define IDirect3DRMDevice_DeleteDestroyCallback(p,a,b) (p)->DeleteDestroyCallback(a,b)
+#define IDirect3DRMDevice_SetAppData(p,a)              (p)->SetAppData(a)
+#define IDirect3DRMDevice_GetAppData(p)                (p)->GetAppData()
+#define IDirect3DRMDevice_SetName(p,a)                 (p)->SetName(a)
+#define IDirect3DRMDevice_GetName(p,a,b)               (p)->GetName(a,b)
+#define IDirect3DRMDevice_GetClassName(p,a,b)          (p)->GetClassName(a,b)
+/*** IDirect3DRMDevice methods ***/
+#define IDirect3DRMDevice_Init(p,a,b)                  (p)->Init(p,a,b)
+#define IDirect3DRMDevice_InitFromD3D(p,a,b)           (p)->InitFromD3D(p,a,b)
+#define IDirect3DRMDevice_InitFromClipper(p,a,b,c,d)   (p)->InitFromClipper(p,a,b,c,d)
+#define IDirect3DRMDevice_Update(p)                    (p)->Update(p)
+#define IDirect3DRMDevice_AddUpdateCallback(p,a,b)     (p)->AddUpdateCallback(p,a,b)
+#define IDirect3DRMDevice_DeleteUpdateCallback(p,a,b)  (p)->DeleteUpdateCallback(p,a,b,c)
+#define IDirect3DRMDevice_SetBufferCount(p,a)          (p)->SetBufferCount(p,a)
+#define IDirect3DRMDevice_GetBufferCount(p)            (p)->GetBufferCount(p)
+#define IDirect3DRMDevice_SetDither(p,a)               (p)->SetDither(p,a)
+#define IDirect3DRMDevice_SetShades(p,a)               (p)->SetShades(p,a)
+#define IDirect3DRMDevice_SetQuality(p,a)              (p)->SetQuality(p,a)
+#define IDirect3DRMDevice_SetTextureQuality(p,a)       (p)->SetTextureQuality(p,a)
+#define IDirect3DRMDevice_GetViewports(p,a)            (p)->GetViewports(p,a)
+#define IDirect3DRMDevice_GetDither(p)                 (p)->GetDither(p)
+#define IDirect3DRMDevice_GetShades(p)                 (p)->GetShades(p)
+#define IDirect3DRMDevice_GetHeight(p)                 (p)->GetHeight(p)
+#define IDirect3DRMDevice_GetWidth(p)                  (p)->GetWidth(p)
+#define IDirect3DRMDevice_GetTrianglesDrawn(p)         (p)->GetTrianglesDrawn(p)
+#define IDirect3DRMDevice_GetWireframeOptions(p)       (p)->GetWireframeOptions(p)
+#define IDirect3DRMDevice_GetQuality(p)                (p)->GetQuality(p)
+#define IDirect3DRMDevice_GetColorModel(p)             (p)->GetColorModel(p)
+#define IDirect3DRMDevice_GetTextureQuality(p)         (p)->GetTextureQuality(p)
+#define IDirect3DRMDevice_GetDirect3DDevice(p,a)       (p)->GetDirect3DDevice(p,a)
+#endif
+
+/*****************************************************************************
+ * IDirect3DRMDevice2 interface
+ */
+#ifdef WINE_NO_UNICODE_MACROS
+#undef GetClassName
+#endif
+#define INTERFACE IDirect3DRMDevice2
+DECLARE_INTERFACE_(IDirect3DRMDevice2,IDirect3DRMDevice)
+{
+    /*** IUnknown methods ***/
+    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
+    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+    STDMETHOD_(ULONG,Release)(THIS) PURE;
+    /*** IDirect3DRMObject methods ***/
+    STDMETHOD(Clone)(THIS_ LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj) PURE;
+    STDMETHOD(AddDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK pFunc, LPVOID pArg) PURE;
+    STDMETHOD(DeleteDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK pFunc, LPVOID pArg) PURE;
+    STDMETHOD(SetAppData)(THIS_ DWORD data) PURE;
+    STDMETHOD_(DWORD, GetAppData)(THIS) PURE;
+    STDMETHOD(SetName)(THIS_ LPCSTR) PURE;
+    STDMETHOD(GetName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE;
+    STDMETHOD(GetClassName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE;
+    /*** IDirect3DRMDevice methods ***/
+    STDMETHOD(Init)(THIS_ ULONG width, ULONG height) PURE;
+    STDMETHOD(InitFromD3D)(THIS_ LPDIRECT3D pD3D, LPDIRECT3DDEVICE pD3DDev) PURE;
+    STDMETHOD(InitFromClipper)(THIS_ LPDIRECTDRAWCLIPPER pDDClipper, LPGUID pGUID, int width, int height) PURE;
+    STDMETHOD(Update)(THIS) PURE;
+    STDMETHOD(AddUpdateCallback)(THIS_ D3DRMUPDATECALLBACK, LPVOID arg) PURE;
+    STDMETHOD(DeleteUpdateCallback)(THIS_ D3DRMUPDATECALLBACK, LPVOID arg) PURE;
+    STDMETHOD(SetBufferCount)(THIS_ DWORD) PURE;
+    STDMETHOD_(DWORD, GetBufferCount)(THIS) PURE;
+    STDMETHOD(SetDither)(THIS_ BOOL) PURE;
+    STDMETHOD(SetShades)(THIS_ DWORD) PURE;
+    STDMETHOD(SetQuality)(THIS_ D3DRMRENDERQUALITY) PURE;
+    STDMETHOD(SetTextureQuality)(THIS_ D3DRMTEXTUREQUALITY) PURE;
+    STDMETHOD(GetViewports)(THIS_ LPDIRECT3DRMVIEWPORTARRAY *return_views) PURE;
+    STDMETHOD_(BOOL, GetDither)(THIS) PURE;
+    STDMETHOD_(DWORD, GetShades)(THIS) PURE;
+    STDMETHOD_(DWORD, GetHeight)(THIS) PURE;
+    STDMETHOD_(DWORD, GetWidth)(THIS) PURE;
+    STDMETHOD_(DWORD, GetTrianglesDrawn)(THIS) PURE;
+    STDMETHOD_(DWORD, GetWireframeOptions)(THIS) PURE;
+    STDMETHOD_(D3DRMRENDERQUALITY, GetQuality)(THIS) PURE;
+    STDMETHOD_(D3DCOLORMODEL, GetColorModel)(THIS) PURE;
+    STDMETHOD_(D3DRMTEXTUREQUALITY, GetTextureQuality)(THIS) PURE;
+    STDMETHOD(GetDirect3DDevice)(THIS_ LPDIRECT3DDEVICE *) PURE;
+    /*** IDirect3DRMDevice2 methods ***/
+    STDMETHOD(InitFromD3D2)(THIS_ LPDIRECT3D2 pD3D, LPDIRECT3DDEVICE2 pD3DDev) PURE;
+    STDMETHOD(InitFromSurface)(THIS_ LPGUID pGUID, LPDIRECTDRAW pDD, LPDIRECTDRAWSURFACE pDDSBack) PURE;
+    STDMETHOD(SetRenderMode)(THIS_ DWORD flags) PURE;
+    STDMETHOD_(DWORD, GetRenderMode)(THIS) PURE;
+    STDMETHOD(GetDirect3DDevice2)(THIS_ LPDIRECT3DDEVICE2 *) PURE;
+};
+#undef INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IDirect3DRMDevice2_QueryInterface(p,a,b)        (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DRMDevice2_AddRef(p)                    (p)->lpVtbl->AddRef(p)
+#define IDirect3DRMDevice2_Release(p)                   (p)->lpVtbl->Release(p)
+/*** IDirect3DRMObject methods ***/
+#define IDirect3DRMDevice2_Clone(p,a,b,c)               (p)->lpVtbl->Clone(p,a,b,c)
+#define IDirect3DRMDevice2_AddDestroyCallback(p,a,b)    (p)->lpVtbl->AddDestroyCallback(p,a,b)
+#define IDirect3DRMDevice2_DeleteDestroyCallback(p,a,b) (p)->lpVtbl->DeleteDestroyCallback(p,a,b)
+#define IDirect3DRMDevice2_SetAppData(p,a)              (p)->lpVtbl->SetAppData(p,a)
+#define IDirect3DRMDevice2_GetAppData(p)                (p)->lpVtbl->GetAppData(p)
+#define IDirect3DRMDevice2_SetName(p,a)                 (p)->lpVtbl->SetName(p,a)
+#define IDirect3DRMDevice2_GetName(p,a,b)               (p)->lpVtbl->GetName(p,a,b)
+#define IDirect3DRMDevice2_GetClassName(p,a,b)          (p)->lpVtbl->GetClassName(p,a,b)
+/*** IDirect3DRMDevice methods ***/
+#define IDirect3DRMDevice2_Init(p,a,b)                  (p)->lpVtbl->Init(p,a,b)
+#define IDirect3DRMDevice2_InitFromD3D(p,a,b)           (p)->lpVtbl->InitFromD3D(p,a,b)
+#define IDirect3DRMDevice2_InitFromClipper(p,a,b,c,d)   (p)->lpVtbl->InitFromClipper(p,a,b,c,d)
+#define IDirect3DRMDevice2_Update(p)                    (p)->lpVtbl->Update(p)
+#define IDirect3DRMDevice2_AddUpdateCallback(p,a,b)     (p)->lpVtbl->AddUpdateCallback(p,a,b)
+#define IDirect3DRMDevice2_DeleteUpdateCallback(p,a,b)  (p)->lpVtbl->DeleteUpdateCallback(p,a,b,c)
+#define IDirect3DRMDevice2_SetBufferCount(p,a)          (p)->lpVtbl->SetBufferCount(p,a)
+#define IDirect3DRMDevice2_GetBufferCount(p)            (p)->lpVtbl->GetBufferCount(p)
+#define IDirect3DRMDevice2_SetDither(p,a)               (p)->lpVtbl->SetDither(p,a)
+#define IDirect3DRMDevice2_SetShades(p,a)               (p)->lpVtbl->SetShades(p,a)
+#define IDirect3DRMDevice2_SetQuality(p,a)              (p)->lpVtbl->SetQuality(p,a)
+#define IDirect3DRMDevice2_SetTextureQuality(p,a)       (p)->lpVtbl->SetTextureQuality(p,a)
+#define IDirect3DRMDevice2_GetViewports(p,a)            (p)->lpVtbl->GetViewports(p,a)
+#define IDirect3DRMDevice2_GetDither(p)                 (p)->lpVtbl->GetDither(p)
+#define IDirect3DRMDevice2_GetShades(p)                 (p)->lpVtbl->GetShades(p)
+#define IDirect3DRMDevice2_GetHeight(p)                 (p)->lpVtbl->GetHeight(p)
+#define IDirect3DRMDevice2_GetWidth(p)                  (p)->lpVtbl->GetWidth(p)
+#define IDirect3DRMDevice2_GetTrianglesDrawn(p)         (p)->lpVtbl->GetTrianglesDrawn(p)
+#define IDirect3DRMDevice2_GetWireframeOptions(p)       (p)->lpVtbl->GetWireframeOptions(p)
+#define IDirect3DRMDevice2_GetQuality(p)                (p)->lpVtbl->GetQuality(p)
+#define IDirect3DRMDevice2_GetColorModel(p)             (p)->lpVtbl->GetColorModel(p)
+#define IDirect3DRMDevice2_GetTextureQuality(p)         (p)->lpVtbl->GetTextureQuality(p)
+#define IDirect3DRMDevice2_GetDirect3DDevice(p,a)       (p)->lpVtbl->GetDirect3DDevice(p,a)
+/*** IDirect3DRMDevice2 methods ***/
+#define IDirect3DRMDevice2_InitFromD3D2(p,a,b)          (p)->lpVtbl->InitFromD3D2(p,a,b)
+#define IDirect3DRMDevice2_InitFromSurface(p,a,b,c)     (p)->lpVtbl->InitFromSurface(p,a,b,c)
+#define IDirect3DRMDevice2_SetRenderMode(p,a)           (p)->lpVtbl->SetRenderMode(p,a)
+#define IDirect3DRMDevice2_GetRenderMode(p)             (p)->lpVtbl->GetRenderMode(p)
+#define IDirect3DRMDevice2_GetDirect3DDevice2(p,a)      (p)->lpVtbl->GetDirect3DDevice2(p,a)
+#else
+/*** IUnknown methods ***/
+#define IDirect3DRMDevice2_QueryInterface(p,a,b)        (p)->QueryInterface(a,b)
+#define IDirect3DRMDevice2_AddRef(p)                    (p)->AddRef()
+#define IDirect3DRMDevice2_Release(p)                   (p)->Release()
+/*** IDirect3DRMObject methods ***/
+#define IDirect3DRMDevice2_Clone(p,a,b,c)               (p)->Clone(a,b,c)
+#define IDirect3DRMDevice2_AddDestroyCallback(p,a,b)    (p)->AddDestroyCallback(a,b)
+#define IDirect3DRMDevice2_DeleteDestroyCallback(p,a,b) (p)->DeleteDestroyCallback(a,b)
+#define IDirect3DRMDevice2_SetAppData(p,a)              (p)->SetAppData(a)
+#define IDirect3DRMDevice2_GetAppData(p)                (p)->GetAppData()
+#define IDirect3DRMDevice2_SetName(p,a)                 (p)->SetName(a)
+#define IDirect3DRMDevice2_GetName(p,a,b)               (p)->GetName(a,b)
+#define IDirect3DRMDevice2_GetClassName(p,a,b)          (p)->GetClassName(a,b)
+/*** IDirect3DRMDevice methods ***/
+#define IDirect3DRMDevice2_Init(p,a,b)                  (p)->Init(p,a,b)
+#define IDirect3DRMDevice2_InitFromD3D(p,a,b)           (p)->InitFromD3D(p,a,b)
+#define IDirect3DRMDevice2_InitFromClipper(p,a,b,c,d)   (p)->InitFromClipper(p,a,b,c,d)
+#define IDirect3DRMDevice2_Update(p)                    (p)->Update(p)
+#define IDirect3DRMDevice2_AddUpdateCallback(p,a,b)     (p)->AddUpdateCallback(p,a,b)
+#define IDirect3DRMDevice2_DeleteUpdateCallback(p,a,b)  (p)->DeleteUpdateCallback(p,a,b,c)
+#define IDirect3DRMDevice2_SetBufferCount(p,a)          (p)->SetBufferCount(p,a)
+#define IDirect3DRMDevice2_GetBufferCount(p)            (p)->GetBufferCount(p)
+#define IDirect3DRMDevice2_SetDither(p,a)               (p)->SetDither(p,a)
+#define IDirect3DRMDevice2_SetShades(p,a)               (p)->SetShades(p,a)
+#define IDirect3DRMDevice2_SetQuality(p,a)              (p)->SetQuality(p,a)
+#define IDirect3DRMDevice2_SetTextureQuality(p,a)       (p)->SetTextureQuality(p,a)
+#define IDirect3DRMDevice2_GetViewports(p,a)            (p)->GetViewports(p,a)
+#define IDirect3DRMDevice2_GetDither(p)                 (p)->GetDither(p)
+#define IDirect3DRMDevice2_GetShades(p)                 (p)->GetShades(p)
+#define IDirect3DRMDevice2_GetHeight(p)                 (p)->GetHeight(p)
+#define IDirect3DRMDevice2_GetWidth(p)                  (p)->GetWidth(p)
+#define IDirect3DRMDevice2_GetTrianglesDrawn(p)         (p)->GetTrianglesDrawn(p)
+#define IDirect3DRMDevice2_GetWireframeOptions(p)       (p)->GetWireframeOptions(p)
+#define IDirect3DRMDevice2_GetQuality(p)                (p)->GetQuality(p)
+#define IDirect3DRMDevice2_GetColorModel(p)             (p)->GetColorModel(p)
+#define IDirect3DRMDevice2_GetTextureQuality(p)         (p)->GetTextureQuality(p)
+#define IDirect3DRMDevice2_GetDirect3DDevice(p,a)       (p)->GetDirect3DDevice(p,a)
+/*** IDirect3DRMDevice2 methods ***/
+#define IDirect3DRMDevice2_InitFromD3D2(p,a,b)          (p)->InitFromD3D2(a,b)
+#define IDirect3DRMDevice2_InitFromSurface(p,a,b,c)     (p)->InitFromSurface(a,b,c)
+#define IDirect3DRMDevice2_SetRenderMode(p,a)           (p)->SetRenderMode(a)
+#define IDirect3DRMDevice2_GetRenderMode(p)             (p)->GetRenderMode()
+#define IDirect3DRMDevice2_GetDirect3DDevice2(p,a)      (p)->GetDirect3DDevice2(a)
+#endif
+
+/*****************************************************************************
+ * IDirect3DRMDevice3 interface
+ */
+#ifdef WINE_NO_UNICODE_MACROS
+#undef GetClassName
+#endif
+#define INTERFACE IDirect3DRMDevice3
+DECLARE_INTERFACE_(IDirect3DRMDevice3,IDirect3DRMObject)
+{
+    /*** IUnknown methods ***/
+    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
+    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+    STDMETHOD_(ULONG,Release)(THIS) PURE;
+    /*** IDirect3DRMObject methods ***/
+    STDMETHOD(Clone)(THIS_ LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj) PURE;
+    STDMETHOD(AddDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK pFunc, LPVOID pArg) PURE;
+    STDMETHOD(DeleteDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK pFunc, LPVOID pArg) PURE;
+    STDMETHOD(SetAppData)(THIS_ DWORD data) PURE;
+    STDMETHOD_(DWORD, GetAppData)(THIS) PURE;
+    STDMETHOD(SetName)(THIS_ LPCSTR) PURE;
+    STDMETHOD(GetName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE;
+    STDMETHOD(GetClassName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE;
+    /*** IDirect3DRMDevice methods ***/
+    STDMETHOD(Init)(THIS_ ULONG width, ULONG height) PURE;
+    STDMETHOD(InitFromD3D)(THIS_ LPDIRECT3D pD3D, LPDIRECT3DDEVICE pD3DDev) PURE;
+    STDMETHOD(InitFromClipper)(THIS_ LPDIRECTDRAWCLIPPER pDDClipper, LPGUID pGUID, int width, int height) PURE;
+    STDMETHOD(Update)(THIS) PURE;
+    STDMETHOD(AddUpdateCallback)(THIS_ D3DRMUPDATECALLBACK, LPVOID arg) PURE;
+    STDMETHOD(DeleteUpdateCallback)(THIS_ D3DRMUPDATECALLBACK, LPVOID arg) PURE;
+    STDMETHOD(SetBufferCount)(THIS_ DWORD) PURE;
+    STDMETHOD_(DWORD, GetBufferCount)(THIS) PURE;
+    STDMETHOD(SetDither)(THIS_ BOOL) PURE;
+    STDMETHOD(SetShades)(THIS_ DWORD) PURE;
+    STDMETHOD(SetQuality)(THIS_ D3DRMRENDERQUALITY) PURE;
+    STDMETHOD(SetTextureQuality)(THIS_ D3DRMTEXTUREQUALITY) PURE;
+    STDMETHOD(GetViewports)(THIS_ LPDIRECT3DRMVIEWPORTARRAY *return_views) PURE;
+    STDMETHOD_(BOOL, GetDither)(THIS) PURE;
+    STDMETHOD_(DWORD, GetShades)(THIS) PURE;
+    STDMETHOD_(DWORD, GetHeight)(THIS) PURE;
+    STDMETHOD_(DWORD, GetWidth)(THIS) PURE;
+    STDMETHOD_(DWORD, GetTrianglesDrawn)(THIS) PURE;
+    STDMETHOD_(DWORD, GetWireframeOptions)(THIS) PURE;
+    STDMETHOD_(D3DRMRENDERQUALITY, GetQuality)(THIS) PURE;
+    STDMETHOD_(D3DCOLORMODEL, GetColorModel)(THIS) PURE;
+    STDMETHOD_(D3DRMTEXTUREQUALITY, GetTextureQuality)(THIS) PURE;
+    STDMETHOD(GetDirect3DDevice)(THIS_ LPDIRECT3DDEVICE *) PURE;
+    /*** IDirect3DRMDevice2 methods ***/
+    STDMETHOD(InitFromD3D2)(THIS_ LPDIRECT3D2 pD3D, LPDIRECT3DDEVICE2 pD3DDev) PURE;
+    STDMETHOD(InitFromSurface)(THIS_ LPGUID pGUID, LPDIRECTDRAW pDD, LPDIRECTDRAWSURFACE pDDSBack) PURE;
+    STDMETHOD(SetRenderMode)(THIS_ DWORD flags) PURE;
+    STDMETHOD_(DWORD, GetRenderMode)(THIS) PURE;
+    STDMETHOD(GetDirect3DDevice2)(THIS_ LPDIRECT3DDEVICE2 *) PURE;
+    /*** IDirect3DRMDevice3 methods ***/
+    STDMETHOD(FindPreferredTextureFormat)(THIS_ DWORD BitDepths, DWORD flags, LPDDPIXELFORMAT pDDPF) PURE;
+    STDMETHOD(RenderStateChange)(THIS_ D3DRENDERSTATETYPE drsType, DWORD val, DWORD flags) PURE;
+    STDMETHOD(LightStateChange)(THIS_ D3DLIGHTSTATETYPE drsType, DWORD val, DWORD flags) PURE;
+    STDMETHOD(GetStateChangeOptions)(THIS_ DWORD StateClass, DWORD StateNum, LPDWORD pFlags) PURE;
+    STDMETHOD(SetStateChangeOptions)(THIS_ DWORD StateClass, DWORD StateNum, DWORD flags) PURE;
+};
+#undef INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IDirect3DRMDevice3_QueryInterface(p,a,b)               (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DRMDevice3_AddRef(p)                           (p)->lpVtbl->AddRef(p)
+#define IDirect3DRMDevice3_Release(p)                          (p)->lpVtbl->Release(p)
+/*** IDirect3DRMObject methods ***/
+#define IDirect3DRMDevice3_Clone(p,a,b,c)                      (p)->lpVtbl->Clone(p,a,b,c)
+#define IDirect3DRMDevice3_AddDestroyCallback(p,a,b)           (p)->lpVtbl->AddDestroyCallback(p,a,b)
+#define IDirect3DRMDevice3_DeleteDestroyCallback(p,a,b)        (p)->lpVtbl->DeleteDestroyCallback(p,a,b)
+#define IDirect3DRMDevice3_SetAppData(p,a)                     (p)->lpVtbl->SetAppData(p,a)
+#define IDirect3DRMDevice3_GetAppData(p)                       (p)->lpVtbl->GetAppData(p)
+#define IDirect3DRMDevice3_SetName(p,a)                        (p)->lpVtbl->SetName(p,a)
+#define IDirect3DRMDevice3_GetName(p,a,b)                      (p)->lpVtbl->GetName(p,a,b)
+#define IDirect3DRMDevice3_GetClassName(p,a,b)                 (p)->lpVtbl->GetClassName(p,a,b)
+/*** IDirect3DRMDevice methods ***/
+#define IDirect3DRMDevice3_Init(p,a,b)                         (p)->lpVtbl->Init(p,a,b)
+#define IDirect3DRMDevice3_InitFromD3D(p,a,b)                  (p)->lpVtbl->InitFromD3D(p,a,b)
+#define IDirect3DRMDevice3_InitFromClipper(p,a,b,c,d)          (p)->lpVtbl->InitFromClipper(p,a,b,c,d)
+#define IDirect3DRMDevice3_Update(p)                           (p)->lpVtbl->Update(p)
+#define IDirect3DRMDevice3_AddUpdateCallback(p,a,b)            (p)->lpVtbl->AddUpdateCallback(p,a,b)
+#define IDirect3DRMDevice3_DeleteUpdateCallback(p,a,b)         (p)->lpVtbl->DeleteUpdateCallback(p,a,b,c)
+#define IDirect3DRMDevice3_SetBufferCount(p,a)                 (p)->lpVtbl->SetBufferCount(p,a)
+#define IDirect3DRMDevice3_GetBufferCount(p)                   (p)->lpVtbl->GetBufferCount(p)
+#define IDirect3DRMDevice3_SetDither(p,a)                      (p)->lpVtbl->SetDither(p,a)
+#define IDirect3DRMDevice3_SetShades(p,a)                      (p)->lpVtbl->SetShades(p,a)
+#define IDirect3DRMDevice3_SetQuality(p,a)                     (p)->lpVtbl->SetQuality(p,a)
+#define IDirect3DRMDevice3_SetTextureQuality(p,a)              (p)->lpVtbl->SetTextureQuality(p,a)
+#define IDirect3DRMDevice3_GetViewports(p,a)                   (p)->lpVtbl->GetViewports(p,a)
+#define IDirect3DRMDevice3_GetDither(p)                        (p)->lpVtbl->GetDither(p)
+#define IDirect3DRMDevice3_GetShades(p)                        (p)->lpVtbl->GetShades(p)
+#define IDirect3DRMDevice3_GetHeight(p)                        (p)->lpVtbl->GetHeight(p)
+#define IDirect3DRMDevice3_GetWidth(p)                         (p)->lpVtbl->GetWidth(p)
+#define IDirect3DRMDevice3_GetTrianglesDrawn(p)                (p)->lpVtbl->GetTrianglesDrawn(p)
+#define IDirect3DRMDevice3_GetWireframeOptions(p)              (p)->lpVtbl->GetWireframeOptions(p)
+#define IDirect3DRMDevice3_GetQuality(p)                       (p)->lpVtbl->GetQuality(p)
+#define IDirect3DRMDevice3_GetColorModel(p)                    (p)->lpVtbl->GetColorModel(p)
+#define IDirect3DRMDevice3_GetTextureQuality(p)                (p)->lpVtbl->GetTextureQuality(p)
+#define IDirect3DRMDevice3_GetDirect3DDevice(p,a)              (p)->lpVtbl->GetDirect3DDevice(p,a)
+/*** IDirect3DRMDevice2 methods ***/
+#define IDirect3DRMDevice3_InitFromD3D2(p,a,b)                 (p)->lpVtbl->InitFromD3D2(p,a,b)
+#define IDirect3DRMDevice3_InitFromSurface(p,a,b,c)            (p)->lpVtbl->InitFromSurface(p,a,b,c)
+#define IDirect3DRMDevice3_SetRenderMode(p,a)                  (p)->lpVtbl->SetRenderMode(p,a)
+#define IDirect3DRMDevice3_GetRenderMode(p)                    (p)->lpVtbl->GetRenderMode(p)
+#define IDirect3DRMDevice3_GetDirect3DDevice2(p,a)             (p)->lpVtbl->GetDirect3DDevice2(p,a)
+/*** IDirect3DRMDevice3 methods ***/
+#define IDirect3DRMDevice3_FindPreferredTextureFormat(p,a,b,c) (p)->lpVtbl->FindPreferredTextureFormat(p,a,b)
+#define IDirect3DRMDevice3_RenderStateChange(p,a,b,c)          (p)->lpVtbl->RenderStateChange(p,a,b)
+#define IDirect3DRMDevice3_LightStateChange(p,a,b,c)           (p)->lpVtbl->LightStateChange(p,a,b)
+#define IDirect3DRMDevice3_GetStateChangeOptions(p,a,b,c)      (p)->lpVtbl->GetStateChangeOptions(p,a,b)
+#define IDirect3DRMDevice3_SetStateChangeOptions(p,a,b,c)      (p)->lpVtbl->SetStateChangeOptions(p,a,b)
+#else
+/*** IUnknown methods ***/
+#define IDirect3DRMDevice3_QueryInterface(p,a,b)               (p)->QueryInterface(a,b)
+#define IDirect3DRMDevice3_AddRef(p)                           (p)->AddRef()
+#define IDirect3DRMDevice3_Release(p)                          (p)->Release()
+/*** IDirect3DRMObject methods ***/
+#define IDirect3DRMDevice3_Clone(p,a,b,c)                      (p)->Clone(a,b,c)
+#define IDirect3DRMDevice3_AddDestroyCallback(p,a,b)           (p)->AddDestroyCallback(a,b)
+#define IDirect3DRMDevice3_DeleteDestroyCallback(p,a,b)        (p)->DeleteDestroyCallback(a,b)
+#define IDirect3DRMDevice3_SetAppData(p,a)                     (p)->SetAppData(a)
+#define IDirect3DRMDevice3_GetAppData(p)                       (p)->GetAppData()
+#define IDirect3DRMDevice3_SetName(p,a)                        (p)->SetName(a)
+#define IDirect3DRMDevice3_GetName(p,a,b)                      (p)->GetName(a,b)
+#define IDirect3DRMDevice3_GetClassName(p,a,b)                 (p)->GetClassName(a,b)
+/*** IDirect3DRMDevice methods ***/
+#define IDirect3DRMDevice3_Init(p,a,b)                         (p)->Init(p,a,b)
+#define IDirect3DRMDevice3_InitFromD3D(p,a,b)                  (p)->InitFromD3D(p,a,b)
+#define IDirect3DRMDevice3_InitFromClipper(p,a,b,c,d)          (p)->InitFromClipper(p,a,b,c,d)
+#define IDirect3DRMDevice3_Update(p)                           (p)->Update(p)
+#define IDirect3DRMDevice3_AddUpdateCallback(p,a,b)            (p)->AddUpdateCallback(p,a,b)
+#define IDirect3DRMDevice3_DeleteUpdateCallback(p,a,b)         (p)->DeleteUpdateCallback(p,a,b,c)
+#define IDirect3DRMDevice3_SetBufferCount(p,a)                 (p)->SetBufferCount(p,a)
+#define IDirect3DRMDevice3_GetBufferCount(p)                   (p)->GetBufferCount(p)
+#define IDirect3DRMDevice3_SetDither(p,a)                      (p)->SetDither(p,a)
+#define IDirect3DRMDevice3_SetShades(p,a)                      (p)->SetShades(p,a)
+#define IDirect3DRMDevice3_SetQuality(p,a)                     (p)->SetQuality(p,a)
+#define IDirect3DRMDevice3_SetTextureQuality(p,a)              (p)->SetTextureQuality(p,a)
+#define IDirect3DRMDevice3_GetViewports(p,a)                   (p)->GetViewports(p,a)
+#define IDirect3DRMDevice3_GetDither(p)                        (p)->GetDither(p)
+#define IDirect3DRMDevice3_GetShades(p)                        (p)->GetShades(p)
+#define IDirect3DRMDevice3_GetHeight(p)                        (p)->GetHeight(p)
+#define IDirect3DRMDevice3_GetWidth(p)                         (p)->GetWidth(p)
+#define IDirect3DRMDevice3_GetTrianglesDrawn(p)                (p)->GetTrianglesDrawn(p)
+#define IDirect3DRMDevice3_GetWireframeOptions(p)              (p)->GetWireframeOptions(p)
+#define IDirect3DRMDevice3_GetQuality(p)                       (p)->GetQuality(p)
+#define IDirect3DRMDevice3_GetColorModel(p)                    (p)->GetColorModel(p)
+#define IDirect3DRMDevice3_GetTextureQuality(p)                (p)->GetTextureQuality(p)
+#define IDirect3DRMDevice3_GetDirect3DDevice(p,a)              (p)->GetDirect3DDevice(p,a)
+/*** IDirect3DRMDevice2 methods ***/
+#define IDirect3DRMDevice3_InitFromD3D2(p,a,b)                 (p)->InitFromD3D2(a,b)
+#define IDirect3DRMDevice3_InitFromSurface(p,a,b,c)            (p)->InitFromSurface(a,b,c)
+#define IDirect3DRMDevice3_SetRenderMode(p,a)                  (p)->SetRenderMode(a)
+#define IDirect3DRMDevice3_GetRenderMode(p)                    (p)->GetRenderMode()
+#define IDirect3DRMDevice3_GetDirect3DDevice2(p,a)             (p)->GetDirect3DDevice2(a)
+/*** IDirect3DRMDevice3 methods ***/
+#define IDirect3DRMDevice3_FindPreferredTextureFormat(p,a,b,c) (p)->FindPreferredTextureFormat(a,b,c)
+#define IDirect3DRMDevice3_RenderStateChange(p,a,b,c)          (p)->RenderStateChange(a,b,c)
+#define IDirect3DRMDevice3_LightStateChange(p,a,b,c)           (p)->LightStateChange(a,b,c)
+#define IDirect3DRMDevice3_GetStateChangeOptions(p,a,b,c)      (p)->GetStateChangeOptions(a,b,c)
+#define IDirect3DRMDevice3_SetStateChangeOptions(p,a,b,c)      (p)->SetStateChangeOptions(a,b,c)
+#endif
+
+/*****************************************************************************
+ * IDirect3DRMViewport interface
+ */
+#define INTERFACE IDirect3DRMViewport
+DECLARE_INTERFACE_(IDirect3DRMViewport,IDirect3DRMObject)
+{
+    /*** IUnknown methods ***/
+    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
+    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+    STDMETHOD_(ULONG,Release)(THIS) PURE;
+    /*** IDirect3DRMObject methods ***/
+    STDMETHOD(Clone)(THIS_ LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj) PURE;
+    STDMETHOD(AddDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK, LPVOID argument) PURE;
+    STDMETHOD(DeleteDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK, LPVOID argument) PURE;
+    STDMETHOD(SetAppData)(THIS_ DWORD data) PURE;
+    STDMETHOD_(DWORD, GetAppData)(THIS) PURE;
+    STDMETHOD(SetName)(THIS_ LPCSTR) PURE;
+    STDMETHOD(GetName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE;
+    STDMETHOD(GetClassName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE;
+    /*** IDirect3DRMViewport methods ***/
+    STDMETHOD(Init) (THIS_ LPDIRECT3DRMDEVICE dev, LPDIRECT3DRMFRAME camera, DWORD xpos, DWORD ypos,
+        DWORD width, DWORD height) PURE;
+    STDMETHOD(Clear)(THIS) PURE;
+    STDMETHOD(Render)(THIS_ LPDIRECT3DRMFRAME) PURE;
+    STDMETHOD(SetFront)(THIS_ D3DVALUE) PURE;
+    STDMETHOD(SetBack)(THIS_ D3DVALUE) PURE;
+    STDMETHOD(SetField)(THIS_ D3DVALUE) PURE;
+    STDMETHOD(SetUniformScaling)(THIS_ BOOL) PURE;
+    STDMETHOD(SetCamera)(THIS_ LPDIRECT3DRMFRAME) PURE;
+    STDMETHOD(SetProjection)(THIS_ D3DRMPROJECTIONTYPE) PURE;
+    STDMETHOD(Transform)(THIS_ D3DRMVECTOR4D *d, D3DVECTOR *s) PURE;
+    STDMETHOD(InverseTransform)(THIS_ D3DVECTOR *d, D3DRMVECTOR4D *s) PURE;
+    STDMETHOD(Configure)(THIS_ LONG x, LONG y, DWORD width, DWORD height) PURE;
+    STDMETHOD(ForceUpdate)(THIS_ DWORD x1, DWORD y1, DWORD x2, DWORD y2) PURE;
+    STDMETHOD(SetPlane)(THIS_ D3DVALUE left, D3DVALUE right, D3DVALUE bottom, D3DVALUE top) PURE;
+    STDMETHOD(GetCamera)(THIS_ LPDIRECT3DRMFRAME *) PURE;
+    STDMETHOD(GetDevice)(THIS_ LPDIRECT3DRMDEVICE *) PURE;
+    STDMETHOD(GetPlane)(THIS_ D3DVALUE *left, D3DVALUE *right, D3DVALUE *bottom, D3DVALUE *top) PURE;
+    STDMETHOD(Pick)(THIS_ LONG x, LONG y, LPDIRECT3DRMPICKEDARRAY *return_visuals) PURE;
+    STDMETHOD_(BOOL, GetUniformScaling)(THIS) PURE;
+    STDMETHOD_(LONG, GetX)(THIS) PURE;
+    STDMETHOD_(LONG, GetY)(THIS) PURE;
+    STDMETHOD_(DWORD, GetWidth)(THIS) PURE;
+    STDMETHOD_(DWORD, GetHeight)(THIS) PURE;
+    STDMETHOD_(D3DVALUE, GetField)(THIS) PURE;
+    STDMETHOD_(D3DVALUE, GetBack)(THIS) PURE;
+    STDMETHOD_(D3DVALUE, GetFront)(THIS) PURE;
+    STDMETHOD_(D3DRMPROJECTIONTYPE, GetProjection)(THIS) PURE;
+    STDMETHOD(GetDirect3DViewport)(THIS_ LPDIRECT3DVIEWPORT *) PURE;
+};
+#undef INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IDirect3DRMViewport_QueryInterface(p,a,b)        (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DRMViewport_AddRef(p)                    (p)->lpVtbl->AddRef(p)
+#define IDirect3DRMViewport_Release(p)                   (p)->lpVtbl->Release(p)
+/*** IDirect3DRMObject methods ***/
+#define IDirect3DRMViewport_Clone(p,a,b,c)               (p)->lpVtbl->Clone(p,a,b,c)
+#define IDirect3DRMViewport_AddDestroyCallback(p,a,b)    (p)->lpVtbl->AddDestroyCallback(p,a,b)
+#define IDirect3DRMViewport_DeleteDestroyCallback(p,a,b) (p)->lpVtbl->DeleteDestroyCallback(p,a,b)
+#define IDirect3DRMViewport_SetAppData(p,a)              (p)->lpVtbl->SetAppData(p,a)
+#define IDirect3DRMViewport_GetAppData(p)                (p)->lpVtbl->GetAppData(p)
+#define IDirect3DRMViewport_SetName(p,a)                 (p)->lpVtbl->SetName(p,a)
+#define IDirect3DRMViewport_GetName(p,a,b)               (p)->lpVtbl->GetName(p,a,b)
+#define IDirect3DRMViewport_GetClassName(p,a,b)          (p)->lpVtbl->GetClassName(p,a,b)
+/*** IDirect3DRMViewport methods ***/
+#define IDirect3DRMViewport_Init(p,a,b,c,d)              (p)->lpVtbl->Init(p,a,b,c,d)
+#define IDirect3DRMViewport_Clear(p)                     (p)->lpVtbl->Clear(p)
+#define IDirect3DRMViewport_Render(p,a)                  (p)->lpVtbl->Render(p,a)
+#define IDirect3DRMViewport_SetFront(p,a)                (p)->lpVtbl->SetFront(p,a)
+#define IDirect3DRMViewport_SetBack(p,a)                 (p)->lpVtbl->(p,a)
+#define IDirect3DRMViewport_SetField(p,a)                (p)->lpVtbl->(p,a)
+#define IDirect3DRMViewport_SetUniformScaling(p,a)       (p)->lpVtbl->SetUniformScaling(p,a)
+#define IDirect3DRMViewport_SetCamera(p,a)               (p)->lpVtbl->SetCamera(p,a)
+#define IDirect3DRMViewport_SetProjection(p,a)           (p)->lpVtbl->SetProjection(p,a)
+#define IDirect3DRMViewport_Transform(p,a,b)             (p)->lpVtbl->Transform(p,a,b)
+#define IDirect3DRMViewport_InverseTransform(p,a,b)      (p)->lpVtbl->(p,a,b)
+#define IDirect3DRMViewport_Configure(p,a,b,c,d)         (p)->lpVtbl->Configure(p,a,b,c,d)
+#define IDirect3DRMViewport_ForceUpdate(p,a,b,c,d)       (p)->lpVtbl->ForceUpdate(p,a,b,c,d)
+#define IDirect3DRMViewport_SetPlane(p,a,b,c,d)          (p)->lpVtbl->SetPlane(p,a,b,c,d)
+#define IDirect3DRMViewport_GetCamera(p,a)               (p)->lpVtbl->(p,a)
+#define IDirect3DRMViewport_GetDevice(p,a)               (p)->lpVtbl->GetDevice(p,a)
+#define IDirect3DRMViewport_GetPlane(p,a,b,c,d)          (p)->lpVtbl->GetPlane(p,a,b,c,d)
+#define IDirect3DRMViewport_Pick(p,a,b,c)                (p)->lpVtbl->Pick(p,a,b,c)
+#define IDirect3DRMViewport_GetUniformScaling(p)         (p)->lpVtbl->GetUniformScaling(p)
+#define IDirect3DRMViewport_GetX(p)                      (p)->lpVtbl->GetX(p)
+#define IDirect3DRMViewport_GetY(p)                      (p)->lpVtbl->GetY(p)
+#define IDirect3DRMViewport_GetWidth(p)                  (p)->lpVtbl->GetWidth(p)
+#define IDirect3DRMViewport_GetHeight(p)                 (p)->lpVtbl->GetHeight(p)
+#define IDirect3DRMViewport_GetField(p)                  (p)->lpVtbl->GetField(p)
+#define IDirect3DRMViewport_GetBack(p)                   (p)->lpVtbl->GetBack(p)
+#define IDirect3DRMViewport_GetFront(p)                  (p)->lpVtbl->GetFront(p)
+#define IDirect3DRMViewport_GetProjection(p)             (p)->lpVtbl->GetProjection(p)
+#define IDirect3DRMViewport_GetDirect3DViewport(p,a)     (p)->lpVtbl->GetDirect3DViewport(p,a)
+#else
+/*** IUnknown methods ***/
+#define IDirect3DRMViewport_QueryInterface(p,a,b)        (p)->QueryInterface(a,b)
+#define IDirect3DRMViewport_AddRef(p)                    (p)->AddRef()
+#define IDirect3DRMViewport_Release(p)                   (p)->Release()
+/*** IDirect3DRMObject methods ***/
+#define IDirect3DRMViewport_Clone(p,a,b,c)               (p)->Clone(a,b,c)
+#define IDirect3DRMViewport_AddDestroyCallback(p,a,b)    (p)->AddDestroyCallback(a,b)
+#define IDirect3DRMViewport_DeleteDestroyCallback(p,a,b) (p)->DeleteDestroyCallback(a,b)
+#define IDirect3DRMViewport_SetAppData(p,a)              (p)->SetAppData(a)
+#define IDirect3DRMViewport_GetAppData(p)                (p)->GetAppData()
+#define IDirect3DRMViewport_SetName(p,a)                 (p)->SetName(a)
+#define IDirect3DRMViewport_GetName(p,a,b)               (p)->GetName(a,b)
+#define IDirect3DRMViewport_GetClassName(p,a,b)          (p)->GetClassName(a,b)
+/*** IDirect3DRMViewport methods ***/
+#define IDirect3DRMViewport_Init(p,a,b,c,d)              (p)->Init(p,a,b,c,d)
+#define IDirect3DRMViewport_Clear(p)                     (p)->Clear(p)
+#define IDirect3DRMViewport_Render(p,a)                  (p)->Render(p,a)
+#define IDirect3DRMViewport_SetFront(p,a)                (p)->SetFront(p,a)
+#define IDirect3DRMViewport_SetBack(p,a)                 (p)->(p,a)
+#define IDirect3DRMViewport_SetField(p,a)                (p)->(p,a)
+#define IDirect3DRMViewport_SetUniformScaling(p,a)       (p)->SetUniformScaling(p,a)
+#define IDirect3DRMViewport_SetCamera(p,a)               (p)->SetCamera(p,a)
+#define IDirect3DRMViewport_SetProjection(p,a)           (p)->SetProjection(p,a)
+#define IDirect3DRMViewport_Transform(p,a,b)             (p)->Transform(p,a,b)
+#define IDirect3DRMViewport_InverseTransform(p,a,b)      (p)->(p,a,b)
+#define IDirect3DRMViewport_Configure(p,a,b,c,d)         (p)->Configure(p,a,b,c,d)
+#define IDirect3DRMViewport_ForceUpdate(p,a,b,c,d)       (p)->ForceUpdate(p,a,b,c,d)
+#define IDirect3DRMViewport_SetPlane(p,a,b,c,d)          (p)->SetPlane(p,a,b,c,d)
+#define IDirect3DRMViewport_GetCamera(p,a)               (p)->GetCamera(p,a)
+#define IDirect3DRMViewport_GetDevice(p,a)               (p)->GetDevice(p,a)
+#define IDirect3DRMViewport_GetPlane(p,a,b,c,d)          (p)->GetPlane(p,a,b,c,d)
+#define IDirect3DRMViewport_Pick(p,a,b,c)                (p)->Pick(p,a,b,c)
+#define IDirect3DRMViewport_GetUniformScaling(p)         (p)->GetUniformScaling(p)
+#define IDirect3DRMViewport_GetX(p)                      (p)->GetX(p)
+#define IDirect3DRMViewport_GetY(p)                      (p)->GetY(p)
+#define IDirect3DRMViewport_GetWidth(p)                  (p)->GetWidth(p)
+#define IDirect3DRMViewport_GetHeight(p)                 (p)->GetHeight(p)
+#define IDirect3DRMViewport_GetField(p)                  (p)->GetField(p)
+#define IDirect3DRMViewport_GetBack(p)                   (p)->GetBack(p)
+#define IDirect3DRMViewport_GetFront(p)                  (p)->GetFront(p)
+#define IDirect3DRMViewport_GetProjection(p)             (p)->GetProjection(p)
+#define IDirect3DRMViewport_GetDirect3DViewport(p,a)     (p)->GetDirect3DViewport(p,a)
+#endif
+
+/*****************************************************************************
+ * IDirect3DRMViewport2 interface
+ */
+#define INTERFACE IDirect3DRMViewport2
+DECLARE_INTERFACE_(IDirect3DRMViewport2,IDirect3DRMObject)
+{
+    /*** IUnknown methods ***/
+    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
+    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+    STDMETHOD_(ULONG,Release)(THIS) PURE;
+    /*** IDirect3DRMObject methods ***/
+    STDMETHOD(Clone)(THIS_ LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj) PURE;
+    STDMETHOD(AddDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK, LPVOID argument) PURE;
+    STDMETHOD(DeleteDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK, LPVOID argument) PURE;
+    STDMETHOD(SetAppData)(THIS_ DWORD data) PURE;
+    STDMETHOD_(DWORD, GetAppData)(THIS) PURE;
+    STDMETHOD(SetName)(THIS_ LPCSTR) PURE;
+    STDMETHOD(GetName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE;
+    STDMETHOD(GetClassName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE;
+    /*** IDirect3DRMViewport2 methods ***/
+    STDMETHOD(Init) (THIS_ LPDIRECT3DRMDEVICE3 dev, LPDIRECT3DRMFRAME3 camera, DWORD xpos, DWORD ypos,
+        DWORD width, DWORD height) PURE;
+    STDMETHOD(Clear)(THIS_ DWORD flags) PURE;
+    STDMETHOD(Render)(THIS_ LPDIRECT3DRMFRAME3) PURE;
+    STDMETHOD(SetFront)(THIS_ D3DVALUE) PURE;
+    STDMETHOD(SetBack)(THIS_ D3DVALUE) PURE;
+    STDMETHOD(SetField)(THIS_ D3DVALUE) PURE;
+    STDMETHOD(SetUniformScaling)(THIS_ BOOL) PURE;
+    STDMETHOD(SetCamera)(THIS_ LPDIRECT3DRMFRAME3) PURE;
+    STDMETHOD(SetProjection)(THIS_ D3DRMPROJECTIONTYPE) PURE;
+    STDMETHOD(Transform)(THIS_ D3DRMVECTOR4D *d, D3DVECTOR *s) PURE;
+    STDMETHOD(InverseTransform)(THIS_ D3DVECTOR *d, D3DRMVECTOR4D *s) PURE;
+    STDMETHOD(Configure)(THIS_ LONG x, LONG y, DWORD width, DWORD height) PURE;
+    STDMETHOD(ForceUpdate)(THIS_ DWORD x1, DWORD y1, DWORD x2, DWORD y2) PURE;
+    STDMETHOD(SetPlane)(THIS_ D3DVALUE left, D3DVALUE right, D3DVALUE bottom, D3DVALUE top) PURE;
+    STDMETHOD(GetCamera)(THIS_ LPDIRECT3DRMFRAME3 *) PURE;
+    STDMETHOD(GetDevice)(THIS_ LPDIRECT3DRMDEVICE3 *) PURE;
+    STDMETHOD(GetPlane)(THIS_ D3DVALUE *left, D3DVALUE *right, D3DVALUE *bottom, D3DVALUE *top) PURE;
+    STDMETHOD(Pick)(THIS_ LONG x, LONG y, LPDIRECT3DRMPICKEDARRAY *return_visuals) PURE;
+    STDMETHOD_(BOOL, GetUniformScaling)(THIS) PURE;
+    STDMETHOD_(LONG, GetX)(THIS) PURE;
+    STDMETHOD_(LONG, GetY)(THIS) PURE;
+    STDMETHOD_(DWORD, GetWidth)(THIS) PURE;
+    STDMETHOD_(DWORD, GetHeight)(THIS) PURE;
+    STDMETHOD_(D3DVALUE, GetField)(THIS) PURE;
+    STDMETHOD_(D3DVALUE, GetBack)(THIS) PURE;
+    STDMETHOD_(D3DVALUE, GetFront)(THIS) PURE;
+    STDMETHOD_(D3DRMPROJECTIONTYPE, GetProjection)(THIS) PURE;
+    STDMETHOD(GetDirect3DViewport)(THIS_ LPDIRECT3DVIEWPORT *) PURE;
+    STDMETHOD(TransformVectors)(THIS_ DWORD NumVectors, LPD3DRMVECTOR4D pDstVectors,
+        LPD3DVECTOR pSrcVectors) PURE;
+    STDMETHOD(InverseTransformVectors)(THIS_ DWORD NumVectors, LPD3DVECTOR pDstVectors,
+        LPD3DRMVECTOR4D pSrcVectors) PURE;
+};
+#undef INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IDirect3DRMViewport2_QueryInterface(p,a,b)            (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DRMViewport2_AddRef(p)                        (p)->lpVtbl->AddRef(p)
+#define IDirect3DRMViewport2_Release(p)                       (p)->lpVtbl->Release(p)
+/*** IDirect3DRMObject methods ***/
+#define IDirect3DRMViewport_2Clone(p,a,b,c)                   (p)->lpVtbl->Clone(p,a,b,c)
+#define IDirect3DRMViewport2_AddDestroyCallback(p,a,b)        (p)->lpVtbl->AddDestroyCallback(p,a,b)
+#define IDirect3DRMViewport2_DeleteDestroyCallback(p,a,b)     (p)->lpVtbl->DeleteDestroyCallback(p,a,b)
+#define IDirect3DRMViewport2_SetAppData(p,a)                  (p)->lpVtbl->SetAppData(p,a)
+#define IDirect3DRMViewport2_GetAppData(p)                    (p)->lpVtbl->GetAppData(p)
+#define IDirect3DRMViewport2_SetName(p,a)                     (p)->lpVtbl->SetName(p,a)
+#define IDirect3DRMViewport2_GetName(p,a,b)                   (p)->lpVtbl->GetName(p,a,b)
+#define IDirect3DRMViewport2_GetClassName(p,a,b)              (p)->lpVtbl->GetClassName(p,a,b)
+/*** IDirect3DRMViewport2 methods ***/
+#define IDirect3DRMViewport2_Init(p,a,b,c,d,e,f)              (p)->lpVtbl->Init(p,a,b,c,d,e,f)
+#define IDirect3DRMViewport2_Clear(p,a)                       (p)->lpVtbl->Clear(p,a)
+#define IDirect3DRMViewport2_Render(p,a)                      (p)->lpVtbl->Render(p,a)
+#define IDirect3DRMViewport2_SetFront(p,a)                    (p)->lpVtbl->SetFront(p,a)
+#define IDirect3DRMViewport2_SetBack(p,a)                     (p)->lpVtbl->(p,a)
+#define IDirect3DRMViewport2_SetField(p,a)                    (p)->lpVtbl->(p,a)
+#define IDirect3DRMViewport2_SetUniformScaling(p,a)           (p)->lpVtbl->SetUniformScaling(p,a)
+#define IDirect3DRMViewport2_SetCamera(p,a)                   (p)->lpVtbl->SetCamera(p,a)
+#define IDirect3DRMViewport2_SetProjection(p,a)               (p)->lpVtbl->SetProjection(p,a)
+#define IDirect3DRMViewport2_Transform(p,a,b)                 (p)->lpVtbl->Transform(p,a,b)
+#define IDirect3DRMViewport2_InverseTransform(p,a,b)          (p)->lpVtbl->(p,a,b)
+#define IDirect3DRMViewport2_Configure(p,a,b,c,d)             (p)->lpVtbl->Configure(p,a,b,c,d)
+#define IDirect3DRMViewport2_ForceUpdate(p,a,b,c,d)           (p)->lpVtbl->ForceUpdate(p,a,b,c,d)
+#define IDirect3DRMViewport2_SetPlane(p,a,b,c,d)              (p)->lpVtbl->SetPlane(p,a,b,c,d)
+#define IDirect3DRMViewport2_GetCamera(p,a)                   (p)->lpVtbl->(p,a)
+#define IDirect3DRMViewport2_GetDevice(p,a)                   (p)->lpVtbl->GetDevice(p,a)
+#define IDirect3DRMViewport2_GetPlane(p,a,b,c,d)              (p)->lpVtbl->GetPlane(p,a,b,c,d)
+#define IDirect3DRMViewport2_Pick(p,a,b,c)                    (p)->lpVtbl->Pick(p,a,b,c)
+#define IDirect3DRMViewport2_GetUniformScaling(p)             (p)->lpVtbl->GetUniformScaling(p)
+#define IDirect3DRMViewport2_GetX(p)                          (p)->lpVtbl->GetX(p)
+#define IDirect3DRMViewport2_GetY(p)                          (p)->lpVtbl->GetY(p)
+#define IDirect3DRMViewport2_GetWidth(p)                      (p)->lpVtbl->GetWidth(p)
+#define IDirect3DRMViewport2_GetHeight(p)                     (p)->lpVtbl->GetHeight(p)
+#define IDirect3DRMViewport2_GetField(p)                      (p)->lpVtbl->GetField(p)
+#define IDirect3DRMViewport2_GetBack(p)                       (p)->lpVtbl->GetBack(p)
+#define IDirect3DRMViewport2_GetFront(p)                      (p)->lpVtbl->GetFront(p)
+#define IDirect3DRMViewport2_GetProjection(p)                 (p)->lpVtbl->GetProjection(p)
+#define IDirect3DRMViewport2_GetDirect3DViewport(p,a)         (p)->lpVtbl->GetDirect3DViewport(p,a)
+#define IDirect3DRMViewport2_TransformVectors(p,a,b,c)        (p)->lpVtbl->TransformVectors(p,a,b,c)
+#define IDirect3DRMViewport2_InverseTransformVectors(p,a,b,c) (p)->lpVtbl->InverseTransformVectors(p,ab,c)
+#else
+/*** IUnknown methods ***/
+#define IDirect3DRMViewport2_QueryInterface(p,a,b)            (p)->QueryInterface(a,b)
+#define IDirect3DRMViewport2_AddRef(p)                        (p)->AddRef()
+#define IDirect3DRMViewport2_Release(p)                       (p)->Release()
+/*** IDirect3DRMObject methods ***/
+#define IDirect3DRMViewport2_Clone(p,a,b,c)                   (p)->Clone(a,b,c)
+#define IDirect3DRMViewport2_AddDestroyCallback(p,a,b)        (p)->AddDestroyCallback(a,b)
+#define IDirect3DRMViewport2_DeleteDestroyCallback(p,a,b)     (p)->DeleteDestroyCallback(a,b)
+#define IDirect3DRMViewport2_SetAppData(p,a)                  (p)->SetAppData(a)
+#define IDirect3DRMViewport2_GetAppData(p)                    (p)->GetAppData()
+#define IDirect3DRMViewport2_SetName(p,a)                     (p)->SetName(a)
+#define IDirect3DRMViewport2_GetName(p,a,b)                   (p)->GetName(a,b)
+#define IDirect3DRMViewport2_GetClassName(p,a,b)              (p)->GetClassName(a,b)
+/*** IDirect3DRMViewport2 methods ***/
+#define IDirect3DRMViewport2_Init(p,a,b,c,d)                  (p)->Init(p,a,b,c,d)
+#define IDirect3DRMViewport2_Clear(p)                         (p)->Clear(p)
+#define IDirect3DRMViewport2_Render(p,a)                      (p)->Render(p,a)
+#define IDirect3DRMViewport2_SetFront(p,a)                    (p)->SetFront(p,a)
+#define IDirect3DRMViewport2_SetBack(p,a)                     (p)->(p,a)
+#define IDirect3DRMViewport2_SetField(p,a)                    (p)->(p,a)
+#define IDirect3DRMViewport2_SetUniformScaling(p,a)           (p)->SetUniformScaling(p,a)
+#define IDirect3DRMViewport2_SetCamera(p,a)                   (p)->SetCamera(p,a)
+#define IDirect3DRMViewport2_SetProjection(p,a)               (p)->SetProjection(p,a)
+#define IDirect3DRMViewport2_Transform(p,a,b)                 (p)->Transform(p,a,b)
+#define IDirect3DRMViewport2_InverseTransform(p,a,b)          (p)->(p,a,b)
+#define IDirect3DRMViewport2_Configure(p,a,b,c,d)             (p)->Configure(p,a,b,c,d)
+#define IDirect3DRMViewport2_ForceUpdate(p,a,b,c,d)           (p)->ForceUpdate(p,a,b,c,d)
+#define IDirect3DRMViewport2_SetPlane(p,a,b,c,d)              (p)->SetPlane(p,a,b,c,d)
+#define IDirect3DRMViewport2_GetCamera(p,a)                   (p)->GetCamera(p,a)
+#define IDirect3DRMViewport2_GetDevice(p,a)                   (p)->GetDevice(p,a)
+#define IDirect3DRMViewport2_GetPlane(p,a,b,c,d)              (p)->GetPlane(p,a,b,c,d)
+#define IDirect3DRMViewport2_Pick(p,a,b,c)                    (p)->Pick(p,a,b,c)
+#define IDirect3DRMViewport2_GetUniformScaling(p)             (p)->GetUniformScaling(p)
+#define IDirect3DRMViewport2_GetX(p)                          (p)->GetX(p)
+#define IDirect3DRMViewport2_GetY(p)                          (p)->GetY(p)
+#define IDirect3DRMViewport2_GetWidth(p)                      (p)->GetWidth(p)
+#define IDirect3DRMViewport2_GetHeight(p)                     (p)->GetHeight(p)
+#define IDirect3DRMViewport2_GetField(p)                      (p)->GetField(p)
+#define IDirect3DRMViewport2_GetBack(p)                       (p)->GetBack(p)
+#define IDirect3DRMViewport2_GetFront(p)                      (p)->GetFront(p)
+#define IDirect3DRMViewport2_GetProjection(p)                 (p)->GetProjection(p)
+#define IDirect3DRMViewport2_GetDirect3DViewport(p,a)         (p)->GetDirect3DViewport(p,a)
+#define IDirect3DRMViewport2_TransformVectors(p,a,b,c)        (p)->TransformVectors(a,b,c)
+#define IDirect3DRMViewport2_InverseTransformVectors(p,a,b,c) (p)->InverseTransformVectors(ab,c)
+#endif
+
+/*****************************************************************************
+ * IDirect3DRMFrame interface
+ */
+#define INTERFACE IDirect3DRMFrame
+DECLARE_INTERFACE_(IDirect3DRMFrame,IDirect3DRMVisual)
+{
+    /*** IUnknown methods ***/
+    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
+    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+    STDMETHOD_(ULONG,Release)(THIS) PURE;
+    /*** IDirect3DRMObject methods ***/
+    STDMETHOD(Clone)(THIS_ LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj) PURE;
+    STDMETHOD(AddDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK, LPVOID argument) PURE;
+    STDMETHOD(DeleteDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK, LPVOID argument) PURE;
+    STDMETHOD(SetAppData)(THIS_ DWORD data) PURE;
+    STDMETHOD_(DWORD, GetAppData)(THIS) PURE;
+    STDMETHOD(SetName)(THIS_ LPCSTR) PURE;
+    STDMETHOD(GetName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE;
+    STDMETHOD(GetClassName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE;
+    /*** IDirect3DRMFrame methods ***/
+    STDMETHOD(AddChild)(THIS_ LPDIRECT3DRMFRAME child) PURE;
+    STDMETHOD(AddLight)(THIS_ LPDIRECT3DRMLIGHT) PURE;
+    STDMETHOD(AddMoveCallback)(THIS_ D3DRMFRAMEMOVECALLBACK, VOID *arg) PURE;
+    STDMETHOD(AddTransform)(THIS_ D3DRMCOMBINETYPE, D3DRMMATRIX4D) PURE;
+    STDMETHOD(AddTranslation)(THIS_ D3DRMCOMBINETYPE, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE;
+    STDMETHOD(AddScale)(THIS_ D3DRMCOMBINETYPE, D3DVALUE sx, D3DVALUE sy, D3DVALUE sz) PURE;
+    STDMETHOD(AddRotation)(THIS_ D3DRMCOMBINETYPE, D3DVALUE x, D3DVALUE y, D3DVALUE z, D3DVALUE theta) PURE;
+    STDMETHOD(AddVisual)(THIS_ LPDIRECT3DRMVISUAL) PURE;
+    STDMETHOD(GetChildren)(THIS_ LPDIRECT3DRMFRAMEARRAY *children) PURE;
+    STDMETHOD_(D3DCOLOR, GetColor)(THIS) PURE;
+    STDMETHOD(GetLights)(THIS_ LPDIRECT3DRMLIGHTARRAY *lights) PURE;
+    STDMETHOD_(D3DRMMATERIALMODE, GetMaterialMode)(THIS) PURE;
+    STDMETHOD(GetParent)(THIS_ LPDIRECT3DRMFRAME *) PURE;
+    STDMETHOD(GetPosition)(THIS_ LPDIRECT3DRMFRAME reference, LPD3DVECTOR return_position) PURE;
+    STDMETHOD(GetRotation)(THIS_ LPDIRECT3DRMFRAME reference, LPD3DVECTOR axis, LPD3DVALUE return_theta) PURE;
+    STDMETHOD(GetScene)(THIS_ LPDIRECT3DRMFRAME *) PURE;
+    STDMETHOD_(D3DRMSORTMODE, GetSortMode)(THIS) PURE;
+    STDMETHOD(GetTexture)(THIS_ LPDIRECT3DRMTEXTURE *) PURE;
+    STDMETHOD(GetTransform)(THIS_ D3DRMMATRIX4D return_matrix) PURE;
+    STDMETHOD(GetVelocity)(THIS_ LPDIRECT3DRMFRAME reference, LPD3DVECTOR return_velocity, BOOL with_rotation) PURE;
+    STDMETHOD(GetOrientation)(THIS_ LPDIRECT3DRMFRAME reference, LPD3DVECTOR dir, LPD3DVECTOR up) PURE;
+    STDMETHOD(GetVisuals)(THIS_ LPDIRECT3DRMVISUALARRAY *visuals) PURE;
+    STDMETHOD(GetTextureTopology)(THIS_ BOOL *wrap_u, BOOL *wrap_v) PURE;
+    STDMETHOD(InverseTransform)(THIS_ D3DVECTOR *d, D3DVECTOR *s) PURE;
+    STDMETHOD(Load)(THIS_ LPVOID filename, LPVOID name, D3DRMLOADOPTIONS loadflags, D3DRMLOADTEXTURECALLBACK,
+        LPVOID pArg)PURE;
+    STDMETHOD(LookAt)(THIS_ LPDIRECT3DRMFRAME target, LPDIRECT3DRMFRAME reference, D3DRMFRAMECONSTRAINT) PURE;
+    STDMETHOD(Move)(THIS_ D3DVALUE delta) PURE;
+    STDMETHOD(DeleteChild)(THIS_ LPDIRECT3DRMFRAME) PURE;
+    STDMETHOD(DeleteLight)(THIS_ LPDIRECT3DRMLIGHT) PURE;
+    STDMETHOD(DeleteMoveCallback)(THIS_ D3DRMFRAMEMOVECALLBACK, VOID *arg) PURE;
+    STDMETHOD(DeleteVisual)(THIS_ LPDIRECT3DRMVISUAL) PURE;
+    STDMETHOD_(D3DCOLOR, GetSceneBackground)(THIS) PURE;
+    STDMETHOD(GetSceneBackgroundDepth)(THIS_ LPDIRECTDRAWSURFACE *) PURE;
+    STDMETHOD_(D3DCOLOR, GetSceneFogColor)(THIS) PURE;
+    STDMETHOD_(BOOL, GetSceneFogEnable)(THIS) PURE;
+    STDMETHOD_(D3DRMFOGMODE, GetSceneFogMode)(THIS) PURE;
+    STDMETHOD(GetSceneFogParams)(THIS_ D3DVALUE *return_start, D3DVALUE *return_end, D3DVALUE *return_density) PURE;
+    STDMETHOD(SetSceneBackground)(THIS_ D3DCOLOR) PURE;
+    STDMETHOD(SetSceneBackgroundRGB)(THIS_ D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE;
+    STDMETHOD(SetSceneBackgroundDepth)(THIS_ LPDIRECTDRAWSURFACE) PURE;
+    STDMETHOD(SetSceneBackgroundImage)(THIS_ LPDIRECT3DRMTEXTURE) PURE;
+    STDMETHOD(SetSceneFogEnable)(THIS_ BOOL) PURE;
+    STDMETHOD(SetSceneFogColor)(THIS_ D3DCOLOR) PURE;
+    STDMETHOD(SetSceneFogMode)(THIS_ D3DRMFOGMODE) PURE;
+    STDMETHOD(SetSceneFogParams)(THIS_ D3DVALUE start, D3DVALUE end, D3DVALUE density) PURE;
+    STDMETHOD(SetColor)(THIS_ D3DCOLOR) PURE;
+    STDMETHOD(SetColorRGB)(THIS_ D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE;
+    STDMETHOD_(D3DRMZBUFFERMODE, GetZbufferMode)(THIS) PURE;
+    STDMETHOD(SetMaterialMode)(THIS_ D3DRMMATERIALMODE) PURE;
+    STDMETHOD(SetOrientation)(THIS_ LPDIRECT3DRMFRAME reference, D3DVALUE dx, D3DVALUE dy, D3DVALUE dz,
+        D3DVALUE ux, D3DVALUE uy, D3DVALUE uz) PURE;
+    STDMETHOD(SetPosition)(THIS_ LPDIRECT3DRMFRAME reference, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE;
+    STDMETHOD(SetRotation)(THIS_ LPDIRECT3DRMFRAME reference, D3DVALUE x, D3DVALUE y, D3DVALUE z, D3DVALUE theta) PURE;
+    STDMETHOD(SetSortMode)(THIS_ D3DRMSORTMODE) PURE;
+    STDMETHOD(SetTexture)(THIS_ LPDIRECT3DRMTEXTURE) PURE;
+    STDMETHOD(SetTextureTopology)(THIS_ BOOL wrap_u, BOOL wrap_v) PURE;
+    STDMETHOD(SetVelocity)(THIS_ LPDIRECT3DRMFRAME reference, D3DVALUE x, D3DVALUE y, D3DVALUE z, BOOL with_rotation) PURE;
+    STDMETHOD(SetZbufferMode)(THIS_ D3DRMZBUFFERMODE) PURE;
+    STDMETHOD(Transform)(THIS_ D3DVECTOR *d, D3DVECTOR *s) PURE;
+};
+#undef INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IDirect3DRMFrame_QueryInterface(p,a,b)            (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DRMFrame_AddRef(p)                        (p)->lpVtbl->AddRef(p)
+#define IDirect3DRMFrame_Release(p)                       (p)->lpVtbl->Release(p)
+/*** IDirect3DRMObject methods ***/
+#define IDirect3DRMFrame_Clone(p,a,b,c)                   (p)->lpVtbl->Clone(p,a,b,c)
+#define IDirect3DRMFrame_AddDestroyCallback(p,a,b)        (p)->lpVtbl->AddDestroyCallback(p,a,b)
+#define IDirect3DRMFrame_DeleteDestroyCallback(p,a,b)     (p)->lpVtbl->DeleteDestroyCallback(p,a,b)
+#define IDirect3DRMFrame_SetAppData(p,a)                  (p)->lpVtbl->SetAppData(p,a)
+#define IDirect3DRMFrame_GetAppData(p)                    (p)->lpVtbl->GetAppData(p)
+#define IDirect3DRMFrame_SetName(p,a)                     (p)->lpVtbl->SetName(p,a)
+#define IDirect3DRMFrame_GetName(p,a,b)                   (p)->lpVtbl->GetName(p,a,b)
+#define IDirect3DRMFrame_GetClassName(p,a,b)              (p)->lpVtbl->GetClassName(p,a,b)
+/*** IDirect3DRMFrame methods ***/
+#define IDirect3DRMFrame_AddChild(p,a)                    (p)->lpVtbl->AddChild(p,a)
+#define IDirect3DRMFrame_AddLight(p,a)                    (p)->lpVtbl->AddLight(p,a)
+#define IDirect3DRMFrame_AddMoveCallback(p,a,b)           (p)->lpVtbl->AddMoveCallback(p,a,b)
+#define IDirect3DRMFrame_AddTransform(p,a,b)              (p)->lpVtbl->AddTransform(p,a,b)
+#define IDirect3DRMFrame_AddTranslation(p,a,b,c,d)        (p)->lpVtbl->AddTranslation(p,a,b,c,d)
+#define IDirect3DRMFrame_AddScale(p,a,b,c,d)              (p)->lpVtbl->AddScale(p,a,b,c,d)
+#define IDirect3DRMFrame_AddRotation(p,a,b,c,d,e)         (p)->lpVtbl->AddRotation(p,a,b,c,d,e)
+#define IDirect3DRMFrame_AddVisual(p,a)                   (p)->lpVtbl->AddVisual(p,a)
+#define IDirect3DRMFrame_GetChildren(p,a)                 (p)->lpVtbl->GetChildren(p,a)
+#define IDirect3DRMFrame_GetColor(p)                      (p)->lpVtbl->GetColor(p)
+#define IDirect3DRMFrame_GetLights(p,a)                   (p)->lpVtbl->GetLights(p,a)
+#define IDirect3DRMFrame_GetMaterialMode(p)               (p)->lpVtbl->GetMaterialMode(p)
+#define IDirect3DRMFrame_GetParent(p,a)                   (p)->lpVtbl->GetParent(p,a)
+#define IDirect3DRMFrame_GetPosition(p,a,b)               (p)->lpVtbl->GetPosition(p,a,b)
+#define IDirect3DRMFrame_GetRotation(p,a,b,c)             (p)->lpVtbl->GetRotation(p,a,b,c)
+#define IDirect3DRMFrame_GetScene(p,a)                    (p)->lpVtbl->GetScene(p,a)
+#define IDirect3DRMFrame_GetSortMode(p)                   (p)->lpVtbl->GetSortMode(p)
+#define IDirect3DRMFrame_GetTexture(p,a)                  (p)->lpVtbl->GetTexture(p,a)
+#define IDirect3DRMFrame_GetTransform(p,a)                (p)->lpVtbl->GetTransform(p,a)
+#define IDirect3DRMFrame_GetVelocity(p,a,b,c)             (p)->lpVtbl->GetVelocity(p,a,b,c)
+#define IDirect3DRMFrame_GetOrientation(p,a,b,c)          (p)->lpVtbl->GetOrientation(p,a,b,c)
+#define IDirect3DRMFrame_GetVisuals(p,a)                  (p)->lpVtbl->GetVisuals(p,a)
+#define IDirect3DRMFrame_GetTextureTopology(p,a,b)        (p)->lpVtbl->GetTextureTopology(p,a,b)
+#define IDirect3DRMFrame_InverseTransform(p,a,b)          (p)->lpVtbl->InverseTransform(p,a,b)
+#define IDirect3DRMFrame_Load(p,a,b,c,d,e)                (p)->lpVtbl->Load(p,a,b,c,d,e)
+#define IDirect3DRMFrame_LookAt(p,a,b,c)                  (p)->lpVtbl->LookAt(p,a,b,c)
+#define IDirect3DRMFrame_Move(p,a)                        (p)->lpVtbl->Move(p,a)
+#define IDirect3DRMFrame_DeleteChild(p,a)                 (p)->lpVtbl->DeleteChild(p,a)
+#define IDirect3DRMFrame_DeleteLight(p,a)                 (p)->lpVtbl->DeleteLight(p,a)
+#define IDirect3DRMFrame_DeleteMoveCallback(p,a,b)        (p)->lpVtbl->DeleteMoveCallback(p,a,b)
+#define IDirect3DRMFrame_DeleteVisual(p,a)                (p)->lpVtbl->DeleteVisual(p,a)
+#define IDirect3DRMFrame_GetSceneBackground(p)            (p)->lpVtbl->GetSceneBackground(p)
+#define IDirect3DRMFrame_GetSceneBackgroundDepth(p,a)     (p)->lpVtbl->GetSceneBackgroundDepth(p,a)
+#define IDirect3DRMFrame_GetSceneFogColor(p)              (p)->lpVtbl->GetSceneFogColor(p)
+#define IDirect3DRMFrame_GetSceneFogEnable(p)             (p)->lpVtbl->GetSceneFogEnable(p)
+#define IDirect3DRMFrame_GetSceneFogMode(p)               (p)->lpVtbl->GetSceneFogMode(p)
+#define IDirect3DRMFrame_GetSceneFogParams(p,a,b,c)       (p)->lpVtbl->GetSceneFogParams(p,a,b,c)
+#define IDirect3DRMFrame_SetSceneBackground(p,a)          (p)->lpVtbl->SetSceneBackground(p,a)
+#define IDirect3DRMFrame_SetSceneBackgroundRGB(p,a,b,c)   (p)->lpVtbl->SetSceneBackgroundRGB(p,a,b,c)
+#define IDirect3DRMFrame_SetSceneBackgroundDepth(p,a)     (p)->lpVtbl->SetSceneBackgroundDepth(p,a)
+#define IDirect3DRMFrame_SetSceneBackgroundImage(p,a)     (p)->lpVtbl->SetSceneBackgroundImage(p,a)
+#define IDirect3DRMFrame_SetSceneFogEnable(p,a)           (p)->lpVtbl->SetSceneFogEnable(p,a)
+#define IDirect3DRMFrame_SetSceneFogColor(p,a)            (p)->lpVtbl->SetSceneFogColor(p,a)
+#define IDirect3DRMFrame_SetSceneFogMode(p,a)             (p)->lpVtbl->SetSceneFogMode(p,a)
+#define IDirect3DRMFrame_SetSceneFogParams(p,a,b,c)       (p)->lpVtbl->SetSceneFogParams(p,a,b,c)
+#define IDirect3DRMFrame_SetColor(p,a)                    (p)->lpVtbl->SetColor(p,a)
+#define IDirect3DRMFrame_SetColorRGB(p,a,b,c)             (p)->lpVtbl->SetColorRGB(p,a,b,c)
+#define IDirect3DRMFrame_GetZbufferMode(p)                (p)->lpVtbl->GetZbufferMode(p)
+#define IDirect3DRMFrame_SetMaterialMode(p,a)             (p)->lpVtbl->SetMaterialMode(p,a)
+#define IDirect3DRMFrame_SetOrientation(p,a,b,c,d,e,f,g)  (p)->lpVtbl->SetOrientation(p,a,b,c,d,e,f,g)
+#define IDirect3DRMFrame_SetPosition(p,a,b,c,d)           (p)->lpVtbl->SetPosition(p,a,b,c,d)
+#define IDirect3DRMFrame_SetRotation(p,a,b,c,d,e)         (p)->lpVtbl->SetRotation(p,a,b,c,d,e)
+#define IDirect3DRMFrame_SetSortMode(p,a)                 (p)->lpVtbl->SetSortMode(p,a)
+#define IDirect3DRMFrame_SetTexture(p,a)                  (p)->lpVtbl->SetTexture(p,a)
+#define IDirect3DRMFrame_SetTextureTopology(p,a,b)        (p)->lpVtbl->SetTextureTopology(p,a,b)
+#define IDirect3DRMFrame_SetVelocity(p,a,b,c,d,e)         (p)->lpVtbl->SetVelocity(p,a,b,c,d,e)
+#define IDirect3DRMFrame_SetZbufferMode(p,a)              (p)->lpVtbl->SetZbufferMode(p,a)
+#define IDirect3DRMFrame_Transform(p,a,b)                 (p)->lpVtbl->Transform(p,a,b)
+#else
+/*** IUnknown methods ***/
+#define IDirect3DRMFrame_QueryInterface(p,a,b)            (p)->QueryInterface(a,b)
+#define IDirect3DRMFrame_AddRef(p)                        (p)->AddRef()
+#define IDirect3DRMFrame_Release(p)                       (p)->Release()
+/*** IDirect3DRMObject methods ***/
+#define IDirect3DRMFrame_Clone(p,a,b,c)                   (p)->Clone(a,b,c)
+#define IDirect3DRMFrame_AddDestroyCallback(p,a,b)        (p)->AddDestroyCallback(a,b)
+#define IDirect3DRMFrame_DeleteDestroyCallback(p,a,b)     (p)->DeleteDestroyCallback(a,b)
+#define IDirect3DRMFrame_SetAppData(p,a)                  (p)->SetAppData(a)
+#define IDirect3DRMFrame_GetAppData(p)                    (p)->GetAppData()
+#define IDirect3DRMFrame_SetName(p,a)                     (p)->SetName(a)
+#define IDirect3DRMFrame_GetName(p,a,b)                   (p)->GetName(a,b)
+#define IDirect3DRMFrame_GetClassName(p,a,b)              (p)->GetClassName(a,b)
+/*** IDirect3DRMFrame methods ***/
+#define IDirect3DRMFrame_AddChild(p,a)                    (p)->AddChild(a)
+#define IDirect3DRMFrame_AddLight(p,a)                    (p)->AddLight(a)
+#define IDirect3DRMFrame_AddMoveCallback(p,a,b)           (p)->AddMoveCallback(a,b)
+#define IDirect3DRMFrame_AddTransform(p,a,b)              (p)->AddTransform(a,b)
+#define IDirect3DRMFrame_AddTranslation(p,a,b,c,d)        (p)->AddTranslation(a,b,c,d)
+#define IDirect3DRMFrame_AddScale(p,a,b,c,d)              (p)->AddScale(a,b,c,d)
+#define IDirect3DRMFrame_AddRotation(p,a,b,c,d,e)         (p)->AddRotation(a,b,c,d,e)
+#define IDirect3DRMFrame_AddVisual(p,a)                   (p)->AddVisual(a)
+#define IDirect3DRMFrame_GetChildren(p,a)                 (p)->GetChildren(a)
+#define IDirect3DRMFrame_GetColor(p)                      (p)->GetColor()
+#define IDirect3DRMFrame_GetLights(p,a)                   (p)->GetLights(a)
+#define IDirect3DRMFrame_GetMaterialMode(p)               (p)->GetMaterialMode()
+#define IDirect3DRMFrame_GetParent(p,a)                   (p)->GetParent(a)
+#define IDirect3DRMFrame_GetPosition(p,a,b)               (p)->GetPosition(a,b)
+#define IDirect3DRMFrame_GetRotation(p,a,b,c)             (p)->GetRotation(a,b,c)
+#define IDirect3DRMFrame_GetScene(p,a)                    (p)->GetScene(a)
+#define IDirect3DRMFrame_GetSortMode(p)                   (p)->GetSortMode()
+#define IDirect3DRMFrame_GetTexture(p,a)                  (p)->GetTexture(a)
+#define IDirect3DRMFrame_GetTransform(p,a)                (p)->GetTransform(a)
+#define IDirect3DRMFrame_GetVelocity(p,a,b,c)             (p)->GetVelocity(a,b,c)
+#define IDirect3DRMFrame_GetOrientation(p,a,b,c)          (p)->GetOrientation(a,b,c)
+#define IDirect3DRMFrame_GetVisuals(p,a)                  (p)->GetVisuals(a)
+#define IDirect3DRMFrame_GetTextureTopology(p,a,b)        (p)->GetTextureTopology(a,b)
+#define IDirect3DRMFrame_InverseTransform(p,a,b)          (p)->InverseTransform(a,b)
+#define IDirect3DRMFrame_Load(p,a,b,c,d,e)                (p)->Load(a,b,c,d,e)
+#define IDirect3DRMFrame_LookAt(p,a,b,c)                  (p)->LookAt(a,b,c)
+#define IDirect3DRMFrame_Move(p,a)                        (p)->Move(a)
+#define IDirect3DRMFrame_DeleteChild(p,a)                 (p)->DeleteChild(a)
+#define IDirect3DRMFrame_DeleteLight(p,a)                 (p)->DeleteLight(a)
+#define IDirect3DRMFrame_DeleteMoveCallback(p,a,b)        (p)->DeleteMoveCallback(a,b)
+#define IDirect3DRMFrame_DeleteVisual(p,a)                (p)->DeleteVisual(a)
+#define IDirect3DRMFrame_GetSceneBackground(p)            (p)->GetSceneBackground()
+#define IDirect3DRMFrame_GetSceneBackgroundDepth(p,a)     (p)->GetSceneBackgroundDepth(a)
+#define IDirect3DRMFrame_GetSceneFogColor(p)              (p)->GetSceneFogColor()
+#define IDirect3DRMFrame_GetSceneFogEnable(p)             (p)->GetSceneFogEnable()
+#define IDirect3DRMFrame_GetSceneFogMode(p)               (p)->GetSceneFogMode()
+#define IDirect3DRMFrame_GetSceneFogParams(p,a,b,c)       (p)->GetSceneFogParams(a,b,c)
+#define IDirect3DRMFrame_SetSceneBackground(p,a)          (p)->SetSceneBackground(a)
+#define IDirect3DRMFrame_SetSceneBackgroundRGB(p,a,b,c)   (p)->SetSceneBackgroundRGB(a,b,c)
+#define IDirect3DRMFrame_SetSceneBackgroundDepth(p,a)     (p)->SetSceneBackgroundDepth(a)
+#define IDirect3DRMFrame_SetSceneBackgroundImage(p,a)     (p)->SetSceneBackgroundImage(a)
+#define IDirect3DRMFrame_SetSceneFogEnable(p,a)           (p)->SetSceneFogEnable(a)
+#define IDirect3DRMFrame_SetSceneFogColor(p,a)            (p)->SetSceneFogColor(a)
+#define IDirect3DRMFrame_SetSceneFogMode(p,a)             (p)->SetSceneFogMode(a)
+#define IDirect3DRMFrame_SetSceneFogParams(p,a,b,c)       (p)->SetSceneFogParams(a,b,c)
+#define IDirect3DRMFrame_SetColor(p,a)                    (p)->SetColor(a)
+#define IDirect3DRMFrame_SetColorRGB(p,a,b,c)             (p)->SetColorRGB(a,b,c)
+#define IDirect3DRMFrame_GetZbufferMode(p)                (p)->GetZbufferMode()
+#define IDirect3DRMFrame_SetMaterialMode(p,a)             (p)->SetMaterialMode(a)
+#define IDirect3DRMFrame_SetOrientation(p,a,b,c,d,e,f,g)  (p)->SetOrientation(a,b,c,d,e,f,g)
+#define IDirect3DRMFrame_SetPosition(p,a,b,c,d)           (p)->SetPosition(a,b,c,d)
+#define IDirect3DRMFrame_SetRotation(p,a,b,c,d,e)         (p)->SetRotation(a,b,c,d,e)
+#define IDirect3DRMFrame_SetSortMode(p,a)                 (p)->SetSortMode(a)
+#define IDirect3DRMFrame_SetTexture(p,a)                  (p)->SetTexture(a)
+#define IDirect3DRMFrame_SetTextureTopology(p,a,b)        (p)->SetTextureTopology(a,b)
+#define IDirect3DRMFrame_SetVelocity(p,a,b,c,d,e)         (p)->SetVelocity(a,b,c,d,e)
+#define IDirect3DRMFrame_SetZbufferMode(p,a)              (p)->SetZbufferMode(a)
+#define IDirect3DRMFrame_Transform(p,a,b)                 (p)->Transform(a,b)
+#endif
+
+/*****************************************************************************
+ * IDirect3DRMFrame2 interface
+ */
+#define INTERFACE IDirect3DRMFrame2
+DECLARE_INTERFACE_(IDirect3DRMFrame2,IDirect3DRMFrame)
+{
+    /*** IUnknown methods ***/
+    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
+    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+    STDMETHOD_(ULONG,Release)(THIS) PURE;
+    /*** IDirect3DRMObject methods ***/
+    STDMETHOD(Clone)(THIS_ LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj) PURE;
+    STDMETHOD(AddDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK, LPVOID argument) PURE;
+    STDMETHOD(DeleteDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK, LPVOID argument) PURE;
+    STDMETHOD(SetAppData)(THIS_ DWORD data) PURE;
+    STDMETHOD_(DWORD, GetAppData)(THIS) PURE;
+    STDMETHOD(SetName)(THIS_ LPCSTR) PURE;
+    STDMETHOD(GetName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE;
+    STDMETHOD(GetClassName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE;
+    /*** IDirect3DRMFrame methods ***/
+    STDMETHOD(AddChild)(THIS_ LPDIRECT3DRMFRAME child) PURE;
+    STDMETHOD(AddLight)(THIS_ LPDIRECT3DRMLIGHT) PURE;
+    STDMETHOD(AddMoveCallback)(THIS_ D3DRMFRAMEMOVECALLBACK, VOID *arg) PURE;
+    STDMETHOD(AddTransform)(THIS_ D3DRMCOMBINETYPE, D3DRMMATRIX4D) PURE;
+    STDMETHOD(AddTranslation)(THIS_ D3DRMCOMBINETYPE, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE;
+    STDMETHOD(AddScale)(THIS_ D3DRMCOMBINETYPE, D3DVALUE sx, D3DVALUE sy, D3DVALUE sz) PURE;
+    STDMETHOD(AddRotation)(THIS_ D3DRMCOMBINETYPE, D3DVALUE x, D3DVALUE y, D3DVALUE z, D3DVALUE theta) PURE;
+    STDMETHOD(AddVisual)(THIS_ LPDIRECT3DRMVISUAL) PURE;
+    STDMETHOD(GetChildren)(THIS_ LPDIRECT3DRMFRAMEARRAY *children) PURE;
+    STDMETHOD_(D3DCOLOR, GetColor)(THIS) PURE;
+    STDMETHOD(GetLights)(THIS_ LPDIRECT3DRMLIGHTARRAY *lights) PURE;
+    STDMETHOD_(D3DRMMATERIALMODE, GetMaterialMode)(THIS) PURE;
+    STDMETHOD(GetParent)(THIS_ LPDIRECT3DRMFRAME *) PURE;
+    STDMETHOD(GetPosition)(THIS_ LPDIRECT3DRMFRAME reference, LPD3DVECTOR return_position) PURE;
+    STDMETHOD(GetRotation)(THIS_ LPDIRECT3DRMFRAME reference, LPD3DVECTOR axis, LPD3DVALUE return_theta) PURE;
+    STDMETHOD(GetScene)(THIS_ LPDIRECT3DRMFRAME *) PURE;
+    STDMETHOD_(D3DRMSORTMODE, GetSortMode)(THIS) PURE;
+    STDMETHOD(GetTexture)(THIS_ LPDIRECT3DRMTEXTURE *) PURE;
+    STDMETHOD(GetTransform)(THIS_ D3DRMMATRIX4D return_matrix) PURE;
+    STDMETHOD(GetVelocity)(THIS_ LPDIRECT3DRMFRAME reference, LPD3DVECTOR return_velocity, BOOL with_rotation) PURE;
+    STDMETHOD(GetOrientation)(THIS_ LPDIRECT3DRMFRAME reference, LPD3DVECTOR dir, LPD3DVECTOR up) PURE;
+    STDMETHOD(GetVisuals)(THIS_ LPDIRECT3DRMVISUALARRAY *visuals) PURE;
+    STDMETHOD(GetTextureTopology)(THIS_ BOOL *wrap_u, BOOL *wrap_v) PURE;
+    STDMETHOD(InverseTransform)(THIS_ D3DVECTOR *d, D3DVECTOR *s) PURE;
+    STDMETHOD(Load)(THIS_ LPVOID filename, LPVOID name, D3DRMLOADOPTIONS loadflags, D3DRMLOADTEXTURECALLBACK,
+        LPVOID pArg)PURE;
+    STDMETHOD(LookAt)(THIS_ LPDIRECT3DRMFRAME target, LPDIRECT3DRMFRAME reference, D3DRMFRAMECONSTRAINT) PURE;
+    STDMETHOD(Move)(THIS_ D3DVALUE delta) PURE;
+    STDMETHOD(DeleteChild)(THIS_ LPDIRECT3DRMFRAME) PURE;
+    STDMETHOD(DeleteLight)(THIS_ LPDIRECT3DRMLIGHT) PURE;
+    STDMETHOD(DeleteMoveCallback)(THIS_ D3DRMFRAMEMOVECALLBACK, VOID *arg) PURE;
+    STDMETHOD(DeleteVisual)(THIS_ LPDIRECT3DRMVISUAL) PURE;
+    STDMETHOD_(D3DCOLOR, GetSceneBackground)(THIS) PURE;
+    STDMETHOD(GetSceneBackgroundDepth)(THIS_ LPDIRECTDRAWSURFACE *) PURE;
+    STDMETHOD_(D3DCOLOR, GetSceneFogColor)(THIS) PURE;
+    STDMETHOD_(BOOL, GetSceneFogEnable)(THIS) PURE;
+    STDMETHOD_(D3DRMFOGMODE, GetSceneFogMode)(THIS) PURE;
+    STDMETHOD(GetSceneFogParams)(THIS_ D3DVALUE *return_start, D3DVALUE *return_end, D3DVALUE *return_density) PURE;
+    STDMETHOD(SetSceneBackground)(THIS_ D3DCOLOR) PURE;
+    STDMETHOD(SetSceneBackgroundRGB)(THIS_ D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE;
+    STDMETHOD(SetSceneBackgroundDepth)(THIS_ LPDIRECTDRAWSURFACE) PURE;
+    STDMETHOD(SetSceneBackgroundImage)(THIS_ LPDIRECT3DRMTEXTURE) PURE;
+    STDMETHOD(SetSceneFogEnable)(THIS_ BOOL) PURE;
+    STDMETHOD(SetSceneFogColor)(THIS_ D3DCOLOR) PURE;
+    STDMETHOD(SetSceneFogMode)(THIS_ D3DRMFOGMODE) PURE;
+    STDMETHOD(SetSceneFogParams)(THIS_ D3DVALUE start, D3DVALUE end, D3DVALUE density) PURE;
+    STDMETHOD(SetColor)(THIS_ D3DCOLOR) PURE;
+    STDMETHOD(SetColorRGB)(THIS_ D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE;
+    STDMETHOD_(D3DRMZBUFFERMODE, GetZbufferMode)(THIS) PURE;
+    STDMETHOD(SetMaterialMode)(THIS_ D3DRMMATERIALMODE) PURE;
+    STDMETHOD(SetOrientation)(THIS_ LPDIRECT3DRMFRAME reference, D3DVALUE dx, D3DVALUE dy, D3DVALUE dz,
+        D3DVALUE ux, D3DVALUE uy, D3DVALUE uz) PURE;
+    STDMETHOD(SetPosition)(THIS_ LPDIRECT3DRMFRAME reference, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE;
+    STDMETHOD(SetRotation)(THIS_ LPDIRECT3DRMFRAME reference, D3DVALUE x, D3DVALUE y, D3DVALUE z, D3DVALUE theta) PURE;
+    STDMETHOD(SetSortMode)(THIS_ D3DRMSORTMODE) PURE;
+    STDMETHOD(SetTexture)(THIS_ LPDIRECT3DRMTEXTURE) PURE;
+    STDMETHOD(SetTextureTopology)(THIS_ BOOL wrap_u, BOOL wrap_v) PURE;
+    STDMETHOD(SetVelocity)(THIS_ LPDIRECT3DRMFRAME reference, D3DVALUE x, D3DVALUE y, D3DVALUE z, BOOL with_rotation) PURE;
+    STDMETHOD(SetZbufferMode)(THIS_ D3DRMZBUFFERMODE) PURE;
+    STDMETHOD(Transform)(THIS_ D3DVECTOR *d, D3DVECTOR *s) PURE;
+    /*** IDirect3DRMFrame2 methods ***/
+    STDMETHOD(AddMoveCallback2)(THIS_ D3DRMFRAMEMOVECALLBACK, VOID *arg, DWORD flags) PURE;
+    STDMETHOD(GetBox)(THIS_ LPD3DRMBOX) PURE;
+    STDMETHOD_(BOOL, GetBoxEnable)(THIS) PURE;
+    STDMETHOD(GetAxes)(THIS_ LPD3DVECTOR dir, LPD3DVECTOR up);
+    STDMETHOD(GetMaterial)(THIS_ LPDIRECT3DRMMATERIAL *) PURE;
+    STDMETHOD_(BOOL, GetInheritAxes)(THIS);
+    STDMETHOD(GetHierarchyBox)(THIS_ LPD3DRMBOX) PURE;
+    STDMETHOD(SetBox)(THIS_ LPD3DRMBOX) PURE;
+    STDMETHOD(SetBoxEnable)(THIS_ BOOL) PURE;
+    STDMETHOD(SetAxes)(THIS_ D3DVALUE dx, D3DVALUE dy, D3DVALUE dz, D3DVALUE ux, D3DVALUE uy, D3DVALUE uz);
+    STDMETHOD(SetInheritAxes)(THIS_ BOOL inherit_from_parent);
+    STDMETHOD(SetMaterial)(THIS_ LPDIRECT3DRMMATERIAL) PURE;
+    STDMETHOD(SetQuaternion)(THIS_ LPDIRECT3DRMFRAME reference, D3DRMQUATERNION *q) PURE;
+    STDMETHOD(RayPick)(THIS_ LPDIRECT3DRMFRAME reference, LPD3DRMRAY ray, DWORD flags,
+        LPDIRECT3DRMPICKED2ARRAY *return_visuals) PURE;
+    STDMETHOD(Save)(THIS_ LPCSTR filename, D3DRMXOFFORMAT d3dFormat, D3DRMSAVEOPTIONS d3dSaveFlags);
+};
+#undef INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IDirect3DRMFrame2_QueryInterface(p,a,b)            (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DRMFrame2_AddRef(p)                        (p)->lpVtbl->AddRef(p)
+#define IDirect3DRMFrame2_Release(p)                       (p)->lpVtbl->Release(p)
+/*** IDirect3DRMObject methods ***/
+#define IDirect3DRMFrame2_Clone(p,a,b,c)                   (p)->lpVtbl->Clone(p,a,b,c)
+#define IDirect3DRMFrame2_AddDestroyCallback(p,a,b)        (p)->lpVtbl->AddDestroyCallback(p,a,b)
+#define IDirect3DRMFrame2_DeleteDestroyCallback(p,a,b)     (p)->lpVtbl->DeleteDestroyCallback(p,a,b)
+#define IDirect3DRMFrame2_SetAppData(p,a)                  (p)->lpVtbl->SetAppData(p,a)
+#define IDirect3DRMFrame2_GetAppData(p)                    (p)->lpVtbl->GetAppData(p)
+#define IDirect3DRMFrame2_SetName(p,a)                     (p)->lpVtbl->SetName(p,a)
+#define IDirect3DRMFrame2_GetName(p,a,b)                   (p)->lpVtbl->GetName(p,a,b)
+#define IDirect3DRMFrame2_GetClassName(p,a,b)              (p)->lpVtbl->GetClassName(p,a,b)
+/*** IDirect3DRMFrame methods ***/
+#define IDirect3DRMFrame2_AddChild(p,a)                    (p)->lpVtbl->AddChild(p,a)
+#define IDirect3DRMFrame2_AddLight(p,a)                    (p)->lpVtbl->AddLight(p,a)
+#define IDirect3DRMFrame2_AddMoveCallback(p,a,b)           (p)->lpVtbl->AddMoveCallback(p,a,b)
+#define IDirect3DRMFrame2_AddTransform(p,a,b)              (p)->lpVtbl->AddTransform(p,a,b)
+#define IDirect3DRMFrame2_AddTranslation(p,a,b,c,d)        (p)->lpVtbl->AddTranslation(p,a,b,c,d)
+#define IDirect3DRMFrame2_AddScale(p,a,b,c,d)              (p)->lpVtbl->AddScale(p,a,b,c,d)
+#define IDirect3DRMFrame2_AddRotation(p,a,b,c,d,e)         (p)->lpVtbl->AddRotation(p,a,b,c,d,e)
+#define IDirect3DRMFrame2_AddVisual(p,a)                   (p)->lpVtbl->AddVisual(p,a)
+#define IDirect3DRMFrame2_GetChildren(p,a)                 (p)->lpVtbl->GetChildren(p,a)
+#define IDirect3DRMFrame2_GetColor(p)                      (p)->lpVtbl->GetColor(p)
+#define IDirect3DRMFrame2_GetLights(p,a)                   (p)->lpVtbl->GetLights(p,a)
+#define IDirect3DRMFrame2_GetMaterialMode(p)               (p)->lpVtbl->GetMaterialMode(p)
+#define IDirect3DRMFrame2_GetParent(p,a)                   (p)->lpVtbl->GetParent(p,a)
+#define IDirect3DRMFrame2_GetPosition(p,a,b)               (p)->lpVtbl->GetPosition(p,a,b)
+#define IDirect3DRMFrame2_GetRotation(p,a,b,c)             (p)->lpVtbl->GetRotation(p,a,b,c)
+#define IDirect3DRMFrame2_GetScene(p,a)                    (p)->lpVtbl->GetScene(p,a)
+#define IDirect3DRMFrame2_GetSortMode(p)                   (p)->lpVtbl->GetSortMode(p)
+#define IDirect3DRMFrame2_GetTexture(p,a)                  (p)->lpVtbl->GetTexture(p,a)
+#define IDirect3DRMFrame2_GetTransform(p,a)                (p)->lpVtbl->GetTransform(p,a)
+#define IDirect3DRMFrame2_GetVelocity(p,a,b,c)             (p)->lpVtbl->GetVelocity(p,a,b,c)
+#define IDirect3DRMFrame2_GetOrientation(p,a,b,c)          (p)->lpVtbl->GetOrientation(p,a,b,c)
+#define IDirect3DRMFrame2_GetVisuals(p,a)                  (p)->lpVtbl->GetVisuals(p,a)
+#define IDirect3DRMFrame2_GetTextureTopology(p,a,b)        (p)->lpVtbl->GetTextureTopology(p,a,b)
+#define IDirect3DRMFrame2_InverseTransform(p,a,b)          (p)->lpVtbl->InverseTransform(p,a,b)
+#define IDirect3DRMFrame2_Load(p,a,b,c,d,e)                (p)->lpVtbl->Load(p,a,b,c,d,e)
+#define IDirect3DRMFrame2_LookAt(p,a,b,c)                  (p)->lpVtbl->LookAt(p,a,b,c)
+#define IDirect3DRMFrame2_Move(p,a)                        (p)->lpVtbl->Move(p,a)
+#define IDirect3DRMFrame2_DeleteChild(p,a)                 (p)->lpVtbl->DeleteChild(p,a)
+#define IDirect3DRMFrame2_DeleteLight(p,a)                 (p)->lpVtbl->DeleteLight(p,a)
+#define IDirect3DRMFrame2_DeleteMoveCallback(p,a,b)        (p)->lpVtbl->DeleteMoveCallback(p,a,b)
+#define IDirect3DRMFrame2_DeleteVisual(p,a)                (p)->lpVtbl->DeleteVisual(p,a)
+#define IDirect3DRMFrame2_GetSceneBackground(p)            (p)->lpVtbl->GetSceneBackground(p)
+#define IDirect3DRMFrame2_GetSceneBackgroundDepth(p,a)     (p)->lpVtbl->GetSceneBackgroundDepth(p,a)
+#define IDirect3DRMFrame2_GetSceneFogColor(p)              (p)->lpVtbl->GetSceneFogColor(p)
+#define IDirect3DRMFrame2_GetSceneFogEnable(p)             (p)->lpVtbl->GetSceneFogEnable(p)
+#define IDirect3DRMFrame2_GetSceneFogMode(p)               (p)->lpVtbl->GetSceneFogMode(p)
+#define IDirect3DRMFrame2_GetSceneFogParams(p,a,b,c)       (p)->lpVtbl->GetSceneFogParams(p,a,b,c)
+#define IDirect3DRMFrame2_SetSceneBackground(p,a)          (p)->lpVtbl->SetSceneBackground(p,a)
+#define IDirect3DRMFrame2_SetSceneBackgroundRGB(p,a,b,c)   (p)->lpVtbl->SetSceneBackgroundRGB(p,a,b,c)
+#define IDirect3DRMFrame2_SetSceneBackgroundDepth(p,a)     (p)->lpVtbl->SetSceneBackgroundDepth(p,a)
+#define IDirect3DRMFrame2_SetSceneBackgroundImage(p,a)     (p)->lpVtbl->SetSceneBackgroundImage(p,a)
+#define IDirect3DRMFrame2_SetSceneFogEnable(p,a)           (p)->lpVtbl->SetSceneFogEnable(p,a)
+#define IDirect3DRMFrame2_SetSceneFogColor(p,a)            (p)->lpVtbl->SetSceneFogColor(p,a)
+#define IDirect3DRMFrame2_SetSceneFogMode(p,a)             (p)->lpVtbl->SetSceneFogMode(p,a)
+#define IDirect3DRMFrame2_SetSceneFogParams(p,a,b,c)       (p)->lpVtbl->SetSceneFogParams(p,a,b,c)
+#define IDirect3DRMFrame2_SetColor(p,a)                    (p)->lpVtbl->SetColor(p,a)
+#define IDirect3DRMFrame2_SetColorRGB(p,a,b,c)             (p)->lpVtbl->SetColorRGB(p,a,b,c)
+#define IDirect3DRMFrame2_GetZbufferMode(p)                (p)->lpVtbl->GetZbufferMode(p)
+#define IDirect3DRMFrame2_SetMaterialMode(p,a)             (p)->lpVtbl->SetMaterialMode(p,a)
+#define IDirect3DRMFrame2_SetOrientation(p,a,b,c,d,e,f,g)  (p)->lpVtbl->SetOrientation(p,a,b,c,d,e,f,g)
+#define IDirect3DRMFrame2_SetPosition(p,a,b,c,d)           (p)->lpVtbl->SetPosition(p,a,b,c,d)
+#define IDirect3DRMFrame2_SetRotation(p,a,b,c,d,e)         (p)->lpVtbl->SetRotation(p,a,b,c,d,e)
+#define IDirect3DRMFrame2_SetSortMode(p,a)                 (p)->lpVtbl->SetSortMode(p,a)
+#define IDirect3DRMFrame2_SetTexture(p,a)                  (p)->lpVtbl->SetTexture(p,a)
+#define IDirect3DRMFrame2_SetTextureTopology(p,a,b)        (p)->lpVtbl->SetTextureTopology(p,a,b)
+#define IDirect3DRMFrame2_SetVelocity(p,a,b,c,d,e)         (p)->lpVtbl->SetVelocity(p,a,b,c,d,e)
+#define IDirect3DRMFrame2_SetZbufferMode(p,a)              (p)->lpVtbl->SetZbufferMode(p,a)
+#define IDirect3DRMFrame2_Transform(p,a,b)                 (p)->lpVtbl->Transform(p,a,b)
+/*** IDirect3DRMFrame2 methods ***/
+#define IDirect3DRMFrame2_AddMoveCallback2(p,a,b,c)        (p)->lpVtbl->AddMoveCallback2(p,a,b,c)
+#define IDirect3DRMFrame2_GetBox(p,a)                      (p)->lpVtbl->GetBox(p,a)
+#define IDirect3DRMFrame2_GetBoxEnable(p)                  (p)->lpVtbl->GetBoxEnable(p)
+#define IDirect3DRMFrame2_GetAxes(p,a,b)                   (p)->lpVtbl->GetAxes(p,a,b)
+#define IDirect3DRMFrame2_GetMaterial(p,a)                 (p)->lpVtbl->GetMaterial(p,a)
+#define IDirect3DRMFrame2_GetInheritAxes(p,a,b)            (p)->lpVtbl->GetInheritAxes(p,a,b)
+#define IDirect3DRMFrame2_GetHierarchyBox(p,a)             (p)->lpVtbl->GetHierarchyBox(p,a)
+#define IDirect3DRMFrame2_SetBox(p,a)                      (p)->lpVtbl->SetBox(p,a)
+#define IDirect3DRMFrame2_SetBoxEnable(p,a)                (p)->lpVtbl->SetBoxEnable(p,a)
+#define IDirect3DRMFrame2_SetAxes(p,a,b,c,d,e,f)           (p)->lpVtbl->SetAxes(p,a,b,c,d,e,f)
+#define IDirect3DRMFrame2_SetInheritAxes(p,a)              (p)->lpVtbl->SetInheritAxes(p,a)
+#define IDirect3DRMFrame2_SetMaterial(p,a)                 (p)->lpVtbl->SetMaterial(p,a)
+#define IDirect3DRMFrame2_SetQuaternion(p,a,b)             (p)->lpVtbl->SetQuaternion(p,a,b)
+#define IDirect3DRMFrame2_RayPick(p,a,b,c,d)               (p)->lpVtbl->RayPick(p,a,b,c,d)
+#define IDirect3DRMFrame2_Save(p,a,b,c)                    (p)->lpVtbl->Save(p,a,b,c)
+#else
+/*** IUnknown methods ***/
+#define IDirect3DRMFrame2_QueryInterface(p,a,b)            (p)->QueryInterface(a,b)
+#define IDirect3DRMFrame2_AddRef(p)                        (p)->AddRef()
+#define IDirect3DRMFrame2_Release(p)                       (p)->Release()
+/*** IDirect3DRMObject methods ***/
+#define IDirect3DRMFrame2_Clone(p,a,b,c)                   (p)->Clone(a,b,c)
+#define IDirect3DRMFrame2_AddDestroyCallback(p,a,b)        (p)->AddDestroyCallback(a,b)
+#define IDirect3DRMFrame2_DeleteDestroyCallback(p,a,b)     (p)->DeleteDestroyCallback(a,b)
+#define IDirect3DRMFrame2_SetAppData(p,a)                  (p)->SetAppData(a)
+#define IDirect3DRMFrame2_GetAppData(p)                    (p)->GetAppData()
+#define IDirect3DRMFrame2_SetName(p,a)                     (p)->SetName(a)
+#define IDirect3DRMFrame2_GetName(p,a,b)                   (p)->GetName(a,b)
+#define IDirect3DRMFrame2_GetClassName(p,a,b)              (p)->GetClassName(a,b)
+/*** IDirect3DRMFrame methods ***/
+#define IDirect3DRMFrame2_AddChild(p,a)                    (p)->AddChild(a)
+#define IDirect3DRMFrame2_AddLight(p,a)                    (p)->AddLight(a)
+#define IDirect3DRMFrame2_AddMoveCallback(p,a,b)           (p)->AddMoveCallback(a,b)
+#define IDirect3DRMFrame2_AddTransform(p,a,b)              (p)->AddTransform(a,b)
+#define IDirect3DRMFrame2_AddTranslation(p,a,b,c,d)        (p)->AddTranslation(a,b,c,d)
+#define IDirect3DRMFrame2_AddScale(p,a,b,c,d)              (p)->AddScale(a,b,c,d)
+#define IDirect3DRMFrame2_AddRotation(p,a,b,c,d,e)         (p)->AddRotation(a,b,c,d,e)
+#define IDirect3DRMFrame2_AddVisual(p,a)                   (p)->AddVisual(a)
+#define IDirect3DRMFrame2_GetChildren(p,a)                 (p)->GetChildren(a)
+#define IDirect3DRMFrame2_GetColor(p)                      (p)->GetColor()
+#define IDirect3DRMFrame2_GetLights(p,a)                   (p)->GetLights(a)
+#define IDirect3DRMFrame2_GetMaterialMode(p)               (p)->GetMaterialMode()
+#define IDirect3DRMFrame2_GetParent(p,a)                   (p)->GetParent(a)
+#define IDirect3DRMFrame2_GetPosition(p,a,b)               (p)->GetPosition(a,b)
+#define IDirect3DRMFrame2_GetRotation(p,a,b,c)             (p)->GetRotation(a,b,c)
+#define IDirect3DRMFrame2_GetScene(p,a)                    (p)->GetScene(a)
+#define IDirect3DRMFrame2_GetSortMode(p)                   (p)->GetSortMode()
+#define IDirect3DRMFrame2_GetTexture(p,a)                  (p)->GetTexture(a)
+#define IDirect3DRMFrame2_GetTransform(p,a)                (p)->GetTransform(a)
+#define IDirect3DRMFrame2_GetVelocity(p,a,b,c)             (p)->GetVelocity(a,b,c)
+#define IDirect3DRMFrame2_GetOrientation(p,a,b,c)          (p)->GetOrientation(a,b,c)
+#define IDirect3DRMFrame2_GetVisuals(p,a)                  (p)->GetVisuals(a)
+#define IDirect3DRMFrame2_GetTextureTopology(p,a,b)        (p)->GetTextureTopology(a,b)
+#define IDirect3DRMFrame2_InverseTransform(p,a,b)          (p)->InverseTransform(a,b)
+#define IDirect3DRMFrame2_Load(p,a,b,c,d,e)                (p)->Load(a,b,c,d,e)
+#define IDirect3DRMFrame2_LookAt(p,a,b,c)                  (p)->LookAt(a,b,c)
+#define IDirect3DRMFrame2_Move(p,a)                        (p)->Move(a)
+#define IDirect3DRMFrame2_DeleteChild(p,a)                 (p)->DeleteChild(a)
+#define IDirect3DRMFrame2_DeleteLight(p,a)                 (p)->DeleteLight(a)
+#define IDirect3DRMFrame2_DeleteMoveCallback(p,a,b)        (p)->DeleteMoveCallback(a,b)
+#define IDirect3DRMFrame2_DeleteVisual(p,a)                (p)->DeleteVisual(a)
+#define IDirect3DRMFrame2_GetSceneBackground(p)            (p)->GetSceneBackground()
+#define IDirect3DRMFrame2_GetSceneBackgroundDepth(p,a)     (p)->GetSceneBackgroundDepth(a)
+#define IDirect3DRMFrame2_GetSceneFogColor(p)              (p)->GetSceneFogColor()
+#define IDirect3DRMFrame2_GetSceneFogEnable(p)             (p)->GetSceneFogEnable()
+#define IDirect3DRMFrame2_GetSceneFogMode(p)               (p)->GetSceneFogMode()
+#define IDirect3DRMFrame2_GetSceneFogParams(p,a,b,c)       (p)->GetSceneFogParams(a,b,c)
+#define IDirect3DRMFrame2_SetSceneBackground(p,a)          (p)->SetSceneBackground(a)
+#define IDirect3DRMFrame2_SetSceneBackgroundRGB(p,a,b,c)   (p)->SetSceneBackgroundRGB(a,b,c)
+#define IDirect3DRMFrame2_SetSceneBackgroundDepth(p,a)     (p)->SetSceneBackgroundDepth(a)
+#define IDirect3DRMFrame2_SetSceneBackgroundImage(p,a)     (p)->SetSceneBackgroundImage(a)
+#define IDirect3DRMFrame2_SetSceneFogEnable(p,a)           (p)->SetSceneFogEnable(a)
+#define IDirect3DRMFrame2_SetSceneFogColor(p,a)            (p)->SetSceneFogColor(a)
+#define IDirect3DRMFrame2_SetSceneFogMode(p,a)             (p)->SetSceneFogMode(a)
+#define IDirect3DRMFrame2_SetSceneFogParams(p,a,b,c)       (p)->SetSceneFogParams(a,b,c)
+#define IDirect3DRMFrame2_SetColor(p,a)                    (p)->SetColor(a)
+#define IDirect3DRMFrame2_SetColorRGB(p,a,b,c)             (p)->SetColorRGB(a,b,c)
+#define IDirect3DRMFrame2_GetZbufferMode(p)                (p)->GetZbufferMode()
+#define IDirect3DRMFrame2_SetMaterialMode(p,a)             (p)->SetMaterialMode(a)
+#define IDirect3DRMFrame2_SetOrientation(p,a,b,c,d,e,f,g)  (p)->SetOrientation(a,b,c,d,e,f,g)
+#define IDirect3DRMFrame2_SetPosition(p,a,b,c,d)           (p)->SetPosition(a,b,c,d)
+#define IDirect3DRMFrame2_SetRotation(p,a,b,c,d,e)         (p)->SetRotation(a,b,c,d,e)
+#define IDirect3DRMFrame2_SetSortMode(p,a)                 (p)->SetSortMode(a)
+#define IDirect3DRMFrame2_SetTexture(p,a)                  (p)->SetTexture(a)
+#define IDirect3DRMFrame2_SetTextureTopology(p,a,b)        (p)->SetTextureTopology(a,b)
+#define IDirect3DRMFrame2_SetVelocity(p,a,b,c,d,e)         (p)->SetVelocity(a,b,c,d,e)
+#define IDirect3DRMFrame2_SetZbufferMode(p,a)              (p)->SetZbufferMode(a)
+#define IDirect3DRMFrame2_Transform(p,a,b)                 (p)->Transform(a,b)
+/*** IDirect3DRMFrame2 methods ***/
+#define IDirect3DRMFrame2_AddMoveCallback2(p,a,b,c)        (p)->AddMoveCallback2(a,b,c)
+#define IDirect3DRMFrame2_GetBox(p,a)                      (p)->GetBox(a)
+#define IDirect3DRMFrame2_GetBoxEnable(p)                  (p)->GetBoxEnable()
+#define IDirect3DRMFrame2_GetAxes(p,a,b)                   (p)->GetAxes(a,b)
+#define IDirect3DRMFrame2_GetMaterial(p,a)                 (p)->GetMaterial(a)
+#define IDirect3DRMFrame2_GetInheritAxes(p,a,b)            (p)->GetInheritAxes(a,b)
+#define IDirect3DRMFrame2_GetHierarchyBox(p,a)             (p)->GetHierarchyBox(a)
+#define IDirect3DRMFrame2_SetBox(p,a)                      (p)->SetBox(a)
+#define IDirect3DRMFrame2_SetBoxEnable(p,a)                (p)->SetBoxEnable(a)
+#define IDirect3DRMFrame2_SetAxes(p,a,b,c,d,e,f)           (p)->SetAxes(a,b,c,d,e,f)
+#define IDirect3DRMFrame2_SetInheritAxes(p,a)              (p)->SetInheritAxes(a)
+#define IDirect3DRMFrame2_SetMaterial(p,a)                 (p)->SetMaterial(a)
+#define IDirect3DRMFrame2_SetQuaternion(p,a,b)             (p)->SetQuaternion(a,b)
+#define IDirect3DRMFrame2_RayPick(p,a,b,c,d)               (p)->RayPick(a,b,c,d)
+#define IDirect3DRMFrame2_Save(p,a,b,c)                    (p)->Save(a,b,c)
+#endif
+
+/*****************************************************************************
+ * IDirect3DRMFrame3 interface
+ */
+#define INTERFACE IDirect3DRMFrame3
+DECLARE_INTERFACE_(IDirect3DRMFrame3,IDirect3DRMVisual)
+{
+    /*** IUnknown methods ***/
+    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
+    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+    STDMETHOD_(ULONG,Release)(THIS) PURE;
+    /*** IDirect3DRMObject methods ***/
+    STDMETHOD(Clone)(THIS_ LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj) PURE;
+    STDMETHOD(AddDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK, LPVOID argument) PURE;
+    STDMETHOD(DeleteDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK, LPVOID argument) PURE;
+    STDMETHOD(SetAppData)(THIS_ DWORD data) PURE;
+    STDMETHOD_(DWORD, GetAppData)(THIS) PURE;
+    STDMETHOD(SetName)(THIS_ LPCSTR) PURE;
+    STDMETHOD(GetName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE;
+    STDMETHOD(GetClassName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE;
+    /*** IDirect3DRMFrame3 methods ***/
+    STDMETHOD(AddChild)(THIS_ LPDIRECT3DRMFRAME3 child) PURE;
+    STDMETHOD(AddLight)(THIS_ LPDIRECT3DRMLIGHT) PURE;
+    STDMETHOD(AddMoveCallback)(THIS_ D3DRMFRAME3MOVECALLBACK, VOID *arg, DWORD flags) PURE;
+    STDMETHOD(AddTranslation)(THIS_ D3DRMCOMBINETYPE, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE;
+    STDMETHOD(AddScale)(THIS_ D3DRMCOMBINETYPE, D3DVALUE sx, D3DVALUE sy, D3DVALUE sz) PURE;
+    STDMETHOD(AddRotation)(THIS_ D3DRMCOMBINETYPE, D3DVALUE x, D3DVALUE y, D3DVALUE z, D3DVALUE theta) PURE;
+    STDMETHOD(AddVisual)(THIS_ LPUNKNOWN) PURE;
+    STDMETHOD(GetChildren)(THIS_ LPDIRECT3DRMFRAMEARRAY *children) PURE;
+    STDMETHOD_(D3DCOLOR, GetColor)(THIS) PURE;
+    STDMETHOD(GetLights)(THIS_ LPDIRECT3DRMLIGHTARRAY *lights) PURE;
+    STDMETHOD_(D3DRMMATERIALMODE, GetMaterialMode)(THIS) PURE;
+    STDMETHOD(GetParent)(THIS_ LPDIRECT3DRMFRAME3 *) PURE;
+    STDMETHOD(GetPosition)(THIS_ LPDIRECT3DRMFRAME3 reference, LPD3DVECTOR return_position) PURE;
+    STDMETHOD(GetRotation)(THIS_ LPDIRECT3DRMFRAME3 reference, LPD3DVECTOR axis, LPD3DVALUE return_theta) PURE;
+    STDMETHOD(GetScene)(THIS_ LPDIRECT3DRMFRAME3 *) PURE;
+    STDMETHOD_(D3DRMSORTMODE, GetSortMode)(THIS) PURE;
+    STDMETHOD(GetTexture)(THIS_ LPDIRECT3DRMTEXTURE3 *) PURE;
+    STDMETHOD(GetTransform)(THIS_ LPDIRECT3DRMFRAME3 reference, D3DRMMATRIX4D rmMatrix) PURE;
+    STDMETHOD(GetVelocity)(THIS_ LPDIRECT3DRMFRAME3 reference, LPD3DVECTOR return_velocity,
+        BOOL with_rotation) PURE;
+    STDMETHOD(GetOrientation)(THIS_ LPDIRECT3DRMFRAME3 reference, LPD3DVECTOR dir, LPD3DVECTOR up) PURE;
+    STDMETHOD(GetVisuals)(THIS_ LPDWORD pCount, LPUNKNOWN *) PURE;
+    STDMETHOD(InverseTransform)(THIS_ D3DVECTOR *d, D3DVECTOR *s) PURE;
+    STDMETHOD(Load)(THIS_ LPVOID filename, LPVOID name, D3DRMLOADOPTIONS loadflags,
+        D3DRMLOADTEXTURE3CALLBACK, LPVOID pArg) PURE;
+    STDMETHOD(LookAt)(THIS_ LPDIRECT3DRMFRAME3 target, LPDIRECT3DRMFRAME3 reference, D3DRMFRAMECONSTRAINT) PURE;
+    STDMETHOD(Move)(THIS_ D3DVALUE delta) PURE;
+    STDMETHOD(DeleteChild)(THIS_ LPDIRECT3DRMFRAME3) PURE;
+    STDMETHOD(DeleteLight)(THIS_ LPDIRECT3DRMLIGHT) PURE;
+    STDMETHOD(DeleteMoveCallback)(THIS_ D3DRMFRAME3MOVECALLBACK, VOID *arg) PURE;
+    STDMETHOD(DeleteVisual)(THIS_ LPUNKNOWN) PURE;
+    STDMETHOD_(D3DCOLOR, GetSceneBackground)(THIS) PURE;
+    STDMETHOD(GetSceneBackgroundDepth)(THIS_ LPDIRECTDRAWSURFACE *) PURE;
+    STDMETHOD_(D3DCOLOR, GetSceneFogColor)(THIS) PURE;
+    STDMETHOD_(BOOL, GetSceneFogEnable)(THIS) PURE;
+    STDMETHOD_(D3DRMFOGMODE, GetSceneFogMode)(THIS) PURE;
+    STDMETHOD(GetSceneFogParams)(THIS_ D3DVALUE *return_start, D3DVALUE *return_end,
+        D3DVALUE *return_density) PURE;
+    STDMETHOD(SetSceneBackground)(THIS_ D3DCOLOR) PURE;
+    STDMETHOD(SetSceneBackgroundRGB)(THIS_ D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE;
+    STDMETHOD(SetSceneBackgroundDepth)(THIS_ LPDIRECTDRAWSURFACE) PURE;
+    STDMETHOD(SetSceneBackgroundImage)(THIS_ LPDIRECT3DRMTEXTURE3) PURE;
+    STDMETHOD(SetSceneFogEnable)(THIS_ BOOL) PURE;
+    STDMETHOD(SetSceneFogColor)(THIS_ D3DCOLOR) PURE;
+    STDMETHOD(SetSceneFogMode)(THIS_ D3DRMFOGMODE) PURE;
+    STDMETHOD(SetSceneFogParams)(THIS_ D3DVALUE start, D3DVALUE end, D3DVALUE density) PURE;
+    STDMETHOD(SetColor)(THIS_ D3DCOLOR) PURE;
+    STDMETHOD(SetColorRGB)(THIS_ D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE;
+    STDMETHOD_(D3DRMZBUFFERMODE, GetZbufferMode)(THIS) PURE;
+    STDMETHOD(SetMaterialMode)(THIS_ D3DRMMATERIALMODE) PURE;
+    STDMETHOD(SetOrientation)(THIS_ LPDIRECT3DRMFRAME3 reference, D3DVALUE dx, D3DVALUE dy, D3DVALUE dz,
+        D3DVALUE ux, D3DVALUE uy, D3DVALUE uz) PURE;
+    STDMETHOD(SetPosition)(THIS_ LPDIRECT3DRMFRAME3 reference, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE;
+    STDMETHOD(SetRotation)(THIS_ LPDIRECT3DRMFRAME3 reference, D3DVALUE x, D3DVALUE y, D3DVALUE z,
+        D3DVALUE theta) PURE;
+    STDMETHOD(SetSortMode)(THIS_ D3DRMSORTMODE) PURE;
+    STDMETHOD(SetTexture)(THIS_ LPDIRECT3DRMTEXTURE3) PURE;
+    STDMETHOD(SetVelocity)(THIS_ LPDIRECT3DRMFRAME3 reference, D3DVALUE x, D3DVALUE y, D3DVALUE z,
+        BOOL with_rotation) PURE;
+    STDMETHOD(SetZbufferMode)(THIS_ D3DRMZBUFFERMODE) PURE;
+    STDMETHOD(Transform)(THIS_ D3DVECTOR *d, D3DVECTOR *s) PURE;
+    STDMETHOD(GetBox)(THIS_ LPD3DRMBOX) PURE;
+    STDMETHOD_(BOOL, GetBoxEnable)(THIS) PURE;
+    STDMETHOD(GetAxes)(THIS_ LPD3DVECTOR dir, LPD3DVECTOR up);
+    STDMETHOD(GetMaterial)(THIS_ LPDIRECT3DRMMATERIAL2 *) PURE;
+    STDMETHOD_(BOOL, GetInheritAxes)(THIS);
+    STDMETHOD(GetHierarchyBox)(THIS_ LPD3DRMBOX) PURE;
+    STDMETHOD(SetBox)(THIS_ LPD3DRMBOX) PURE;
+    STDMETHOD(SetBoxEnable)(THIS_ BOOL) PURE;
+    STDMETHOD(SetAxes)(THIS_ D3DVALUE dx, D3DVALUE dy, D3DVALUE dz, D3DVALUE ux, D3DVALUE uy, D3DVALUE uz);
+    STDMETHOD(SetInheritAxes)(THIS_ BOOL inherit_from_parent);
+    STDMETHOD(SetMaterial)(THIS_ LPDIRECT3DRMMATERIAL2) PURE;
+    STDMETHOD(SetQuaternion)(THIS_ LPDIRECT3DRMFRAME3 reference, D3DRMQUATERNION *q) PURE;
+    STDMETHOD(RayPick)(THIS_ LPDIRECT3DRMFRAME3 reference, LPD3DRMRAY ray, DWORD flags,
+        LPDIRECT3DRMPICKED2ARRAY *return_visuals) PURE;
+    STDMETHOD(Save)(THIS_ LPCSTR filename, D3DRMXOFFORMAT d3dFormat, D3DRMSAVEOPTIONS d3dSaveFlags);
+    STDMETHOD(TransformVectors)(THIS_ LPDIRECT3DRMFRAME3 reference, DWORD NumVectors,
+        LPD3DVECTOR pDstVectors, LPD3DVECTOR pSrcVectors) PURE;
+    STDMETHOD(InverseTransformVectors)(THIS_ LPDIRECT3DRMFRAME3 reference, DWORD NumVectors,
+        LPD3DVECTOR pDstVectors, LPD3DVECTOR pSrcVectors) PURE;
+    STDMETHOD(SetTraversalOptions)(THIS_ DWORD flags) PURE;
+    STDMETHOD(GetTraversalOptions)(THIS_ LPDWORD pFlags) PURE;
+    STDMETHOD(SetSceneFogMethod)(THIS_ DWORD flags) PURE;
+    STDMETHOD(GetSceneFogMethod)(THIS_ LPDWORD pFlags) PURE;
+    STDMETHOD(SetMaterialOverride)(THIS_ LPD3DRMMATERIALOVERRIDE) PURE;
+    STDMETHOD(GetMaterialOverride)(THIS_ LPD3DRMMATERIALOVERRIDE) PURE;
+};
+#undef INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IDirect3DRMFrame3_QueryInterface(p,a,b)              (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DRMFrame3_AddRef(p)                          (p)->lpVtbl->AddRef(p)
+#define IDirect3DRMFrame3_Release(p)                         (p)->lpVtbl->Release(p)
+/*** IDirect3DRMObject methods ***/
+#define IDirect3DRMFrame3_Clone(p,a,b,c)                     (p)->lpVtbl->Clone(p,a,b,c)
+#define IDirect3DRMFrame3_AddDestroyCallback(p,a,b)          (p)->lpVtbl->AddDestroyCallback(p,a,b)
+#define IDirect3DRMFrame3_DeleteDestroyCallback(p,a,b)       (p)->lpVtbl->DeleteDestroyCallback(p,a,b)
+#define IDirect3DRMFrame3_SetAppData(p,a)                    (p)->lpVtbl->SetAppData(p,a)
+#define IDirect3DRMFrame3_GetAppData(p)                      (p)->lpVtbl->GetAppData(p)
+#define IDirect3DRMFrame3_SetName(p,a)                       (p)->lpVtbl->SetName(p,a)
+#define IDirect3DRMFrame3_GetName(p,a,b)                     (p)->lpVtbl->GetName(p,a,b)
+#define IDirect3DRMFrame3_GetClassName(p,a,b)                (p)->lpVtbl->GetClassName(p,a,b)
+/*** IDirect3DRMFrame3 methods ***/
+#define IDirect3DRMFrame3_AddChild(p,a)                      (p)->lpVtbl->AddChild(p,a)
+#define IDirect3DRMFrame3_AddLight(p,a)                      (p)->lpVtbl->AddLight(p,a)
+#define IDirect3DRMFrame3_AddMoveCallback(p,a,b,c)           (p)->lpVtbl->AddMoveCallback(p,a,b,c)
+#define IDirect3DRMFrame3_AddTransform(p,a,b)                (p)->lpVtbl->AddTransform(p,a,b)
+#define IDirect3DRMFrame3_AddTranslation(p,a,b,c,d)          (p)->lpVtbl->AddTranslation(p,a,b,c,d)
+#define IDirect3DRMFrame3_AddScale(p,a,b,c,d)                (p)->lpVtbl->AddScale(p,a,b,c,d)
+#define IDirect3DRMFrame3_AddRotation(p,a,b,c,d,e)           (p)->lpVtbl->AddRotation(p,a,b,c,d,e)
+#define IDirect3DRMFrame3_AddVisual(p,a)                     (p)->lpVtbl->AddVisual(p,a)
+#define IDirect3DRMFrame3_GetChildren(p,a)                   (p)->lpVtbl->GetChildren(p,a)
+#define IDirect3DRMFrame3_GetColor(p)                        (p)->lpVtbl->GetColor(p)
+#define IDirect3DRMFrame3_GetLights(p,a)                     (p)->lpVtbl->GetLights(p,a)
+#define IDirect3DRMFrame3_GetMaterialMode(p)                 (p)->lpVtbl->GetMaterialMode(p)
+#define IDirect3DRMFrame3_GetParent(p,a)                     (p)->lpVtbl->GetParent(p,a)
+#define IDirect3DRMFrame3_GetPosition(p,a,b)                 (p)->lpVtbl->GetPosition(p,a,b)
+#define IDirect3DRMFrame3_GetRotation(p,a,b,c)               (p)->lpVtbl->GetRotation(p,a,b,c)
+#define IDirect3DRMFrame3_GetScene(p,a)                      (p)->lpVtbl->GetScene(p,a)
+#define IDirect3DRMFrame3_GetSortMode(p)                     (p)->lpVtbl->GetSortMode(p)
+#define IDirect3DRMFrame3_GetTexture(p,a)                    (p)->lpVtbl->GetTexture(p,a)
+#define IDirect3DRMFrame3_GetTransform(p,a,b)                (p)->lpVtbl->GetTransform(p,a,b)
+#define IDirect3DRMFrame3_GetVelocity(p,a,b,c)               (p)->lpVtbl->GetVelocity(p,a,b,c)
+#define IDirect3DRMFrame3_GetOrientation(p,a,b,c)            (p)->lpVtbl->GetOrientation(p,a,b,c)
+#define IDirect3DRMFrame3_GetVisuals(p,a,b)                  (p)->lpVtbl->GetVisuals(p,a,b)
+#define IDirect3DRMFrame3_InverseTransform(p,a,b)            (p)->lpVtbl->InverseTransform(p,a,b)
+#define IDirect3DRMFrame3_Load(p,a,b,c,d,e)                  (p)->lpVtbl->Load(p,a,b,c,d,e)
+#define IDirect3DRMFrame3_LookAt(p,a,b,c)                    (p)->lpVtbl->LookAt(p,a,b,c)
+#define IDirect3DRMFrame3_Move(p,a)                          (p)->lpVtbl->Move(p,a)
+#define IDirect3DRMFrame3_DeleteChild(p,a)                   (p)->lpVtbl->DeleteChild(p,a)
+#define IDirect3DRMFrame3_DeleteLight(p,a)                   (p)->lpVtbl->DeleteLight(p,a)
+#define IDirect3DRMFrame3_DeleteMoveCallback(p,a,b)          (p)->lpVtbl->DeleteMoveCallback(p,a,b)
+#define IDirect3DRMFrame3_DeleteVisual(p,a)                  (p)->lpVtbl->DeleteVisual(p,a)
+#define IDirect3DRMFrame3_GetSceneBackground(p)              (p)->lpVtbl->GetSceneBackground(p)
+#define IDirect3DRMFrame3_GetSceneBackgroundDepth(p,a)       (p)->lpVtbl->GetSceneBackgroundDepth(p,a)
+#define IDirect3DRMFrame3_GetSceneFogColor(p)                (p)->lpVtbl->GetSceneFogColor(p)
+#define IDirect3DRMFrame3_GetSceneFogEnable(p)               (p)->lpVtbl->GetSceneFogEnable(p)
+#define IDirect3DRMFrame3_GetSceneFogMode(p)                 (p)->lpVtbl->GetSceneFogMode(p)
+#define IDirect3DRMFrame3_GetSceneFogParams(p,a,b,c)         (p)->lpVtbl->GetSceneFogParams(p,a,b,c)
+#define IDirect3DRMFrame3_SetSceneBackground(p,a)            (p)->lpVtbl->SetSceneBackground(p,a)
+#define IDirect3DRMFrame3_SetSceneBackgroundRGB(p,a,b,c)     (p)->lpVtbl->SetSceneBackgroundRGB(p,a,b,c)
+#define IDirect3DRMFrame3_SetSceneBackgroundDepth(p,a)       (p)->lpVtbl->SetSceneBackgroundDepth(p,a)
+#define IDirect3DRMFrame3_SetSceneBackgroundImage(p,a)       (p)->lpVtbl->SetSceneBackgroundImage(p,a)
+#define IDirect3DRMFrame3_SetSceneFogEnable(p,a)             (p)->lpVtbl->SetSceneFogEnable(p,a)
+#define IDirect3DRMFrame3_SetSceneFogColor(p,a)              (p)->lpVtbl->SetSceneFogColor(p,a)
+#define IDirect3DRMFrame3_SetSceneFogMode(p,a)               (p)->lpVtbl->SetSceneFogMode(p,a)
+#define IDirect3DRMFrame3_SetSceneFogParams(p,a,b,c)         (p)->lpVtbl->SetSceneFogParams(p,a,b,c)
+#define IDirect3DRMFrame3_SetColor(p,a)                      (p)->lpVtbl->SetColor(p,a)
+#define IDirect3DRMFrame3_SetColorRGB(p,a,b,c)               (p)->lpVtbl->SetColorRGB(p,a,b,c)
+#define IDirect3DRMFrame3_GetZbufferMode(p)                  (p)->lpVtbl->GetZbufferMode(p)
+#define IDirect3DRMFrame3_SetMaterialMode(p,a)               (p)->lpVtbl->SetMaterialMode(p,a)
+#define IDirect3DRMFrame3_SetOrientation(p,a,b,c,d,e,f,g)    (p)->lpVtbl->SetOrientation(p,a,b,c,d,e,f,g)
+#define IDirect3DRMFrame3_SetPosition(p,a,b,c,d)             (p)->lpVtbl->SetPosition(p,a,b,c,d)
+#define IDirect3DRMFrame3_SetRotation(p,a,b,c,d,e)           (p)->lpVtbl->SetRotation(p,a,b,c,d,e)
+#define IDirect3DRMFrame3_SetSortMode(p,a)                   (p)->lpVtbl->SetSortMode(p,a)
+#define IDirect3DRMFrame3_SetTexture(p,a)                    (p)->lpVtbl->SetTexture(p,a)
+#define IDirect3DRMFrame3_SetVelocity(p,a,b,c,d,e)           (p)->lpVtbl->SetVelocity(p,a,b,c,d,e)
+#define IDirect3DRMFrame3_SetZbufferMode(p,a)                (p)->lpVtbl->SetZbufferMode(p,a)
+#define IDirect3DRMFrame3_Transform(p,a,b)                   (p)->lpVtbl->Transform(p,a,b)
+#define IDirect3DRMFrame3_GetBox(p,a)                        (p)->lpVtbl->GetBox(p,a)
+#define IDirect3DRMFrame3_GetBoxEnable(p)                    (p)->lpVtbl->GetBoxEnable(p)
+#define IDirect3DRMFrame3_GetAxes(p,a,b)                     (p)->lpVtbl->GetAxes(p,a,b)
+#define IDirect3DRMFrame3_GetMaterial(p,a)                   (p)->lpVtbl->GetMaterial(p,a)
+#define IDirect3DRMFrame3_GetInheritAxes(p)                  (p)->lpVtbl->GetInheritAxes(p)
+#define IDirect3DRMFrame3_GetHierarchyBox(p,a)               (p)->lpVtbl->GetHierarchyBox(p,a)
+#define IDirect3DRMFrame3_SetBox(p,a)                        (p)->lpVtbl->SetBox(p,a)
+#define IDirect3DRMFrame3_SetBoxEnable(p,a)                  (p)->lpVtbl->SetBoxEnable(p,a)
+#define IDirect3DRMFrame3_SetAxes(p,a,b,c,d,e,f)             (p)->lpVtbl->SetAxes(p,a,b,c,d,e,f)
+#define IDirect3DRMFrame3_SetInheritAxes(p,a)                (p)->lpVtbl->SetInheritAxes(p,a)
+#define IDirect3DRMFrame3_SetMaterial(p,a)                   (p)->lpVtbl->SetMaterial(p,a)
+#define IDirect3DRMFrame3_SetQuaternion(p,a,b)               (p)->lpVtbl->SetQuaternion(p,a,b)
+#define IDirect3DRMFrame3_RayPick(p,a,b,c,d)                 (p)->lpVtbl->RayPick(p,a,b,c,d)
+#define IDirect3DRMFrame3_Save(p,a,b,c)                      (p)->lpVtbl->Save(p,a,b,c)
+#define IDirect3DRMFrame3_TransformVectors(p,a,b,c,d)        (p)->lpVtbl->TransformVectors(p,a,b,c,d)
+#define IDirect3DRMFrame3_InverseTransformVectors(p,a,b,c,d) (p)->lpVtbl->InverseTransformVectors(p,a,b,c,d)
+#define IDirect3DRMFrame3_SetTraversalOptions(p,a)           (p)->lpVtbl->SetTraversalOptions(p,a)
+#define IDirect3DRMFrame3_GetTraversalOptions(p,a)           (p)->lpVtbl->GetTraversalOptions(p,a)
+#define IDirect3DRMFrame3_SetSceneFogMethod(p,a)             (p)->lpVtbl->SetSceneFogMethod(p,a)
+#define IDirect3DRMFrame3_GetSceneFogMethod(p,a)             (p)->lpVtbl->GetSceneFogMethod(p,a)
+#define IDirect3DRMFrame3_SetMaterialOverride(p,a)           (p)->lpVtbl->SetMaterialOverride(p,a)
+#define IDirect3DRMFrame3_GetMaterialOverride(p,a)           (p)->lpVtbl->GetMaterialOverride(p,a)
+#else
+/*** IUnknown methods ***/
+#define IDirect3DRMFrame3_QueryInterface(p,a,b)              (p)->QueryInterface(a,b)
+#define IDirect3DRMFrame3_AddRef(p)                          (p)->AddRef()
+#define IDirect3DRMFrame3_Release(p)                         (p)->Release()
+/*** IDirect3DRMObject methods ***/
+#define IDirect3DRMFrame3_Clone(p,a,b,c)                     (p)->Clone(a,b,c)
+#define IDirect3DRMFrame3_AddDestroyCallback(p,a,b)          (p)->AddDestroyCallback(a,b)
+#define IDirect3DRMFrame3_DeleteDestroyCallback(p,a,b)       (p)->DeleteDestroyCallback(a,b)
+#define IDirect3DRMFrame3_SetAppData(p,a)                    (p)->SetAppData(a)
+#define IDirect3DRMFrame3_GetAppData(p)                      (p)->GetAppData()
+#define IDirect3DRMFrame3_SetName(p,a)                       (p)->SetName(a)
+#define IDirect3DRMFrame3_GetName(p,a,b)                     (p)->GetName(a,b)
+#define IDirect3DRMFrame3_GetClassName(p,a,b)                (p)->GetClassName(a,b)
+/*** IDirect3DRMFrame3 methods ***/
+#define IDirect3DRMFrame3_AddChild(p,a)                      (p)->AddChild(a)
+#define IDirect3DRMFrame3_AddLight(p,a)                      (p)->AddLight(a)
+#define IDirect3DRMFrame3_AddMoveCallback(p,a,b,c)           (p)->AddMoveCallback(a,b,c)
+#define IDirect3DRMFrame3_AddTransform(p,a,b)                (p)->AddTransform(a,b)
+#define IDirect3DRMFrame3_AddTranslation(p,a,b,c,d)          (p)->AddTranslation(a,b,c,d)
+#define IDirect3DRMFrame3_AddScale(p,a,b,c,d)                (p)->AddScale(a,b,c,d)
+#define IDirect3DRMFrame3_AddRotation(p,a,b,c,d,e)           (p)->AddRotation(a,b,c,d,e)
+#define IDirect3DRMFrame3_AddVisual(p,a)                     (p)->AddVisual(a)
+#define IDirect3DRMFrame3_GetChildren(p,a)                   (p)->GetChildren(a)
+#define IDirect3DRMFrame3_GetColor(p)                        (p)->GetColor()
+#define IDirect3DRMFrame3_GetLights(p,a)                     (p)->GetLights(a)
+#define IDirect3DRMFrame3_GetMaterialMode(p)                 (p)->GetMaterialMode()
+#define IDirect3DRMFrame3_GetParent(p,a)                     (p)->GetParent(a)
+#define IDirect3DRMFrame3_GetPosition(p,a,b)                 (p)->GetPosition(a,b)
+#define IDirect3DRMFrame3_GetRotation(p,a,b,c)               (p)->GetRotation(a,b,c)
+#define IDirect3DRMFrame3_GetScene(p,a)                      (p)->GetScene(a)
+#define IDirect3DRMFrame3_GetSortMode(p)                     (p)->GetSortMode()
+#define IDirect3DRMFrame3_GetTexture(p,a)                    (p)->GetTexture(a)
+#define IDirect3DRMFrame3_GetTransform(p,a,b)                (p)->GetTransform(a,b)
+#define IDirect3DRMFrame3_GetVelocity(p,a,b,c)               (p)->GetVelocity(a,b,c)
+#define IDirect3DRMFrame3_GetOrientation(p,a,b,c)            (p)->GetOrientation(a,b,c)
+#define IDirect3DRMFrame3_GetVisuals(p,a,b)                  (p)->GetVisuals(a,b)
+#define IDirect3DRMFrame3_InverseTransform(p,a,b)            (p)->InverseTransform(a,b)
+#define IDirect3DRMFrame3_Load(p,a,b,c,d,e)                  (p)->Load(a,b,c,d,e)
+#define IDirect3DRMFrame3_LookAt(p,a,b,c)                    (p)->LookAt(a,b,c)
+#define IDirect3DRMFrame3_Move(p,a)                          (p)->Move(a)
+#define IDirect3DRMFrame3_DeleteChild(p,a)                   (p)->DeleteChild(a)
+#define IDirect3DRMFrame3_DeleteLight(p,a)                   (p)->DeleteLight(a)
+#define IDirect3DRMFrame3_DeleteMoveCallback(p,a,b)          (p)->DeleteMoveCallback(a,b)
+#define IDirect3DRMFrame3_DeleteVisual(p,a)                  (p)->DeleteVisual(a)
+#define IDirect3DRMFrame3_GetSceneBackground(p)              (p)->GetSceneBackground()
+#define IDirect3DRMFrame3_GetSceneBackgroundDepth(p,a)       (p)->GetSceneBackgroundDepth(a)
+#define IDirect3DRMFrame3_GetSceneFogColor(p)                (p)->GetSceneFogColor()
+#define IDirect3DRMFrame3_GetSceneFogEnable(p)               (p)->GetSceneFogEnable()
+#define IDirect3DRMFrame3_GetSceneFogMode(p)                 (p)->GetSceneFogMode()
+#define IDirect3DRMFrame3_GetSceneFogParams(p,a,b,c)         (p)->GetSceneFogParams(a,b,c)
+#define IDirect3DRMFrame3_SetSceneBackground(p,a)            (p)->SetSceneBackground(a)
+#define IDirect3DRMFrame3_SetSceneBackgroundRGB(p,a,b,c)     (p)->SetSceneBackgroundRGB(a,b,c)
+#define IDirect3DRMFrame3_SetSceneBackgroundDepth(p,a)       (p)->SetSceneBackgroundDepth(a)
+#define IDirect3DRMFrame3_SetSceneBackgroundImage(p,a)       (p)->SetSceneBackgroundImage(a)
+#define IDirect3DRMFrame3_SetSceneFogEnable(p,a)             (p)->SetSceneFogEnable(a)
+#define IDirect3DRMFrame3_SetSceneFogColor(p,a)              (p)->SetSceneFogColor(a)
+#define IDirect3DRMFrame3_SetSceneFogMode(p,a)               (p)->SetSceneFogMode(a)
+#define IDirect3DRMFrame3_SetSceneFogParams(p,a,b,c)         (p)->SetSceneFogParams(a,b,c)
+#define IDirect3DRMFrame3_SetColor(p,a)                      (p)->SetColor(a)
+#define IDirect3DRMFrame3_SetColorRGB(p,a,b,c)               (p)->SetColorRGB(a,b,c)
+#define IDirect3DRMFrame3_GetZbufferMode(p)                  (p)->GetZbufferMode()
+#define IDirect3DRMFrame3_SetMaterialMode(p,a)               (p)->SetMaterialMode(a)
+#define IDirect3DRMFrame3_SetOrientation(p,a,b,c,d,e,f,g)    (p)->SetOrientation(a,b,c,d,e,f,g)
+#define IDirect3DRMFrame3_SetPosition(p,a,b,c,d)             (p)->SetPosition(a,b,c,d)
+#define IDirect3DRMFrame3_SetRotation(p,a,b,c,d,e)           (p)->SetRotation(a,b,c,d,e)
+#define IDirect3DRMFrame3_SetSortMode(p,a)                   (p)->SetSortMode(a)
+#define IDirect3DRMFrame3_SetTexture(p,a)                    (p)->SetTexture(a)
+#define IDirect3DRMFrame3_SetVelocity(p,a,b,c,d,e)           (p)->SetVelocity(a,b,c,d,e)
+#define IDirect3DRMFrame3_SetZbufferMode(p,a)                (p)->SetZbufferMode(a)
+#define IDirect3DRMFrame3_Transform(p,a,b)                   (p)->Transform(a,b)
+#define IDirect3DRMFrame3_GetBox(p,a)                        (p)->GetBox(a)
+#define IDirect3DRMFrame3_GetBoxEnable(p)                    (p)->GetBoxEnable()
+#define IDirect3DRMFrame3_GetAxes(p,a,b)                     (p)->GetAxes(a,b)
+#define IDirect3DRMFrame3_GetMaterial(p,a)                   (p)->GetMaterial(a)
+#define IDirect3DRMFrame3_GetInheritAxes(p)                  (p)->GetInheritAxes()
+#define IDirect3DRMFrame3_GetHierarchyBox(p,a)               (p)->GetHierarchyBox(a)
+#define IDirect3DRMFrame3_SetBox(p,a)                        (p)->SetBox(a)
+#define IDirect3DRMFrame3_SetBoxEnable(p,a)                  (p)->SetBoxEnable(a)
+#define IDirect3DRMFrame3_SetAxes(p,a,b,c,d,e,f)             (p)->SetAxes(a,b,c,d,e,f)
+#define IDirect3DRMFrame3_SetInheritAxes(p,a)                (p)->SetInheritAxes(a)
+#define IDirect3DRMFrame3_SetMaterial(p,a)                   (p)->SetMaterial(a)
+#define IDirect3DRMFrame3_SetQuaternion(p,a,b)               (p)->SetQuaternion(a,b)
+#define IDirect3DRMFrame3_RayPick(p,a,b,c,d)                 (p)->RayPick(a,b,c,d)
+#define IDirect3DRMFrame3_Save(p,a,b,c)                      (p)->Save(a,b,c)
+#define IDirect3DRMFrame3_TransformVectors(p,a,b,c,d)        (p)->TransformVectors(a,b,c,d)
+#define IDirect3DRMFrame3_InverseTransformVectors(p,a,b,c,d) (p)->InverseTransformVectors(a,b,c,d)
+#define IDirect3DRMFrame3_SetTraversalOptions(p,a)           (p)->SetTraversalOptions(a)
+#define IDirect3DRMFrame3_GetTraversalOptions(p,a)           (p)->GetTraversalOptions(a)
+#define IDirect3DRMFrame3_SetSceneFogMethod(p,a)             (p)->SetSceneFogMethod(a)
+#define IDirect3DRMFrame3_GetSceneFogMethod(p,a)             (p)->GetSceneFogMethod(a)
+#define IDirect3DRMFrame3_SetMaterialOverride(p,a)           (p)->SetMaterialOverride(a)
+#define IDirect3DRMFrame3_GetMaterialOverride(p,a)           (p)->GetMaterialOverride(a)
+#endif
+
+/*****************************************************************************
+ * IDirect3DRMMesh interface
+ */
+#define INTERFACE IDirect3DRMMesh
+DECLARE_INTERFACE_(IDirect3DRMMesh,IDirect3DRMVisual)
+{
+    /*** IUnknown methods ***/
+    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
+    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+    STDMETHOD_(ULONG,Release)(THIS) PURE;
+    /*** IDirect3DRMObject methods ***/
+    STDMETHOD(Clone)(THIS_ LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj) PURE;
+    STDMETHOD(AddDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK, LPVOID argument) PURE;
+    STDMETHOD(DeleteDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK, LPVOID argument) PURE;
+    STDMETHOD(SetAppData)(THIS_ DWORD data) PURE;
+    STDMETHOD_(DWORD, GetAppData)(THIS) PURE;
+    STDMETHOD(SetName)(THIS_ LPCSTR) PURE;
+    STDMETHOD(GetName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE;
+    STDMETHOD(GetClassName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE;
+    /*** IDirect3DRMMesh methods ***/
+    STDMETHOD(Scale)(THIS_ D3DVALUE sx, D3DVALUE sy, D3DVALUE sz) PURE;
+    STDMETHOD(Translate)(THIS_ D3DVALUE tx, D3DVALUE ty, D3DVALUE tz) PURE;
+    STDMETHOD(GetBox)(THIS_ D3DRMBOX *) PURE;
+    STDMETHOD(AddGroup)(THIS_ unsigned vCount, unsigned fCount, unsigned vPerFace, unsigned *fData,
+        D3DRMGROUPINDEX *returnId) PURE;
+    STDMETHOD(SetVertices)(THIS_ D3DRMGROUPINDEX id, unsigned index, unsigned count,
+        D3DRMVERTEX *values) PURE;
+    STDMETHOD(SetGroupColor)(THIS_ D3DRMGROUPINDEX id, D3DCOLOR value) PURE;
+    STDMETHOD(SetGroupColorRGB)(THIS_ D3DRMGROUPINDEX id, D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE;
+    STDMETHOD(SetGroupMapping)(THIS_ D3DRMGROUPINDEX id, D3DRMMAPPING value) PURE;
+    STDMETHOD(SetGroupQuality)(THIS_ D3DRMGROUPINDEX id, D3DRMRENDERQUALITY value) PURE;
+    STDMETHOD(SetGroupMaterial)(THIS_ D3DRMGROUPINDEX id, LPDIRECT3DRMMATERIAL value) PURE;
+    STDMETHOD(SetGroupTexture)(THIS_ D3DRMGROUPINDEX id, LPDIRECT3DRMTEXTURE value) PURE;
+    STDMETHOD_(unsigned, GetGroupCount)(THIS) PURE;
+    STDMETHOD(GetGroup)(THIS_ D3DRMGROUPINDEX id, unsigned *vCount, unsigned *fCount, unsigned *vPerFace,
+        DWORD *fDataSize, unsigned *fData) PURE;
+    STDMETHOD(GetVertices)(THIS_ D3DRMGROUPINDEX id, DWORD index, DWORD count, D3DRMVERTEX *returnPtr) PURE;
+    STDMETHOD_(D3DCOLOR, GetGroupColor)(THIS_ D3DRMGROUPINDEX id) PURE;
+    STDMETHOD_(D3DRMMAPPING, GetGroupMapping)(THIS_ D3DRMGROUPINDEX id) PURE;
+    STDMETHOD_(D3DRMRENDERQUALITY, GetGroupQuality)(THIS_ D3DRMGROUPINDEX id) PURE;
+    STDMETHOD(GetGroupMaterial)(THIS_ D3DRMGROUPINDEX id, LPDIRECT3DRMMATERIAL *returnPtr) PURE;
+    STDMETHOD(GetGroupTexture)(THIS_ D3DRMGROUPINDEX id, LPDIRECT3DRMTEXTURE *returnPtr) PURE;
+};
+#undef INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IDirect3DRMMesh_QueryInterface(p,a,b)              (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DRMMesh_AddRef(p)                          (p)->lpVtbl->AddRef(p)
+#define IDirect3DRMMesh_Release(p)                         (p)->lpVtbl->Release(p)
+/*** IDirect3DRMObject methods ***/
+#define IDirect3DRMMesh_Clone(p,a,b,c)                     (p)->lpVtbl->Clone(p,a,b,c)
+#define IDirect3DRMMesh_AddDestroyCallback(p,a,b)          (p)->lpVtbl->AddDestroyCallback(p,a,b)
+#define IDirect3DRMMesh_DeleteDestroyCallback(p,a,b)       (p)->lpVtbl->DeleteDestroyCallback(p,a,b)
+#define IDirect3DRMMesh_SetAppData(p,a)                    (p)->lpVtbl->SetAppData(p,a)
+#define IDirect3DRMMesh_GetAppData(p)                      (p)->lpVtbl->GetAppData(p)
+#define IDirect3DRMMesh_SetName(p,a)                       (p)->lpVtbl->SetName(p,a)
+#define IDirect3DRMMesh_GetName(p,a,b)                     (p)->lpVtbl->GetName(p,a,b)
+#define IDirect3DRMMesh_GetClassName(p,a,b)                (p)->lpVtbl->GetClassName(p,a,b)
+/*** IDirect3DRMMesh methods ***/
+#define IDirect3DRMMesh_Scale(p,a,b,c)                     (p)->lpVtbl->Scale(p,a,b,c)
+#define IDirect3DRMMesh_Translate(p,a,b,c)                 (p)->lpVtbl->Translate(p,a,b,c)
+#define IDirect3DRMMesh_GetBox(p,a)                        (p)->lpVtbl->GetBox(p,a)
+#define IDirect3DRMMesh_AddGroup(p,a,b,c,d,e)              (p)->lpVtbl->AddGroup(p,a,b,c,d,e)
+#define IDirect3DRMMesh_SetVertices(p,a,b,c,d)             (p)->lpVtbl->SetVertices(p,a,b,c,d)
+#define IDirect3DRMMesh_SetGroupColor(p,a,b)               (p)->lpVtbl->SetGroupColor(p,a,b)
+#define IDirect3DRMMesh_SetGroupColorRGB(p,a,b,c,d)        (p)->lpVtbl->SetGroupColorRGB(p,a,b,c,d)
+#define IDirect3DRMMesh_SetGroupMapping(p,a,b)             (p)->lpVtbl->SetGroupMapping(p,a,b)
+#define IDirect3DRMMesh_SetGroupQuality(p,a,b)             (p)->lpVtbl->SetGroupQuality(p,a,b)
+#define IDirect3DRMMesh_SetGroupMaterial(p,a,b)            (p)->lpVtbl->SetGroupMaterial(p,a,b)
+#define IDirect3DRMMesh_SetGroupTexture(p,a,b)             (p)->lpVtbl->SetGroupTexture(p,a,b)
+#define IDirect3DRMMesh_GetGroupCount(p)                   (p)->lpVtbl->GetGroupCount(p)
+#define IDirect3DRMMesh_GetGroup(p,a,b,c,d,e,f)            (p)->lpVtbl->GetGroup(p,a,b,c,d,e,f)
+#define IDirect3DRMMesh_GetVertices(p,a,b,c,d)             (p)->lpVtbl->GetVertices(p,a,b,c,d)
+#define IDirect3DRMMesh_GetGroupColor(p,a)                 (p)->lpVtbl->GetGroupColor(p,a)
+#define IDirect3DRMMesh_GetGroupMapping(p,a)               (p)->lpVtbl->GetGroupMapping(p,a)
+#define IDirect3DRMMesh_GetGroupQuality(p,a)               (p)->lpVtbl->GetGroupQuality(p,a)
+#define IDirect3DRMMesh_GetGroupMaterial(p,a,b)            (p)->lpVtbl->GetGroupMaterial(p,a,b)
+#define IDirect3DRMMesh_GetGroupTexture(p,a,b)             (p)->lpVtbl->GetGroupTexture(p,a,b)
+#else
+/*** IUnknown methods ***/
+#define IDirect3DRMMesh_QueryInterface(p,a,b)              (p)->QueryInterface(a,b)
+#define IDirect3DRMMesh_AddRef(p)                          (p)->AddRef()
+#define IDirect3DRMMesh_Release(p)                         (p)->Release()
+/*** IDirect3DRMObject methods ***/
+#define IDirect3DRMMesh_Clone(p,a,b,c)                     (p)->Clone(a,b,c)
+#define IDirect3DRMMesh_AddDestroyCallback(p,a,b)          (p)->AddDestroyCallback(a,b)
+#define IDirect3DRMMesh_DeleteDestroyCallback(p,a,b)       (p)->DeleteDestroyCallback(a,b)
+#define IDirect3DRMMesh_SetAppData(p,a)                    (p)->SetAppData(a)
+#define IDirect3DRMMesh_GetAppData(p)                      (p)->GetAppData()
+#define IDirect3DRMMesh_SetName(p,a)                       (p)->SetName(a)
+#define IDirect3DRMMesh_GetName(p,a,b)                     (p)->GetName(a,b)
+#define IDirect3DRMMesh_GetClassName(p,a,b)                (p)->GetClassName(a,b)
+/*** IDirect3DRMMesh methods ***/
+#define IDirect3DRMMesh_Scale(p,a,b,c)                     (p)->Scale(a,b,c)
+#define IDirect3DRMMesh_Translate(p,a,b,c)                 (p)->Translate(a,b,c)
+#define IDirect3DRMMesh_GetBox(p,a)                        (p)->GetBox(a)
+#define IDirect3DRMMesh_AddGroup(p,a,b,c,d,e)              (p)->AddGroup(a,b,c,d,e)
+#define IDirect3DRMMesh_SetVertices(p,a,b,c,d)             (p)->SetVertices(a,b,c,d)
+#define IDirect3DRMMesh_SetGroupColor(p,a,b)               (p)->SetGroupColor(a,b)
+#define IDirect3DRMMesh_SetGroupColorRGB(p,a,b,c,d)        (p)->SetGroupColorRGB(a,b,c,d)
+#define IDirect3DRMMesh_SetGroupMapping(p,a,b)             (p)->SetGroupMapping(a,b)
+#define IDirect3DRMMesh_SetGroupQuality(p,a,b)             (p)->SetGroupQuality(a,b)
+#define IDirect3DRMMesh_SetGroupMaterial(p,a,b)            (p)->SetGroupMaterial(a,b)
+#define IDirect3DRMMesh_SetGroupTexture(p,a,b)             (p)->SetGroupTexture(a,b)
+#define IDirect3DRMMesh_GetGroupCount(p)                   (p)->GetGroupCount()
+#define IDirect3DRMMesh_GetGroup(p,a,b,c,d,e,f)            (p)->GetGroup(a,b,c,d,e,f)
+#define IDirect3DRMMesh_GetVertices(p,a,b,c,d)             (p)->GetVertices(a,b,c,d)
+#define IDirect3DRMMesh_GetGroupColor(p,a)                 (p)->GetGroupColor(a)
+#define IDirect3DRMMesh_GetGroupMapping(p,a)               (p)->GetGroupMapping(a)
+#define IDirect3DRMMesh_GetGroupQuality(p,a)               (p)->GetGroupQuality(a)
+#define IDirect3DRMMesh_GetGroupMaterial(p,a,b)            (p)->lpVtbl->GetGroupMaterial(a,b)
+#define IDirect3DRMMesh_GetGroupTexture(p,a,b)             (p)->lpVtbl->GetGroupTexture(a,b)
+#endif
+
+/*****************************************************************************
+ * IDirect3DRMProgressiveMesh interface
+ */
+#define INTERFACE IDirect3DRMProgressiveMesh
+DECLARE_INTERFACE_(IDirect3DRMProgressiveMesh,IDirect3DRMVisual)
+{
+    /*** IUnknown methods ***/
+    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
+    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+    STDMETHOD_(ULONG,Release)(THIS) PURE;
+    /*** IDirect3DRMObject methods ***/
+    STDMETHOD(Clone)(THIS_ LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj) PURE;
+    STDMETHOD(AddDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK, LPVOID argument) PURE;
+    STDMETHOD(DeleteDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK, LPVOID argument) PURE;
+    STDMETHOD(SetAppData)(THIS_ DWORD data) PURE;
+    STDMETHOD_(DWORD, GetAppData)(THIS) PURE;
+    STDMETHOD(SetName)(THIS_ LPCSTR) PURE;
+    STDMETHOD(GetName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE;
+    STDMETHOD(GetClassName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE;
+    /*** IDirect3DRMProgressiveMesh methods ***/
+    STDMETHOD(Load) (THIS_ LPVOID pObjLocation, LPVOID pObjId, D3DRMLOADOPTIONS dloLoadflags,
+        D3DRMLOADTEXTURECALLBACK pCallback, LPVOID lpArg) PURE;
+    STDMETHOD(GetLoadStatus) (THIS_ LPD3DRMPMESHLOADSTATUS pStatus) PURE;
+    STDMETHOD(SetMinRenderDetail) (THIS_ D3DVALUE d3dVal) PURE;
+    STDMETHOD(Abort) (THIS_ DWORD flags) PURE;
+    STDMETHOD(GetFaceDetail) (THIS_ LPDWORD pCount) PURE;
+    STDMETHOD(GetVertexDetail) (THIS_ LPDWORD pCount) PURE;
+    STDMETHOD(SetFaceDetail) (THIS_ DWORD count) PURE;
+    STDMETHOD(SetVertexDetail) (THIS_ DWORD count) PURE;
+    STDMETHOD(GetFaceDetailRange) (THIS_ LPDWORD pMin, LPDWORD pMax) PURE;
+    STDMETHOD(GetVertexDetailRange) (THIS_ LPDWORD pMin, LPDWORD pMax) PURE;
+    STDMETHOD(GetDetail) (THIS_ D3DVALUE *pdvVal) PURE;
+    STDMETHOD(SetDetail) (THIS_ D3DVALUE d3dVal) PURE;
+    STDMETHOD(RegisterEvents) (THIS_ HANDLE event, DWORD flags, DWORD reserved) PURE;
+    STDMETHOD(CreateMesh) (THIS_ LPDIRECT3DRMMESH *ppD3DRMMesh) PURE;
+    STDMETHOD(Duplicate) (THIS_ LPDIRECT3DRMPROGRESSIVEMESH *ppD3DRMPMesh) PURE;
+    STDMETHOD(GetBox) (THIS_ LPD3DRMBOX pBBox) PURE;
+    STDMETHOD(SetQuality) (THIS_ D3DRMRENDERQUALITY) PURE;
+    STDMETHOD(GetQuality) (THIS_ LPD3DRMRENDERQUALITY pQuality) PURE;
+};
+#undef INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IDirect3DRMProgressiveMesh_QueryInterface(p,a,b)          (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DRMProgressiveMesh_AddRef(p)                      (p)->lpVtbl->AddRef(p)
+#define IDirect3DRMProgressiveMesh_Release(p)                     (p)->lpVtbl->Release(p)
+/*** IDirect3DRMObject methods ***/
+#define IDirect3DRMProgressiveMesh_Clone(p,a,b,c)                 (p)->lpVtbl->Clone(p,a,b,c)
+#define IDirect3DRMProgressiveMesh_AddDestroyCallback(p,a,b)      (p)->lpVtbl->AddDestroyCallback(p,a,b)
+#define IDirect3DRMProgressiveMesh_DeleteDestroyCallback(p,a,b)   (p)->lpVtbl->DeleteDestroyCallback(p,a,b)
+#define IDirect3DRMProgressiveMesh_SetAppData(p,a)                (p)->lpVtbl->SetAppData(p,a)
+#define IDirect3DRMProgressiveMesh_GetAppData(p)                  (p)->lpVtbl->GetAppData(p)
+#define IDirect3DRMProgressiveMesh_SetName(p,a)                   (p)->lpVtbl->SetName(p,a)
+#define IDirect3DRMProgressiveMesh_GetName(p,a,b)                 (p)->lpVtbl->GetName(p,a,b)
+#define IDirect3DRMProgressiveMesh_GetClassName(p,a,b)            (p)->lpVtbl->GetClassName(p,a,b)
+/*** IDirect3DRMProgressiveMesh methods ***/
+#define IDirect3DRMProgressiveMesh_Load(p,a,b,c,d,e)              (p)->lpVtbl->Load(p,a,b,c,d,e)
+#define IDirect3DRMProgressiveMesh_GetLoadStatus(p,a)             (p)->lpVtbl->GetLoadStatus(p,a)
+#define IDirect3DRMProgressiveMesh_SetMinRenderDetail(p,a)        (p)->lpVtbl->SetMinRenderDetail(p,a)
+#define IDirect3DRMProgressiveMesh_Abort(p,a)                     (p)->lpVtbl->Abort(p,a)
+#define IDirect3DRMProgressiveMesh_GetFaceDetail(p,a)             (p)->lpVtbl->GetFaceDetail(p,a)
+#define IDirect3DRMProgressiveMesh_GetVertexDetail(p,a)           (p)->lpVtbl->GetVertexDetail(p,a)
+#define IDirect3DRMProgressiveMesh_SetFaceDetail(p,a)             (p)->lpVtbl->SetFaceDetail(p,a)
+#define IDirect3DRMProgressiveMesh_SetVertexDetail(p,a)           (p)->lpVtbl->SetVertexDetail(p,a)
+#define IDirect3DRMProgressiveMesh_GetFaceDetailRange(p,a,b)      (p)->lpVtbl->GetFaceDetailRange(p,a,b)
+#define IDirect3DRMProgressiveMesh_GetVertexDetailRange(p,a,b)    (p)->lpVtbl->GetVertexDetailRange(p,a,b)
+#define IDirect3DRMProgressiveMesh_GetDetail(p,a)                 (p)->lpVtbl->GetDetail(p,a)
+#define IDirect3DRMProgressiveMesh_SetDetail(p,a)                 (p)->lpVtbl->SetDetail(p,a)
+#define IDirect3DRMProgressiveMesh_RegisterEvents(p,a,b,c)        (p)->lpVtbl->RegisterEvents(p,a,b,c)
+#define IDirect3DRMProgressiveMesh_CreateMesh(p,a)                (p)->lpVtbl->CreateMesh(p,a)
+#define IDirect3DRMProgressiveMesh_Duplicate(p,a)                 (p)->lpVtbl->Duplicate(p,a)
+#define IDirect3DRMProgressiveMesh_GetBox(p,a)                    (p)->lpVtbl->GetBox(p,a)
+#define IDirect3DRMProgressiveMesh_SetQuality(p,a)                (p)->lpVtbl->SetQuality(p,a)
+#define IDirect3DRMProgressiveMesh_GetQuality(p,a)                (p)->lpVtbl->GetQuality(p,a)
+#else
+/*** IUnknown methods ***/
+#define IDirect3DRMProgressiveMesh_QueryInterface(p,a,b)          (p)->QueryInterface(a,b)
+#define IDirect3DRMProgressiveMesh_AddRef(p)                      (p)->AddRef()
+#define IDirect3DRMProgressiveMesh_Release(p)                     (p)->Release()
+/*** IDirect3DRMObject methods ***/
+#define IDirect3DRMProgressiveMesh_Clone(p,a,b,c)                 (p)->Clone(a,b,c)
+#define IDirect3DRMProgressiveMesh_AddDestroyCallback(p,a,b)      (p)->AddDestroyCallback(a,b)
+#define IDirect3DRMProgressiveMesh_DeleteDestroyCallback(p,a,b)   (p)->DeleteDestroyCallback(a,b)
+#define IDirect3DRMProgressiveMesh_SetAppData(p,a)                (p)->SetAppData(a)
+#define IDirect3DRMProgressiveMesh_GetAppData(p)                  (p)->GetAppData()
+#define IDirect3DRMProgressiveMesh_SetName(p,a)                   (p)->SetName(a)
+#define IDirect3DRMProgressiveMesh_GetName(p,a,b)                 (p)->GetName(a,b)
+#define IDirect3DRMProgressiveMesh_GetClassName(p,a,b)            (p)->GetClassName(a,b)
+/*** IDirect3DRMProgressiveMesh methods ***/
+#define IDirect3DRMProgressiveMesh_Load(p,a,b,c,d,e)              (p)->Load(a,b,c,d,e)
+#define IDirect3DRMProgressiveMesh_GetLoadStatus(p,a)             (p)->GetLoadStatus(a)
+#define IDirect3DRMProgressiveMesh_SetMinRenderDetail(p,a)        (p)->SetMinRenderDetail(a)
+#define IDirect3DRMProgressiveMesh_Abort(p,a)                     (p)->Abort(a)
+#define IDirect3DRMProgressiveMesh_GetFaceDetail(p,a)             (p)->GetFaceDetail(a)
+#define IDirect3DRMProgressiveMesh_GetVertexDetail(p,a)           (p)->GetVertexDetail(a)
+#define IDirect3DRMProgressiveMesh_SetFaceDetail(p,a)             (p)->SetFaceDetail(a)
+#define IDirect3DRMProgressiveMesh_SetVertexDetail(p,a)           (p)->SetVertexDetail(a)
+#define IDirect3DRMProgressiveMesh_GetFaceDetailRange(p,a,b)      (p)->GetFaceDetailRange(a,b)
+#define IDirect3DRMProgressiveMesh_GetVertexDetailRange(p,a,b)    (p)->GetVertexDetailRange(a,b)
+#define IDirect3DRMProgressiveMesh_GetDetail(p,a)                 (p)->GetDetail(a)
+#define IDirect3DRMProgressiveMesh_SetDetail(p,a)                 (p)->SetDetail(a)
+#define IDirect3DRMProgressiveMesh_RegisterEvents(p,a,b,c)        (p)->RegisterEvents(a,b,c)
+#define IDirect3DRMProgressiveMesh_CreateMesh(p,a)                (p)->CreateMesh(a)
+#define IDirect3DRMProgressiveMesh_Duplicate(p,a)                 (p)->Duplicate(a)
+#define IDirect3DRMProgressiveMesh_GetBox(p,a)                    (p)->GetBox(a)
+#define IDirect3DRMProgressiveMesh_SetQuality(p,a)                (p)->SetQuality(a)
+#define IDirect3DRMProgressiveMesh_GetQuality(p,a)                (p)->GetQuality(a)
+#endif
+
+/*****************************************************************************
+ * IDirect3DRMShadow interface
+ */
+#define INTERFACE IDirect3DRMShadow
+DECLARE_INTERFACE_(IDirect3DRMShadow,IDirect3DRMVisual)
+{
+    /*** IUnknown methods ***/
+    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
+    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+    STDMETHOD_(ULONG,Release)(THIS) PURE;
+    /*** IDirect3DRMObject methods ***/
+    STDMETHOD(Clone)(THIS_ LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj) PURE;
+    STDMETHOD(AddDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK, LPVOID argument) PURE;
+    STDMETHOD(DeleteDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK, LPVOID argument) PURE;
+    STDMETHOD(SetAppData)(THIS_ DWORD data) PURE;
+    STDMETHOD_(DWORD, GetAppData)(THIS) PURE;
+    STDMETHOD(SetName)(THIS_ LPCSTR) PURE;
+    STDMETHOD(GetName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE;
+    STDMETHOD(GetClassName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE;
+    /*** IDirect3DRMShadow methods ***/
+    STDMETHOD(Init)(THIS_ LPDIRECT3DRMVISUAL visual, LPDIRECT3DRMLIGHT light,
+        D3DVALUE px, D3DVALUE py, D3DVALUE pz, D3DVALUE nx, D3DVALUE ny, D3DVALUE nz) PURE;
+};
+#undef INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IDirect3DRMShadow_QueryInterface(p,a,b)          (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DRMShadow_AddRef(p)                      (p)->lpVtbl->AddRef(p)
+#define IDirect3DRMShadow_Release(p)                     (p)->lpVtbl->Release(p)
+/*** IDirect3DRMObject methods ***/
+#define IDirect3DRMShadow_Clone(p,a,b,c)                 (p)->lpVtbl->Clone(p,a,b,c)
+#define IDirect3DRMShadow_AddDestroyCallback(p,a,b)      (p)->lpVtbl->AddDestroyCallback(p,a,b)
+#define IDirect3DRMShadow_DeleteDestroyCallback(p,a,b)   (p)->lpVtbl->DeleteDestroyCallback(p,a,b)
+#define IDirect3DRMShadow_SetAppData(p,a)                (p)->lpVtbl->SetAppData(p,a)
+#define IDirect3DRMShadow_GetAppData(p)                  (p)->lpVtbl->GetAppData(p)
+#define IDirect3DRMShadow_SetName(p,a)                   (p)->lpVtbl->SetName(p,a)
+#define IDirect3DRMShadow_GetName(p,a,b)                 (p)->lpVtbl->GetName(p,a,b)
+#define IDirect3DRMShadow_GetClassName(p,a,b)            (p)->lpVtbl->GetClassName(p,a,b)
+/*** IDirect3DRMShadow methods ***/
+#define IDirect3DRMShadow_Init(p,a,b,c,d,e,f,g)          (p)->lpVtbl->Load(p,a,b,c,d,e,f,g)
+#else
+/*** IUnknown methods ***/
+#define IDirect3DRMShadow_QueryInterface(p,a,b)          (p)->QueryInterface(a,b)
+#define IDirect3DRMShadow_AddRef(p)                      (p)->AddRef()
+#define IDirect3DRMShadow_Release(p)                     (p)->Release()
+/*** IDirect3DRMObject methods ***/
+#define IDirect3DRMShadow_Clone(p,a,b,c)                 (p)->Clone(a,b,c)
+#define IDirect3DRMShadow_AddDestroyCallback(p,a,b)      (p)->AddDestroyCallback(a,b)
+#define IDirect3DRMShadow_DeleteDestroyCallback(p,a,b)   (p)->DeleteDestroyCallback(a,b)
+#define IDirect3DRMShadow_SetAppData(p,a)                (p)->SetAppData(a)
+#define IDirect3DRMShadow_GetAppData(p)                  (p)->GetAppData()
+#define IDirect3DRMShadow_SetName(p,a)                   (p)->SetName(a)
+#define IDirect3DRMShadow_GetName(p,a,b)                 (p)->GetName(a,b)
+#define IDirect3DRMShadow_GetClassName(p,a,b)            (p)->GetClassName(a,b)
+/*** IDirect3DRMShadow methods ***/
+#define IDirect3DRMShadow_Init(p,a,b,c,d,e,f,g)          (p)->Load(a,b,c,d,e,f,g)
+#endif
+
+/*****************************************************************************
+ * IDirect3DRMShadow2 interface
+ */
+#define INTERFACE IDirect3DRMShadow2
+DECLARE_INTERFACE_(IDirect3DRMShadow2,IDirect3DRMVisual)
+{
+    /*** IUnknown methods ***/
+    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
+    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+    STDMETHOD_(ULONG,Release)(THIS) PURE;
+    /*** IDirect3DRMObject methods ***/
+    STDMETHOD(Clone)(THIS_ LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj) PURE;
+    STDMETHOD(AddDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK, LPVOID argument) PURE;
+    STDMETHOD(DeleteDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK, LPVOID argument) PURE;
+    STDMETHOD(SetAppData)(THIS_ DWORD data) PURE;
+    STDMETHOD_(DWORD, GetAppData)(THIS) PURE;
+    STDMETHOD(SetName)(THIS_ LPCSTR) PURE;
+    STDMETHOD(GetName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE;
+    STDMETHOD(GetClassName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE;
+    /*** IDirect3DRMShadow methods ***/
+    STDMETHOD(Init)(THIS_ LPUNKNOWN pUNK, LPDIRECT3DRMLIGHT light,
+        D3DVALUE px, D3DVALUE py, D3DVALUE pz, D3DVALUE nx, D3DVALUE ny, D3DVALUE nz) PURE;
+    /*** IDirect3DRMShadow2 methods ***/
+    STDMETHOD(GetVisual)(THIS_ LPDIRECT3DRMVISUAL *) PURE;
+    STDMETHOD(SetVisual)(THIS_ LPUNKNOWN pUNK, DWORD) PURE;
+    STDMETHOD(GetLight)(THIS_ LPDIRECT3DRMLIGHT *) PURE;
+    STDMETHOD(SetLight)(THIS_ LPDIRECT3DRMLIGHT, DWORD) PURE;
+    STDMETHOD(GetPlane)(THIS_ LPD3DVALUE px, LPD3DVALUE py, LPD3DVALUE pz,
+        LPD3DVALUE nx, LPD3DVALUE ny, LPD3DVALUE nz) PURE;
+    STDMETHOD(SetPlane)(THIS_ D3DVALUE px, D3DVALUE py, D3DVALUE pz,
+        D3DVALUE nx, D3DVALUE ny, D3DVALUE nz, DWORD) PURE;
+    STDMETHOD(GetOptions)(THIS_ LPDWORD) PURE;
+    STDMETHOD(SetOptions)(THIS_ DWORD) PURE;
+};
+#undef INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IDirect3DRMShadow2_QueryInterface(p,a,b)          (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DRMShadow2_AddRef(p)                      (p)->lpVtbl->AddRef(p)
+#define IDirect3DRMShadow2_Release(p)                     (p)->lpVtbl->Release(p)
+/*** IDirect3DRMObject methods ***/
+#define IDirect3DRMShadow2_Clone(p,a,b,c)                 (p)->lpVtbl->Clone(p,a,b,c)
+#define IDirect3DRMShadow2_AddDestroyCallback(p,a,b)      (p)->lpVtbl->AddDestroyCallback(p,a,b)
+#define IDirect3DRMShadow2_DeleteDestroyCallback(p,a,b)   (p)->lpVtbl->DeleteDestroyCallback(p,a,b)
+#define IDirect3DRMShadow2_SetAppData(p,a)                (p)->lpVtbl->SetAppData(p,a)
+#define IDirect3DRMShadow2_GetAppData(p)                  (p)->lpVtbl->GetAppData(p)
+#define IDirect3DRMShadow2_SetName(p,a)                   (p)->lpVtbl->SetName(p,a)
+#define IDirect3DRMShadow2_GetName(p,a,b)                 (p)->lpVtbl->GetName(p,a,b)
+#define IDirect3DRMShadow2_GetClassName(p,a,b)            (p)->lpVtbl->GetClassName(p,a,b)
+/*** IDirect3DRMShadow methods ***/
+#define IDirect3DRMShadow2_Init(p,a,b,c,d,e,f,g)          (p)->lpVtbl->Init(p,a,b,c,d,e,f,g)
+/*** IDirect3DRMShadow2 methods ***/
+#define IDirect3DRMShadow2_GetVisual(p,a)                 (p)->lpVtbl->GetVisual(p,a)
+#define IDirect3DRMShadow2_SetVisual(p,a,b)               (p)->lpVtbl->SetVisual(p,a,b)
+#define IDirect3DRMShadow2_GetLight(p,a)                  (p)->lpVtbl->GetLight(p,a)
+#define IDirect3DRMShadow2_SetLight(p,a,b)                (p)->lpVtbl->SetLight(p,a,b)
+#define IDirect3DRMShadow2_GetPlane(p,a,b,c,d,e,f)        (p)->lpVtbl->GetPlane(p,a,b,c,d,e,f)
+#define IDirect3DRMShadow2_SetPlane(p,a,b,c,d,e,f)        (p)->lpVtbl->SetPlane(p,a,b,c,d,e,f)
+#define IDirect3DRMShadow2_GetOptions(p,a)                (p)->lpVtbl->GetOptions(p,a)
+#define IDirect3DRMShadow2_SetOptions(p,a)                (p)->lpVtbl->SetOptions(p,a)
+#else
+/*** IUnknown methods ***/
+#define IDirect3DRMShadow2_QueryInterface(p,a,b)          (p)->QueryInterface(a,b)
+#define IDirect3DRMShadow2_AddRef(p)                      (p)->AddRef()
+#define IDirect3DRMShadow2_Release(p)                     (p)->Release()
+/*** IDirect3DRMObject methods ***/
+#define IDirect3DRMShadow2_Clone(p,a,b,c)                 (p)->Clone(a,b,c)
+#define IDirect3DRMShadow2_AddDestroyCallback(p,a,b)      (p)->AddDestroyCallback(a,b)
+#define IDirect3DRMShadow2_DeleteDestroyCallback(p,a,b)   (p)->DeleteDestroyCallback(a,b)
+#define IDirect3DRMShadow2_SetAppData(p,a)                (p)->SetAppData(a)
+#define IDirect3DRMShadow2_GetAppData(p)                  (p)->GetAppData()
+#define IDirect3DRMShadow2_SetName(p,a)                   (p)->SetName(a)
+#define IDirect3DRMShadow2_GetName(p,a,b)                 (p)->GetName(a,b)
+#define IDirect3DRMShadow2_GetClassName(p,a,b)            (p)->GetClassName(a,b)
+/*** IDirect3DRMShadow methods ***/
+#define IDirect3DRMShadow2_Init(p,a,b,c,d,e,f,g)          (p)->Init(a,b,c,d,e,f,g)
+/*** IDirect3DRMShadow2 methods ***/
+#define IDirect3DRMShadow2_GetVisual(p,a)                 (p)->GetVisual(a)
+#define IDirect3DRMShadow2_SetVisual(p,a,b)               (p)->SetVisual(a,b)
+#define IDirect3DRMShadow2_GetLight(p,a)                  (p)->GetLight(a)
+#define IDirect3DRMShadow2_SetLight(p,a,b)                (p)->SetLight(a,b)
+#define IDirect3DRMShadow2_GetPlane(p,a,b,c,d,e,f)        (p)->GetPlane(a,b,c,d,e,f)
+#define IDirect3DRMShadow2_SetPlane(p,a,b,c,d,e,f)        (p)->SetPlane(a,b,c,d,e,f)
+#define IDirect3DRMShadow2_GetOptions(p,a)                (p)->GetOptions(a)
+#define IDirect3DRMShadow2_SetOptions(p,a)                (p)->lpVtbl->SetOptions(p,a)
+#endif
+
+/*****************************************************************************
+ * IDirect3DRMFace interface
+ */
+#define INTERFACE IDirect3DRMFace
+DECLARE_INTERFACE_(IDirect3DRMFace,IDirect3DRMObject)
+{
+    /*** IUnknown methods ***/
+    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
+    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+    STDMETHOD_(ULONG,Release)(THIS) PURE;
+    /*** IDirect3DRMObject methods ***/
+    STDMETHOD(Clone)(THIS_ LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj) PURE;
+    STDMETHOD(AddDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK, LPVOID argument) PURE;
+    STDMETHOD(DeleteDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK, LPVOID argument) PURE;
+    STDMETHOD(SetAppData)(THIS_ DWORD data) PURE;
+    STDMETHOD_(DWORD, GetAppData)(THIS) PURE;
+    STDMETHOD(SetName)(THIS_ LPCSTR) PURE;
+    STDMETHOD(GetName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE;
+    STDMETHOD(GetClassName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE;
+    /*** IDirect3DRMFace methods ***/
+    STDMETHOD(AddVertex)(THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE;
+    STDMETHOD(AddVertexAndNormalIndexed)(THIS_ DWORD vertex, DWORD normal) PURE;
+    STDMETHOD(SetColorRGB)(THIS_ D3DVALUE, D3DVALUE, D3DVALUE) PURE;
+    STDMETHOD(SetColor)(THIS_ D3DCOLOR) PURE;
+    STDMETHOD(SetTexture)(THIS_ LPDIRECT3DRMTEXTURE) PURE;
+    STDMETHOD(SetTextureCoordinates)(THIS_ DWORD vertex, D3DVALUE u, D3DVALUE v) PURE;
+    STDMETHOD(SetMaterial)(THIS_ LPDIRECT3DRMMATERIAL) PURE;
+    STDMETHOD(SetTextureTopology)(THIS_ BOOL wrap_u, BOOL wrap_v) PURE;
+    STDMETHOD(GetVertex)(THIS_ DWORD index, D3DVECTOR *vertex, D3DVECTOR *normal) PURE;
+    STDMETHOD(GetVertices)(THIS_ DWORD *vertex_count, D3DVECTOR *coords, D3DVECTOR *normals);
+    STDMETHOD(GetTextureCoordinates)(THIS_ DWORD vertex, D3DVALUE *u, D3DVALUE *v) PURE;
+    STDMETHOD(GetTextureTopology)(THIS_ BOOL *wrap_u, BOOL *wrap_v) PURE;
+    STDMETHOD(GetNormal)(THIS_ D3DVECTOR *) PURE;
+    STDMETHOD(GetTexture)(THIS_ LPDIRECT3DRMTEXTURE *) PURE;
+    STDMETHOD(GetMaterial)(THIS_ LPDIRECT3DRMMATERIAL *) PURE;
+    STDMETHOD_(int, GetVertexCount)(THIS) PURE;
+    STDMETHOD_(int, GetVertexIndex)(THIS_ DWORD which) PURE;
+    STDMETHOD_(int, GetTextureCoordinateIndex)(THIS_ DWORD which) PURE;
+    STDMETHOD_(D3DCOLOR, GetColor)(THIS) PURE;
+};
+#undef INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IDirect3DRMFace_QueryInterface(p,a,b)             (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DRMFace_AddRef(p)                         (p)->lpVtbl->AddRef(p)
+#define IDirect3DRMFace_Release(p)                        (p)->lpVtbl->Release(p)
+/*** IDirect3DRMObject methods ***/
+#define IDirect3DRMFace_Clone(p,a,b,c)                    (p)->lpVtbl->Clone(p,a,b,c)
+#define IDirect3DRMFace_AddDestroyCallback(p,a,b)         (p)->lpVtbl->AddDestroyCallback(p,a,b)
+#define IDirect3DRMFace_DeleteDestroyCallback(p,a,b)      (p)->lpVtbl->DeleteDestroyCallback(p,a,b)
+#define IDirect3DRMFace_SetAppData(p,a)                   (p)->lpVtbl->SetAppData(p,a)
+#define IDirect3DRMFace_GetAppData(p)                     (p)->lpVtbl->GetAppData(p)
+#define IDirect3DRMFace_SetName(p,a)                      (p)->lpVtbl->SetName(p,a)
+#define IDirect3DRMFace_GetName(p,a,b)                    (p)->lpVtbl->GetName(p,a,b)
+#define IDirect3DRMFace_GetClassName(p,a,b)               (p)->lpVtbl->GetClassName(p,a,b)
+/*** IDirect3DRMFace methods ***/
+#define IDirect3DRMFace_AddVertex(p,a,b,c)                (p)->lpVtbl->AddVertex(p,a,b,c)
+#define IDirect3DRMFace_AddVertexAndNormalIndexed(p,a,b)  (p)->lpVtbl->AddVertexAndNormalIndexed(p,a,b)
+#define IDirect3DRMFace_SetColorRGB(p,a,b,c)              (p)->lpVtbl->SetColorRGB(p,a,b,c)
+#define IDirect3DRMFace_SetColor(p,a)                     (p)->lpVtbl->SetColor(p,a)
+#define IDirect3DRMFace_SetTexture(p,a)                   (p)->lpVtbl->SetTexture(p,a)
+#define IDirect3DRMFace_SetTextureCoordinates(p,a,b,c)    (p)->lpVtbl->SetTextureCoordinates(p,a,b,c)
+#define IDirect3DRMFace_SetMaterial(p,a)                  (p)->lpVtbl->SetMaterial(p,a)
+#define IDirect3DRMFace_SetTextureTopology(p,a,b)         (p)->lpVtbl->SetTextureTopology(p,a,b)
+#define IDirect3DRMFace_GetVertex(p,a,b,c)                (p)->lpVtbl->GetVertex(p,a,b,c)
+#define IDirect3DRMFace_GetVertices(p,a,b,c)              (p)->lpVtbl->GetVertices(p,a,b,c)
+#define IDirect3DRMFace_GetTextureCoordinates(p,a,b,c)    (p)->lpVtbl->GetTextureCoordinates(p,a,b,c)
+#define IDirect3DRMFace_GetTextureTopology(p,a,b)         (p)->lpVtbl->GetTextureTopology(p,a,b)
+#define IDirect3DRMFace_GetNormal(p,a)                    (p)->lpVtbl->GetNormal(p,a)
+#define IDirect3DRMFace_GetTexture(p,a)                   (p)->lpVtbl->GetTexture(p,a)
+#define IDirect3DRMFace_GetVertexCount(p)                 (p)->lpVtbl->GetVertexCount(p)
+#define IDirect3DRMFace_GetVertexIndex(p,a)               (p)->lpVtbl->GetVertexIndex(p,a)
+#define IDirect3DRMFace_GetTextureCoordinateIndex(p,a)    (p)->lpVtbl->GetTextureCoordinateIndex(p,a)
+#define IDirect3DRMFace_GetColor(p,a)                     (p)->lpVtbl->GetColor(p,a)
+#else
+/*** IUnknown methods ***/
+#define IDirect3DRMFace_QueryInterface(p,a,b)             (p)->QueryInterface(a,b)
+#define IDirect3DRMFace_AddRef(p)                         (p)->AddRef()
+#define IDirect3DRMFace_Release(p)                        (p)->Release()
+/*** IDirect3DRMObject methods ***/
+#define IDirect3DRMFace_Clone(p,a,b,c)                    (p)->Clone(a,b,c)
+#define IDirect3DRMFace_AddDestroyCallback(p,a,b)         (p)->AddDestroyCallback(a,b)
+#define IDirect3DRMFace_DeleteDestroyCallback(p,a,b)      (p)->DeleteDestroyCallback(a,b)
+#define IDirect3DRMFace_SetAppData(p,a)                   (p)->SetAppData(a)
+#define IDirect3DRMFace_GetAppData(p)                     (p)->GetAppData()
+#define IDirect3DRMFace_SetName(p,a)                      (p)->SetName(a)
+#define IDirect3DRMFace_GetName(p,a,b)                    (p)->GetName(a,b)
+#define IDirect3DRMFace_GetClassName(p,a,b)               (p)->GetClassName(a,b)
+/*** IDirect3DRMFace methods ***/
+#define IDirect3DRMFace_AddVertex(p,a,b,c)                (p)->AddVertex(a,b,c)
+#define IDirect3DRMFace_AddVertexAndNormalIndexed(p,a,b)  (p)->AddVertexAndNormalIndexed(a,b)
+#define IDirect3DRMFace_SetColorRGB(p,a,b,c)              (p)->SetColorRGB(a,b,c)
+#define IDirect3DRMFace_SetColor(p,a)                     (p)->SetColor(a)
+#define IDirect3DRMFace_SetTexture(p,a)                   (p)->SetTexture(a)
+#define IDirect3DRMFace_SetTextureCoordinates(p,a,b,c)    (p)->SetTextureCoordinates(a,b,c)
+#define IDirect3DRMFace_SetMaterial(p,a)                  (p)->SetMaterial(a)
+#define IDirect3DRMFace_SetTextureTopology(p,a,b)         (p)->SetTextureTopology(a,b)
+#define IDirect3DRMFace_GetVertex(p,a,b,c)                (p)->GetVertex(a,b,c)
+#define IDirect3DRMFace_GetVertices(p,a,b,c)              (p)->GetVertices(a,b,c)
+#define IDirect3DRMFace_GetTextureCoordinates(p,a,b,c)    (p)->GetTextureCoordinates(a,b,c)
+#define IDirect3DRMFace_GetTextureTopology(p,a,b)         (p)->GetTextureTopology(a,b)
+#define IDirect3DRMFace_GetNormal(p,a)                    (p)->GetNormal(a)
+#define IDirect3DRMFace_GetTexture(p,a)                   (p)->GetTexture(a)
+#define IDirect3DRMFace_GetVertexCount(p)                 (p)->GetVertexCount()
+#define IDirect3DRMFace_GetVertexIndex(p,a)               (p)->GetVertexIndex(a)
+#define IDirect3DRMFace_GetTextureCoordinateIndex(p,a)    (p)->GetTextureCoordinateIndex(a)
+#define IDirect3DRMFace_GetColor(p,a)                     (p)->GetColor(a)
+#endif
+
+/*****************************************************************************
+ * IDirect3DRMFace2 interface
+ */
+#define INTERFACE IDirect3DRMFace2
+DECLARE_INTERFACE_(IDirect3DRMFace2,IDirect3DRMObject)
+{
+    /*** IUnknown methods ***/
+    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
+    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+    STDMETHOD_(ULONG,Release)(THIS) PURE;
+    /*** IDirect3DRMObject methods ***/
+    STDMETHOD(Clone)(THIS_ LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj) PURE;
+    STDMETHOD(AddDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK, LPVOID argument) PURE;
+    STDMETHOD(DeleteDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK, LPVOID argument) PURE;
+    STDMETHOD(SetAppData)(THIS_ DWORD data) PURE;
+    STDMETHOD_(DWORD, GetAppData)(THIS) PURE;
+    STDMETHOD(SetName)(THIS_ LPCSTR) PURE;
+    STDMETHOD(GetName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE;
+    STDMETHOD(GetClassName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE;
+    /*** IDirect3DRMFace methods ***/
+    STDMETHOD(AddVertex)(THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE;
+    STDMETHOD(AddVertexAndNormalIndexed)(THIS_ DWORD vertex, DWORD normal) PURE;
+    STDMETHOD(SetColorRGB)(THIS_ D3DVALUE, D3DVALUE, D3DVALUE) PURE;
+    STDMETHOD(SetColor)(THIS_ D3DCOLOR) PURE;
+    STDMETHOD(SetTexture)(THIS_ LPDIRECT3DRMTEXTURE3) PURE;
+    STDMETHOD(SetTextureCoordinates)(THIS_ DWORD vertex, D3DVALUE u, D3DVALUE v) PURE;
+    STDMETHOD(SetMaterial)(THIS_ LPDIRECT3DRMMATERIAL2) PURE;
+    STDMETHOD(SetTextureTopology)(THIS_ BOOL wrap_u, BOOL wrap_v) PURE;
+    STDMETHOD(GetVertex)(THIS_ DWORD index, D3DVECTOR *vertex, D3DVECTOR *normal) PURE;
+    STDMETHOD(GetVertices)(THIS_ DWORD *vertex_count, D3DVECTOR *coords, D3DVECTOR *normals);
+    STDMETHOD(GetTextureCoordinates)(THIS_ DWORD vertex, D3DVALUE *u, D3DVALUE *v) PURE;
+    STDMETHOD(GetTextureTopology)(THIS_ BOOL *wrap_u, BOOL *wrap_v) PURE;
+    STDMETHOD(GetNormal)(THIS_ D3DVECTOR *) PURE;
+    STDMETHOD(GetTexture)(THIS_ LPDIRECT3DRMTEXTURE3 *) PURE;
+    STDMETHOD(GetMaterial)(THIS_ LPDIRECT3DRMMATERIAL2 *) PURE;
+    STDMETHOD_(int, GetVertexCount)(THIS) PURE;
+    STDMETHOD_(int, GetVertexIndex)(THIS_ DWORD which) PURE;
+    STDMETHOD_(int, GetTextureCoordinateIndex)(THIS_ DWORD which) PURE;
+    STDMETHOD_(D3DCOLOR, GetColor)(THIS) PURE;
+};
+#undef INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IDirect3DRMFace2_QueryInterface(p,a,b)             (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DRMFace2_AddRef(p)                         (p)->lpVtbl->AddRef(p)
+#define IDirect3DRMFace2_Release(p)                        (p)->lpVtbl->Release(p)
+/*** IDirect3DRMObject methods ***/
+#define IDirect3DRMFace2_Clone(p,a,b,c)                    (p)->lpVtbl->Clone(p,a,b,c)
+#define IDirect3DRMFace2_AddDestroyCallback(p,a,b)         (p)->lpVtbl->AddDestroyCallback(p,a,b)
+#define IDirect3DRMFace2_DeleteDestroyCallback(p,a,b)      (p)->lpVtbl->DeleteDestroyCallback(p,a,b)
+#define IDirect3DRMFace2_SetAppData(p,a)                   (p)->lpVtbl->SetAppData(p,a)
+#define IDirect3DRMFace2_GetAppData(p)                     (p)->lpVtbl->GetAppData(p)
+#define IDirect3DRMFace2_SetName(p,a)                      (p)->lpVtbl->SetName(p,a)
+#define IDirect3DRMFace2_GetName(p,a,b)                    (p)->lpVtbl->GetName(p,a,b)
+#define IDirect3DRMFace2_GetClassName(p,a,b)               (p)->lpVtbl->GetClassName(p,a,b)
+/*** IDirect3DRMFace methods ***/
+#define IDirect3DRMFace2_AddVertex(p,a,b,c)                (p)->lpVtbl->AddVertex(p,a,b,c)
+#define IDirect3DRMFace2_AddVertexAndNormalIndexed(p,a,b)  (p)->lpVtbl->AddVertexAndNormalIndexed(p,a,b)
+#define IDirect3DRMFace2_SetColorRGB(p,a,b,c)              (p)->lpVtbl->SetColorRGB(p,a,b,c)
+#define IDirect3DRMFace2_SetColor(p,a)                     (p)->lpVtbl->SetColor(p,a)
+#define IDirect3DRMFace2_SetTexture(p,a)                   (p)->lpVtbl->SetTexture(p,a)
+#define IDirect3DRMFace2_SetTextureCoordinates(p,a,b,c)    (p)->lpVtbl->SetTextureCoordinates(p,a,b,c)
+#define IDirect3DRMFace2_SetMaterial(p,a)                  (p)->lpVtbl->SetMaterial(p,a)
+#define IDirect3DRMFace2_SetTextureTopology(p,a,b)         (p)->lpVtbl->SetTextureTopology(p,a,b)
+#define IDirect3DRMFace2_GetVertex(p,a,b,c)                (p)->lpVtbl->GetVertex(p,a,b,c)
+#define IDirect3DRMFace2_GetVertices(p,a,b,c)              (p)->lpVtbl->GetVertices(p,a,b,c)
+#define IDirect3DRMFace2_GetTextureCoordinates(p,a,b,c)    (p)->lpVtbl->GetTextureCoordinates(p,a,b,c)
+#define IDirect3DRMFace2_GetTextureTopology(p,a,b)         (p)->lpVtbl->GetTextureTopology(p,a,b)
+#define IDirect3DRMFace2_GetNormal(p,a)                    (p)->lpVtbl->GetNormal(p,a)
+#define IDirect3DRMFace2_GetTexture(p,a)                   (p)->lpVtbl->GetTexture(p,a)
+#define IDirect3DRMFace2_GetVertexCount(p)                 (p)->lpVtbl->GetVertexCount(p)
+#define IDirect3DRMFace2_GetVertexIndex(p,a)               (p)->lpVtbl->GetVertexIndex(p,a)
+#define IDirect3DRMFace2_GetTextureCoordinateIndex(p,a)    (p)->lpVtbl->GetTextureCoordinateIndex(p,a)
+#define IDirect3DRMFace2_GetColor(p,a)                     (p)->lpVtbl->GetColor(p,a)
+#else
+/*** IUnknown methods ***/
+#define IDirect3DRMFace2_QueryInterface(p,a,b)             (p)->QueryInterface(a,b)
+#define IDirect3DRMFace2_AddRef(p)                         (p)->AddRef()
+#define IDirect3DRMFace2_Release(p)                        (p)->Release()
+/*** IDirect3DRMObject methods ***/
+#define IDirect3DRMFace2_Clone(p,a,b,c)                    (p)->Clone(a,b,c)
+#define IDirect3DRMFace2_AddDestroyCallback(p,a,b)         (p)->AddDestroyCallback(a,b)
+#define IDirect3DRMFace2_DeleteDestroyCallback(p,a,b)      (p)->DeleteDestroyCallback(a,b)
+#define IDirect3DRMFace2_SetAppData(p,a)                   (p)->SetAppData(a)
+#define IDirect3DRMFace2_GetAppData(p)                     (p)->GetAppData()
+#define IDirect3DRMFace2_SetName(p,a)                      (p)->SetName(a)
+#define IDirect3DRMFace2_GetName(p,a,b)                    (p)->GetName(a,b)
+#define IDirect3DRMFace2_GetClassName(p,a,b)               (p)->GetClassName(a,b)
+/*** IDirect3DRMFace methods ***/
+#define IDirect3DRMFace2_AddVertex(p,a,b,c)                (p)->AddVertex(a,b,c)
+#define IDirect3DRMFace2_AddVertexAndNormalIndexed(p,a,b)  (p)->AddVertexAndNormalIndexed(a,b)
+#define IDirect3DRMFace2_SetColorRGB(p,a,b,c)              (p)->SetColorRGB(a,b,c)
+#define IDirect3DRMFace2_SetColor(p,a)                     (p)->SetColor(a)
+#define IDirect3DRMFace2_SetTexture(p,a)                   (p)->SetTexture(a)
+#define IDirect3DRMFace2_SetTextureCoordinates(p,a,b,c)    (p)->SetTextureCoordinates(a,b,c)
+#define IDirect3DRMFace2_SetMaterial(p,a)                  (p)->SetMaterial(a)
+#define IDirect3DRMFace2_SetTextureTopology(p,a,b)         (p)->SetTextureTopology(a,b)
+#define IDirect3DRMFace2_GetVertex(p,a,b,c)                (p)->GetVertex(a,b,c)
+#define IDirect3DRMFace2_GetVertices(p,a,b,c)              (p)->GetVertices(a,b,c)
+#define IDirect3DRMFace2_GetTextureCoordinates(p,a,b,c)    (p)->GetTextureCoordinates(a,b,c)
+#define IDirect3DRMFace2_GetTextureTopology(p,a,b)         (p)->GetTextureTopology(a,b)
+#define IDirect3DRMFace2_GetNormal(p,a)                    (p)->GetNormal(a)
+#define IDirect3DRMFace2_GetTexture(p,a)                   (p)->GetTexture(a)
+#define IDirect3DRMFace2_GetVertexCount(p)                 (p)->GetVertexCount()
+#define IDirect3DRMFace2_GetVertexIndex(p,a)               (p)->GetVertexIndex(a)
+#define IDirect3DRMFace2_GetTextureCoordinateIndex(p,a)    (p)->GetTextureCoordinateIndex(a)
+#define IDirect3DRMFace2_GetColor(p,a)                     (p)->GetColor(a)
+#endif
+
+/*****************************************************************************
+ * IDirect3DRMMeshBuilder interface
+ */
+#define INTERFACE IDirect3DRMMeshBuilder
+DECLARE_INTERFACE_(IDirect3DRMMeshBuilder,IDirect3DRMVisual)
+{
+    /*** IUnknown methods ***/
+    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
+    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+    STDMETHOD_(ULONG,Release)(THIS) PURE;
+    /*** IDirect3DRMObject methods ***/
+    STDMETHOD(Clone)(THIS_ LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj) PURE;
+    STDMETHOD(AddDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK, LPVOID argument) PURE;
+    STDMETHOD(DeleteDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK, LPVOID argument) PURE;
+    STDMETHOD(SetAppData)(THIS_ DWORD data) PURE;
+    STDMETHOD_(DWORD, GetAppData)(THIS) PURE;
+    STDMETHOD(SetName)(THIS_ LPCSTR) PURE;
+    STDMETHOD(GetName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE;
+    STDMETHOD(GetClassName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE;
+    /*** IDirect3DRMMeshBuilder methods ***/
+    STDMETHOD(Load)(THIS_ LPVOID filename, LPVOID name, D3DRMLOADOPTIONS loadflags, D3DRMLOADTEXTURECALLBACK, LPVOID pArg) PURE;
+    STDMETHOD(Save)(THIS_ const char *filename, D3DRMXOFFORMAT, D3DRMSAVEOPTIONS save) PURE;
+    STDMETHOD(Scale)(THIS_ D3DVALUE sx, D3DVALUE sy, D3DVALUE sz) PURE;
+    STDMETHOD(Translate)(THIS_ D3DVALUE tx, D3DVALUE ty, D3DVALUE tz) PURE;
+    STDMETHOD(SetColorSource)(THIS_ D3DRMCOLORSOURCE) PURE;
+    STDMETHOD(GetBox)(THIS_ D3DRMBOX *) PURE;
+    STDMETHOD(GenerateNormals)(THIS) PURE;
+    STDMETHOD_(D3DRMCOLORSOURCE, GetColorSource)(THIS) PURE;
+    STDMETHOD(AddMesh)(THIS_ LPDIRECT3DRMMESH) PURE;
+    STDMETHOD(AddMeshBuilder)(THIS_ LPDIRECT3DRMMESHBUILDER) PURE;
+    STDMETHOD(AddFrame)(THIS_ LPDIRECT3DRMFRAME) PURE;
+    STDMETHOD(AddFace)(THIS_ LPDIRECT3DRMFACE) PURE;
+    STDMETHOD(AddFaces)(THIS_ DWORD vcount, D3DVECTOR *vertices, DWORD ncount, D3DVECTOR *normals, DWORD *data,
+        LPDIRECT3DRMFACEARRAY*) PURE;
+    STDMETHOD(ReserveSpace)(THIS_ DWORD vertex_Count, DWORD normal_count, DWORD face_count) PURE;
+    STDMETHOD(SetColorRGB)(THIS_ D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE;
+    STDMETHOD(SetColor)(THIS_ D3DCOLOR) PURE;
+    STDMETHOD(SetTexture)(THIS_ LPDIRECT3DRMTEXTURE) PURE;
+    STDMETHOD(SetMaterial)(THIS_ LPDIRECT3DRMMATERIAL) PURE;
+    STDMETHOD(SetTextureTopology)(THIS_ BOOL wrap_u, BOOL wrap_v) PURE;
+    STDMETHOD(SetQuality)(THIS_ D3DRMRENDERQUALITY) PURE;
+    STDMETHOD(SetPerspective)(THIS_ BOOL) PURE;
+    STDMETHOD(SetVertex)(THIS_ DWORD index, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE;
+    STDMETHOD(SetNormal)(THIS_ DWORD index, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE;
+    STDMETHOD(SetTextureCoordinates)(THIS_ DWORD index, D3DVALUE u, D3DVALUE v) PURE;
+    STDMETHOD(SetVertexColor)(THIS_ DWORD index, D3DCOLOR) PURE;
+    STDMETHOD(SetVertexColorRGB)(THIS_ DWORD index, D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE;
+    STDMETHOD(GetFaces)(THIS_ LPDIRECT3DRMFACEARRAY*) PURE;
+    STDMETHOD(GetVertices)(THIS_ DWORD *vcount, D3DVECTOR *vertices, DWORD *ncount, D3DVECTOR *normals,
+        DWORD *face_data_size, DWORD *face_data) PURE;
+    STDMETHOD(GetTextureCoordinates)(THIS_ DWORD index, D3DVALUE *u, D3DVALUE *v) PURE;
+    STDMETHOD_(int, AddVertex)(THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE;
+    STDMETHOD_(int, AddNormal)(THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE;
+    STDMETHOD(CreateFace)(THIS_ LPDIRECT3DRMFACE*) PURE;
+    STDMETHOD_(D3DRMRENDERQUALITY, GetQuality)(THIS) PURE;
+    STDMETHOD_(BOOL, GetPerspective)(THIS) PURE;
+    STDMETHOD_(int, GetFaceCount)(THIS) PURE;
+    STDMETHOD_(int, GetVertexCount)(THIS) PURE;
+    STDMETHOD_(D3DCOLOR, GetVertexColor)(THIS_ DWORD index) PURE;
+    STDMETHOD(CreateMesh)(THIS_ LPDIRECT3DRMMESH*) PURE;
+};
+#undef INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IDirect3DRMMeshBuilder_QueryInterface(p,a,b)             (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DRMMeshBuilder_AddRef(p)                         (p)->lpVtbl->AddRef(p)
+#define IDirect3DRMMeshBuilder_Release(p)                        (p)->lpVtbl->Release(p)
+/*** IDirect3DRMObject methods ***/
+#define IDirect3DRMMeshBuilder_Clone(p,a,b,c)                    (p)->lpVtbl->Clone(p,a,b,c)
+#define IDirect3DRMMeshBuilder_AddDestroyCallback(p,a,b)         (p)->lpVtbl->AddDestroyCallback(p,a,b)
+#define IDirect3DRMMeshBuilder_DeleteDestroyCallback(p,a,b)      (p)->lpVtbl->DeleteDestroyCallback(p,a,b)
+#define IDirect3DRMMeshBuilder_SetAppData(p,a)                   (p)->lpVtbl->SetAppData(p,a)
+#define IDirect3DRMMeshBuilder_GetAppData(p)                     (p)->lpVtbl->GetAppData(p)
+#define IDirect3DRMMeshBuilder_SetName(p,a)                      (p)->lpVtbl->SetName(p,a)
+#define IDirect3DRMMeshBuilder_GetName(p,a,b)                    (p)->lpVtbl->GetName(p,a,b)
+#define IDirect3DRMMeshBuilder_GetClassName(p,a,b)               (p)->lpVtbl->GetClassName(p,a,b)
+/*** IDirect3DRMMeshBuilder methods ***/
+#define IDirect3DRMMeshBuilder_Load(p,a,b,c,d,e)                 (p)->lpVtbl->Load(p,a,b,c,d,e)
+#define IDirect3DRMMeshBuilder_Save(p,a,b,c)                     (p)->lpVtbl->Save(p,a,b,c)
+#define IDirect3DRMMeshBuilder_Scale(p,a,b,c)                    (p)->lpVtbl->Scale(p,a,b,c)
+#define IDirect3DRMMeshBuilder_Translate(p,a,b,c)                (p)->lpVtbl->Translate(p,a)
+#define IDirect3DRMMeshBuilder_SetColorSource(p,a)               (p)->lpVtbl->SetColorSource(p,a,b,c)
+#define IDirect3DRMMeshBuilder_GetBox(p,a)                       (p)->lpVtbl->GetBox(p,a)
+#define IDirect3DRMMeshBuilder_GenerateNormals(p)                (p)->lpVtbl->GenerateNormals(p)
+#define IDirect3DRMMeshBuilder_GetColorSource(p)                 (p)->lpVtbl->GetColorSource(p)
+#define IDirect3DRMMeshBuilder_AddMesh(p,a)                      (p)->lpVtbl->AddMesh(p,a)
+#define IDirect3DRMMeshBuilder_AddMeshBuilder(p,a)               (p)->lpVtbl->AddMeshBuilder(p,a)
+#define IDirect3DRMMeshBuilder_AddFrame(p,a)                     (p)->lpVtbl->AddFrame(p,a)
+#define IDirect3DRMMeshBuilder_AddFace(p,a)                      (p)->lpVtbl->AddFace(p,a)
+#define IDirect3DRMMeshBuilder_AddFaces(p,a,b,c,d,e,f)           (p)->lpVtbl->AddFaces(p,a,b,c,d,e,f)
+#define IDirect3DRMMeshBuilder_ReserveSpace(p,a,b,c)             (p)->lpVtbl->ReserveSpace(p,a,b,c)
+#define IDirect3DRMMeshBuilder_SetColorRGB(p,a,b,c)              (p)->lpVtbl->SetColorRGB(p,a,b,c)
+#define IDirect3DRMMeshBuilder_SetColor(p,a)                     (p)->lpVtbl->SetColor(p,a)
+#define IDirect3DRMMeshBuilder_SetTexture(p,a)                   (p)->lpVtbl->SetTexture(p,a)
+#define IDirect3DRMMeshBuilder_SetMateria(p,a)                   (p)->lpVtbl->SetMateria(p,a)
+#define IDirect3DRMMeshBuilder_SetTextureTopology(p,a,b)         (p)->lpVtbl->SetTextureTopology(p,a,b)
+#define IDirect3DRMMeshBuilder_SetQuality(p,a)                   (p)->lpVtbl->SetQuality(p,a)
+#define IDirect3DRMMeshBuilder_SetPerspective(p,a)               (p)->lpVtbl->SetPerspective(p,a)
+#define IDirect3DRMMeshBuilder_SetVertex(p,a,b,c,d)              (p)->lpVtbl->SetVertex(p,a,b,c,d)
+#define IDirect3DRMMeshBuilder_SetNormal(p,a,b,c,d)              (p)->lpVtbl->SetNormal(p,a,b,c,d)
+#define IDirect3DRMMeshBuilder_SetTextureCoordinates(p,a,b,c)    (p)->lpVtbl->SetTextureCoordinates(p,a,b,c)
+#define IDirect3DRMMeshBuilder_SetVertexColor(p,a,b)             (p)->lpVtbl->SetVertexColor(p,a,b)
+#define IDirect3DRMMeshBuilder_SetVertexColorRGB(p,a,b,c,d)      (p)->lpVtbl->SetVertexColorRGB(p,a,b,c,d)
+#define IDirect3DRMMeshBuilder_GetFaces(p,a)                     (p)->lpVtbl->GetFaces(p,a)
+#define IDirect3DRMMeshBuilder_GetVertices(p,a,b,c,d,e,f)        (p)->lpVtbl->GetVertices(p,a,b,c,d,e,f)
+#define IDirect3DRMMeshBuilder_GetTextureCoordinates(p,a,b,c)    (p)->lpVtbl->GetTextureCoordinates(p,a,b,c)
+#define IDirect3DRMMeshBuilder_AddVertex(p,a,b,c)                (p)->lpVtbl->AddVertex(p,a,b,c)
+#define IDirect3DRMMeshBuilder_AddNormal(p,a,b,c)                (p)->lpVtbl->AddNormal(p,a,b,c)
+#define IDirect3DRMMeshBuilder_CreateFace(p,a)                   (p)->lpVtbl->CreateFace(p,a)
+#define IDirect3DRMMeshBuilder_GetQuality(p)                     (p)->lpVtbl->GetQuality(p)
+#define IDirect3DRMMeshBuilder_GetPerspective(p)                 (p)->lpVtbl->GetPerspective(p)
+#define IDirect3DRMMeshBuilder_GetFaceCount(p)                   (p)->lpVtbl->GetFaceCount(p)
+#define IDirect3DRMMeshBuilder_GetVertexCount(p)                 (p)->lpVtbl->GetVertexCount(p)
+#define IDirect3DRMMeshBuilder_GetVertexColor(p,a)               (p)->lpVtbl->GetVertexColor(p,a)
+#define IDirect3DRMMeshBuilder_CreateMesh(p,a)                   (p)->lpVtbl->CreateMesh(p,a)
+#else
+/*** IUnknown methods ***/
+#define IDirect3DRMMeshBuilder_QueryInterface(p,a,b)             (p)->QueryInterface(a,b)
+#define IDirect3DRMMeshBuilder_AddRef(p)                         (p)->AddRef()
+#define IDirect3DRMMeshBuilder_Release(p)                        (p)->Release()
+/*** IDirect3DRMObject methods ***/
+#define IDirect3DRMMeshBuilder_Clone(p,a,b,c)                    (p)->Clone(a,b,c)
+#define IDirect3DRMMeshBuilder_AddDestroyCallback(p,a,b)         (p)->AddDestroyCallback(a,b)
+#define IDirect3DRMMeshBuilder_DeleteDestroyCallback(p,a,b)      (p)->DeleteDestroyCallback(a,b)
+#define IDirect3DRMMeshBuilder_SetAppData(p,a)                   (p)->SetAppData(a)
+#define IDirect3DRMMeshBuilder_GetAppData(p)                     (p)->GetAppData()
+#define IDirect3DRMMeshBuilder_SetName(p,a)                      (p)->SetName(a)
+#define IDirect3DRMMeshBuilder_GetName(p,a,b)                    (p)->GetName(a,b)
+#define IDirect3DRMMeshBuilder_GetClassName(p,a,b)               (p)->GetClassName(a,b)
+/*** IDirect3DRMMeshBuilder methods ***/
+#define IDirect3DRMMeshBuilder_Load(p,a,b,c,d,e)                 (p)->Load(a,b,c,d,e)
+#define IDirect3DRMMeshBuilder_Save(p,a,b,c)                     (p)->Save(a,b,c)
+#define IDirect3DRMMeshBuilder_Scale(p,a,b,c)                    (p)->Scale(a,b,c)
+#define IDirect3DRMMeshBuilder_Translate(p,a,b,c)                (p)->Translate(a)
+#define IDirect3DRMMeshBuilder_SetColorSource(p,a)               (p)->SetColorSource(a,b,c)
+#define IDirect3DRMMeshBuilder_GetBox(p,a)                       (p)->GetBox(a)
+#define IDirect3DRMMeshBuilder_GenerateNormals(p)                (p)->GenerateNormals()
+#define IDirect3DRMMeshBuilder_GetColorSource(p)                 (p)->GetColorSource()
+#define IDirect3DRMMeshBuilder_AddMesh(p,a)                      (p)-->AddMesh(a)
+#define IDirect3DRMMeshBuilder_AddMeshBuilder(p,a)               (p)->AddMeshBuilder(a)
+#define IDirect3DRMMeshBuilder_AddFrame(p,a)                     (p)->AddFrame(a)
+#define IDirect3DRMMeshBuilder_AddFace(p,a)                      (p)->AddFace(a)
+#define IDirect3DRMMeshBuilder_AddFaces(p,a,b,c,d,e,f)           (p)->AddFaces(a,b,c,d,e,f)
+#define IDirect3DRMMeshBuilder_ReserveSpace(p,a,b,c)             (p)->ReserveSpace(a,b,c)
+#define IDirect3DRMMeshBuilder_SetColorRGB(p,a,b,c)              (p)->SetColorRGB(a,b,c)
+#define IDirect3DRMMeshBuilder_SetColor(p,a)                     (p)->SetColor(a)
+#define IDirect3DRMMeshBuilder_SetTexture(p,a)                   (p)->SetTexture(a)
+#define IDirect3DRMMeshBuilder_SetMateria(p,a)                   (p)->SetMateria(a)
+#define IDirect3DRMMeshBuilder_SetTextureTopology(p,a,b)         (p)->SetTextureTopology(a,b)
+#define IDirect3DRMMeshBuilder_SetQuality(p,a)                   (p)->SetQuality(a)
+#define IDirect3DRMMeshBuilder_SetPerspective(p,a)               (p)->SetPerspective(a)
+#define IDirect3DRMMeshBuilder_SetVertex(p,a,b,c,d)              (p)->SetVertex(a,b,c,d)
+#define IDirect3DRMMeshBuilder_SetNormal(p,a,b,c,d)              (p)->SetNormal(a,b,c,d)
+#define IDirect3DRMMeshBuilder_SetTextureCoordinates(p,a,b,c)    (p)->SetTextureCoordinates(a,b,c)
+#define IDirect3DRMMeshBuilder_SetVertexColor(p,a,b)             (p)->SetVertexColor(a,b)
+#define IDirect3DRMMeshBuilder_SetVertexColorRGB(p,a,b,c,d)      (p)->SetVertexColorRGB(a,b,c,d)
+#define IDirect3DRMMeshBuilder_GetFaces(p,a)                     (p)->GetFaces(a)
+#define IDirect3DRMMeshBuilder_GetVertices(p,a,b,c,d,e,f)        (p)->GetVertices(a,b,c,d,e,f)
+#define IDirect3DRMMeshBuilder_GetTextureCoordinates(p,a,b,c)    (p)->GetTextureCoordinates(a,b,c)
+#define IDirect3DRMMeshBuilder_AddVertex(p,a,b,c)                (p)->AddVertex(a,b,c)
+#define IDirect3DRMMeshBuilder_AddNormal(p,a,b,c)                (p)->AddNormal(a,b,c)
+#define IDirect3DRMMeshBuilder_CreateFace(p,a)                   (p)->CreateFace(a)
+#define IDirect3DRMMeshBuilder_GetQuality(p)                     (p)->GetQuality()
+#define IDirect3DRMMeshBuilder_GetPerspective(p)                 (p)->GetPerspective()
+#define IDirect3DRMMeshBuilder_GetFaceCount(p)                   (p)->GetFaceCount()
+#define IDirect3DRMMeshBuilder_GetVertexCount(p)                 (p)->GetVertexCount()
+#define IDirect3DRMMeshBuilder_GetVertexColor(p,a)               (p)->GetVertexColor(a)
+#define IDirect3DRMMeshBuilder_CreateMesh(p,a)                   (p)->CreateMesh(a)
+#endif
+
+/*****************************************************************************
+ * IDirect3DRMMeshBuilder2 interface
+ */
+#define INTERFACE IDirect3DRMMeshBuilder2
+DECLARE_INTERFACE_(IDirect3DRMMeshBuilder2,IDirect3DRMMeshBuilder)
+{
+    /*** IUnknown methods ***/
+    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
+    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+    STDMETHOD_(ULONG,Release)(THIS) PURE;
+    /*** IDirect3DRMObject methods ***/
+    STDMETHOD(Clone)(THIS_ LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj) PURE;
+    STDMETHOD(AddDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK, LPVOID argument) PURE;
+    STDMETHOD(DeleteDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK, LPVOID argument) PURE;
+    STDMETHOD(SetAppData)(THIS_ DWORD data) PURE;
+    STDMETHOD_(DWORD, GetAppData)(THIS) PURE;
+    STDMETHOD(SetName)(THIS_ LPCSTR) PURE;
+    STDMETHOD(GetName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE;
+    STDMETHOD(GetClassName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE;
+    /*** IDirect3DRMMeshBuilder methods ***/
+    STDMETHOD(Load)(THIS_ LPVOID filename, LPVOID name, D3DRMLOADOPTIONS loadflags, D3DRMLOADTEXTURECALLBACK, LPVOID pArg) PURE;
+    STDMETHOD(Save)(THIS_ const char *filename, D3DRMXOFFORMAT, D3DRMSAVEOPTIONS save) PURE;
+    STDMETHOD(Scale)(THIS_ D3DVALUE sx, D3DVALUE sy, D3DVALUE sz) PURE;
+    STDMETHOD(Translate)(THIS_ D3DVALUE tx, D3DVALUE ty, D3DVALUE tz) PURE;
+    STDMETHOD(SetColorSource)(THIS_ D3DRMCOLORSOURCE) PURE;
+    STDMETHOD(GetBox)(THIS_ D3DRMBOX *) PURE;
+    STDMETHOD(GenerateNormals)(THIS) PURE;
+    STDMETHOD_(D3DRMCOLORSOURCE, GetColorSource)(THIS) PURE;
+    STDMETHOD(AddMesh)(THIS_ LPDIRECT3DRMMESH) PURE;
+    STDMETHOD(AddMeshBuilder)(THIS_ LPDIRECT3DRMMESHBUILDER) PURE;
+    STDMETHOD(AddFrame)(THIS_ LPDIRECT3DRMFRAME) PURE;
+    STDMETHOD(AddFace)(THIS_ LPDIRECT3DRMFACE) PURE;
+    STDMETHOD(AddFaces)(THIS_ DWORD vcount, D3DVECTOR *vertices, DWORD ncount, D3DVECTOR *normals, DWORD *data,
+        LPDIRECT3DRMFACEARRAY*) PURE;
+    STDMETHOD(ReserveSpace)(THIS_ DWORD vertex_Count, DWORD normal_count, DWORD face_count) PURE;
+    STDMETHOD(SetColorRGB)(THIS_ D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE;
+    STDMETHOD(SetColor)(THIS_ D3DCOLOR) PURE;
+    STDMETHOD(SetTexture)(THIS_ LPDIRECT3DRMTEXTURE) PURE;
+    STDMETHOD(SetMaterial)(THIS_ LPDIRECT3DRMMATERIAL) PURE;
+    STDMETHOD(SetTextureTopology)(THIS_ BOOL wrap_u, BOOL wrap_v) PURE;
+    STDMETHOD(SetQuality)(THIS_ D3DRMRENDERQUALITY) PURE;
+    STDMETHOD(SetPerspective)(THIS_ BOOL) PURE;
+    STDMETHOD(SetVertex)(THIS_ DWORD index, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE;
+    STDMETHOD(SetNormal)(THIS_ DWORD index, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE;
+    STDMETHOD(SetTextureCoordinates)(THIS_ DWORD index, D3DVALUE u, D3DVALUE v) PURE;
+    STDMETHOD(SetVertexColor)(THIS_ DWORD index, D3DCOLOR) PURE;
+    STDMETHOD(SetVertexColorRGB)(THIS_ DWORD index, D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE;
+    STDMETHOD(GetFaces)(THIS_ LPDIRECT3DRMFACEARRAY*) PURE;
+    STDMETHOD(GetVertices)(THIS_ DWORD *vcount, D3DVECTOR *vertices, DWORD *ncount, D3DVECTOR *normals,
+        DWORD *face_data_size, DWORD *face_data) PURE;
+    STDMETHOD(GetTextureCoordinates)(THIS_ DWORD index, D3DVALUE *u, D3DVALUE *v) PURE;
+    STDMETHOD_(int, AddVertex)(THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE;
+    STDMETHOD_(int, AddNormal)(THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE;
+    STDMETHOD(CreateFace)(THIS_ LPDIRECT3DRMFACE*) PURE;
+    STDMETHOD_(D3DRMRENDERQUALITY, GetQuality)(THIS) PURE;
+    STDMETHOD_(BOOL, GetPerspective)(THIS) PURE;
+    STDMETHOD_(int, GetFaceCount)(THIS) PURE;
+    STDMETHOD_(int, GetVertexCount)(THIS) PURE;
+    STDMETHOD_(D3DCOLOR, GetVertexColor)(THIS_ DWORD index) PURE;
+    STDMETHOD(CreateMesh)(THIS_ LPDIRECT3DRMMESH*) PURE;
+    /*** IDirect3DRMMeshBuilder2 methods ***/
+    STDMETHOD(GenerateNormals2)(THIS_ D3DVALUE crease, DWORD flags) PURE;
+    STDMETHOD(GetFace)(THIS_ DWORD index, LPDIRECT3DRMFACE*) PURE;
+};
+#undef INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IDirect3DRMMeshBuilder2_QueryInterface(p,a,b)            (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DRMMeshBuilder2_AddRef(p)                        (p)->lpVtbl->AddRef(p)
+#define IDirect3DRMMeshBuilder2_Release(p)                       (p)->lpVtbl->Release(p)
+/*** IDirect3DRMObject methods ***/
+#define IDirect3DRMMeshBuilder2_Clone(p,a,b,c)                   (p)->lpVtbl->Clone(p,a,b,c)
+#define IDirect3DRMMeshBuilder2_AddDestroyCallback(p,a,b)        (p)->lpVtbl->AddDestroyCallback(p,a,b)
+#define IDirect3DRMMeshBuilder2_DeleteDestroyCallback(p,a,b)     (p)->lpVtbl->DeleteDestroyCallback(p,a,b)
+#define IDirect3DRMMeshBuilder2_SetAppData(p,a)                  (p)->lpVtbl->SetAppData(p,a)
+#define IDirect3DRMMeshBuilder2_GetAppData(p)                    (p)->lpVtbl->GetAppData(p)
+#define IDirect3DRMMeshBuilder2_SetName(p,a)                     (p)->lpVtbl->SetName(p,a)
+#define IDirect3DRMMeshBuilder2_GetName(p,a,b)                   (p)->lpVtbl->GetName(p,a,b)
+#define IDirect3DRMMeshBuilder2_GetClassName(p,a,b)              (p)->lpVtbl->GetClassName(p,a,b)
+/*** IDirect3DRMMeshBuilder methods ***/
+#define IDirect3DRMMeshBuilder2_Load(p,a,b,c,d,e)                (p)->lpVtbl->Load(p,a,b,c,d,e)
+#define IDirect3DRMMeshBuilder2_Save(p,a,b,c)                    (p)->lpVtbl->Save(p,a,b,c)
+#define IDirect3DRMMeshBuilder2_Scale(p,a,b,c)                   (p)->lpVtbl->Scale(p,a,b,c)
+#define IDirect3DRMMeshBuilder2_Translate(p,a,b,c)               (p)->lpVtbl->Translate(p,a)
+#define IDirect3DRMMeshBuilder2_SetColorSource(p,a)              (p)->lpVtbl->SetColorSource(p,a,b,c)
+#define IDirect3DRMMeshBuilder2_GetBox(p,a)                      (p)->lpVtbl->GetBox(p,a)
+#define IDirect3DRMMeshBuilder2_GenerateNormals(p)               (p)->lpVtbl->GenerateNormals(p)
+#define IDirect3DRMMeshBuilder2_GetColorSource(p)                (p)->lpVtbl->GetColorSource(p)
+#define IDirect3DRMMeshBuilder2_AddMesh(p,a)                     (p)->lpVtbl->AddMesh(p,a)
+#define IDirect3DRMMeshBuilder2_AddMeshBuilder(p,a)              (p)->lpVtbl->AddMeshBuilder(p,a)
+#define IDirect3DRMMeshBuilder2_AddFrame(p,a)                    (p)->lpVtbl->AddFrame(p,a)
+#define IDirect3DRMMeshBuilder2_AddFace(p,a)                     (p)->lpVtbl->AddFace(p,a)
+#define IDirect3DRMMeshBuilder2_AddFaces(p,a,b,c,d,e,f)          (p)->lpVtbl->AddFaces(p,a,b,c,d,e,f)
+#define IDirect3DRMMeshBuilder2_ReserveSpace(p,a,b,c)            (p)->lpVtbl->ReserveSpace(p,a,b,c)
+#define IDirect3DRMMeshBuilder2_SetColorRGB(p,a,b,c)             (p)->lpVtbl->SetColorRGB(p,a,b,c)
+#define IDirect3DRMMeshBuilder2_SetColor(p,a)                    (p)->lpVtbl->SetColor(p,a)
+#define IDirect3DRMMeshBuilder2_SetTexture(p,a)                  (p)->lpVtbl->SetTexture(p,a)
+#define IDirect3DRMMeshBuilder2_SetMateria(p,a)                  (p)->lpVtbl->SetMateria(p,a)
+#define IDirect3DRMMeshBuilder2_SetTextureTopology(p,a,b)        (p)->lpVtbl->SetTextureTopology(p,a,b)
+#define IDirect3DRMMeshBuilder2_SetQuality(p,a)                  (p)->lpVtbl->SetQuality(p,a)
+#define IDirect3DRMMeshBuilder2_SetPerspective(p,a)              (p)->lpVtbl->SetPerspective(p,a)
+#define IDirect3DRMMeshBuilder2_SetVertex(p,a,b,c,d)             (p)->lpVtbl->SetVertex(p,a,b,c,d)
+#define IDirect3DRMMeshBuilder2_SetNormal(p,a,b,c,d)             (p)->lpVtbl->SetNormal(p,a,b,c,d)
+#define IDirect3DRMMeshBuilder2_SetTextureCoordinates(p,a,b,c)   (p)->lpVtbl->SetTextureCoordinates(p,a,b,c)
+#define IDirect3DRMMeshBuilder2_SetVertexColor(p,a,b)            (p)->lpVtbl->SetVertexColor(p,a,b)
+#define IDirect3DRMMeshBuilder2_SetVertexColorRGB(p,a,b,c,d)     (p)->lpVtbl->SetVertexColorRGB(p,a,b,c,d)
+#define IDirect3DRMMeshBuilder2_GetFaces(p,a)                    (p)->lpVtbl->GetFaces(p,a)
+#define IDirect3DRMMeshBuilder2_GetVertices(p,a,b,c,d,e,f)       (p)->lpVtbl->GetVertices(p,a,b,c,d,e,f)
+#define IDirect3DRMMeshBuilder2_GetTextureCoordinates(p,a,b,c)   (p)->lpVtbl->GetTextureCoordinates(p,a,b,c)
+#define IDirect3DRMMeshBuilder2_AddVertex(p,a,b,c)               (p)->lpVtbl->AddVertex(p,a,b,c)
+#define IDirect3DRMMeshBuilder2_AddNormal(p,a,b,c)               (p)->lpVtbl->AddNormal(p,a,b,c)
+#define IDirect3DRMMeshBuilder2_CreateFace(p,a)                  (p)->lpVtbl->CreateFace(p,a)
+#define IDirect3DRMMeshBuilder2_GetQuality(p)                    (p)->lpVtbl->GetQuality(p)
+#define IDirect3DRMMeshBuilder2_GetPerspective(p)                (p)->lpVtbl->GetPerspective(p)
+#define IDirect3DRMMeshBuilder2_GetFaceCount(p)                  (p)->lpVtbl->GetFaceCount(p)
+#define IDirect3DRMMeshBuilder2_GetVertexCount(p)                (p)->lpVtbl->GetVertexCount(p)
+#define IDirect3DRMMeshBuilder2_GetVertexColor(p,a)              (p)->lpVtbl->GetVertexColor(p,a)
+#define IDirect3DRMMeshBuilder2_CreateMesh(p,a)                  (p)->lpVtbl->CreateMesh(p,a)
+/*** IDirect3DRMMeshBuilder2 methods ***/
+#define IDirect3DRMMeshBuilder2_GenerateNormals2(p,a,b)          (p)->lpVtbl->GenerateNormals2(p,a,b)
+#define IDirect3DRMMeshBuilder2_GetFace(p,a,b)                   (p)->lpVtbl->GetFace(p,a,b)
+#else
+/*** IUnknown methods ***/
+#define IDirect3DRMMeshBuilder2_QueryInterface(p,a,b)            (p)->QueryInterface(a,b)
+#define IDirect3DRMMeshBuilder2_AddRef(p)                        (p)->AddRef()
+#define IDirect3DRMMeshBuilder2_Release(p)                       (p)->Release()
+/*** IDirect3DRMObject methods ***/
+#define IDirect3DRMMeshBuilder2_Clone(p,a,b,c)                   (p)->Clone(a,b,c)
+#define IDirect3DRMMeshBuilder2_AddDestroyCallback(p,a,b)        (p)->AddDestroyCallback(a,b)
+#define IDirect3DRMMeshBuilder2_DeleteDestroyCallback(p,a,b)     (p)->DeleteDestroyCallback(a,b)
+#define IDirect3DRMMeshBuilder2_SetAppData(p,a)                  (p)->SetAppData(a)
+#define IDirect3DRMMeshBuilder2_GetAppData(p)                    (p)->GetAppData()
+#define IDirect3DRMMeshBuilder2_SetName(p,a)                     (p)->SetName(a)
+#define IDirect3DRMMeshBuilder2_GetName(p,a,b)                   (p)->GetName(a,b)
+#define IDirect3DRMMeshBuilder2_GetClassName(p,a,b)              (p)->GetClassName(a,b)
+/*** IDirect3DRMMeshBuilder methods ***/
+#define IDirect3DRMMeshBuilder2_Load(p,a,b,c,d,e)                (p)->Load(a,b,c,d,e)
+#define IDirect3DRMMeshBuilder2_Save(p,a,b,c)                    (p)->Save(a,b,c)
+#define IDirect3DRMMeshBuilder2_Scale(p,a,b,c)                   (p)->Scale(a,b,c)
+#define IDirect3DRMMeshBuilder2_Translate(p,a,b,c)               (p)->Translate(a)
+#define IDirect3DRMMeshBuilder2_SetColorSource(p,a)              (p)->SetColorSource(a,b,c)
+#define IDirect3DRMMeshBuilder2_GetBox(p,a)                      (p)->GetBox(a)
+#define IDirect3DRMMeshBuilder2_GenerateNormals(p)               (p)->GenerateNormals()
+#define IDirect3DRMMeshBuilder2_GetColorSource(p)                (p)->GetColorSource()
+#define IDirect3DRMMeshBuilder2_AddMesh(p,a)                     (p)-->AddMesh(a)
+#define IDirect3DRMMeshBuilder2_AddMeshBuilder(p,a)              (p)->AddMeshBuilder(a)
+#define IDirect3DRMMeshBuilder2_AddFrame(p,a)                    (p)->AddFrame(a)
+#define IDirect3DRMMeshBuilder2_AddFace(p,a)                     (p)->AddFace(a)
+#define IDirect3DRMMeshBuilder2_AddFaces(p,a,b,c,d,e,f)          (p)->AddFaces(a,b,c,d,e,f)
+#define IDirect3DRMMeshBuilder2_ReserveSpace(p,a,b,c)            (p)->ReserveSpace(a,b,c)
+#define IDirect3DRMMeshBuilder2_SetColorRGB(p,a,b,c)             (p)->SetColorRGB(a,b,c)
+#define IDirect3DRMMeshBuilder2_SetColor(p,a)                    (p)->SetColor(a)
+#define IDirect3DRMMeshBuilder2_SetTexture(p,a)                  (p)->SetTexture(a)
+#define IDirect3DRMMeshBuilder2_SetMateria(p,a)                  (p)->SetMateria(a)
+#define IDirect3DRMMeshBuilder2_SetTextureTopology(p,a,b)        (p)->SetTextureTopology(a,b)
+#define IDirect3DRMMeshBuilder2_SetQuality(p,a)                  (p)->SetQuality(a)
+#define IDirect3DRMMeshBuilder2_SetPerspective(p,a)              (p)->SetPerspective(a)
+#define IDirect3DRMMeshBuilder2_SetVertex(p,a,b,c,d)             (p)->SetVertex(a,b,c,d)
+#define IDirect3DRMMeshBuilder2_SetNormal(p,a,b,c,d)             (p)->SetNormal(a,b,c,d)
+#define IDirect3DRMMeshBuilder2_SetTextureCoordinates(p,a,b,c)   (p)->SetTextureCoordinates(a,b,c)
+#define IDirect3DRMMeshBuilder2_SetVertexColor(p,a,b)            (p)->SetVertexColor(a,b)
+#define IDirect3DRMMeshBuilder2_SetVertexColorRGB(p,a,b,c,d)     (p)->SetVertexColorRGB(a,b,c,d)
+#define IDirect3DRMMeshBuilder2_GetFaces(p,a)                    (p)->GetFaces(a)
+#define IDirect3DRMMeshBuilder2_GetVertices(p,a,b,c,d,e,f)       (p)->GetVertices(a,b,c,d,e,f)
+#define IDirect3DRMMeshBuilder2_GetTextureCoordinates(p,a,b,c)   (p)->GetTextureCoordinates(a,b,c)
+#define IDirect3DRMMeshBuilder2_AddVertex(p,a,b,c)               (p)->AddVertex(a,b,c)
+#define IDirect3DRMMeshBuilder2_AddNormal(p,a,b,c)               (p)->AddNormal(a,b,c)
+#define IDirect3DRMMeshBuilder2_CreateFace(p,a)                  (p)->CreateFace(a)
+#define IDirect3DRMMeshBuilder2_GetQuality(p)                    (p)->GetQuality()
+#define IDirect3DRMMeshBuilder2_GetPerspective(p)                (p)->GetPerspective()
+#define IDirect3DRMMeshBuilder2_GetFaceCount(p)                  (p)->GetFaceCount()
+#define IDirect3DRMMeshBuilder2_GetVertexCount(p)                (p)->GetVertexCount()
+#define IDirect3DRMMeshBuilder2_GetVertexColor(p,a)              (p)->GetVertexColor(a)
+#define IDirect3DRMMeshBuilder2_CreateMesh(p,a)                  (p)->CreateMesh(a)
+/*** IDirect3DRMMeshBuilder2 methods ***/
+#define IDirect3DRMMeshBuilder2_GenerateNormals2(p,a,b)          (p)->GenerateNormals2(a,b)
+#define IDirect3DRMMeshBuilder2_GetFace(p,a,b)                   (p)->GetFace(a,b)
+#endif
+
+/*****************************************************************************
+ * IDirect3DRMMeshBuilder3 interface
+ */
+#define INTERFACE IDirect3DRMMeshBuilder3
+DECLARE_INTERFACE_(IDirect3DRMMeshBuilder3,IDirect3DRMVisual)
+{
+    /*** IUnknown methods ***/
+    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
+    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+    STDMETHOD_(ULONG,Release)(THIS) PURE;
+    /*** IDirect3DRMObject methods ***/
+    STDMETHOD(Clone)(THIS_ LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj) PURE;
+    STDMETHOD(AddDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK, LPVOID argument) PURE;
+    STDMETHOD(DeleteDestroyCallback)(THIS_ D3DRMOBJECTCALLBACK, LPVOID argument) PURE;
+    STDMETHOD(SetAppData)(THIS_ DWORD data) PURE;
+    STDMETHOD_(DWORD, GetAppData)(THIS) PURE;
+    STDMETHOD(SetName)(THIS_ LPCSTR) PURE;
+    STDMETHOD(GetName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE;
+    STDMETHOD(GetClassName)(THIS_ LPDWORD lpdwSize, LPSTR lpName) PURE;
+    /*** IDirect3DRMMeshBuilder3 methods ***/
+    STDMETHOD(Load)(THIS_ LPVOID filename, LPVOID name, D3DRMLOADOPTIONS loadflags, D3DRMLOADTEXTURE3CALLBACK, LPVOID pArg) PURE;
+    STDMETHOD(Save)(THIS_ const char *filename, D3DRMXOFFORMAT, D3DRMSAVEOPTIONS save) PURE;
+    STDMETHOD(Scale)(THIS_ D3DVALUE sx, D3DVALUE sy, D3DVALUE sz) PURE;
+    STDMETHOD(Translate)(THIS_ D3DVALUE tx, D3DVALUE ty, D3DVALUE tz) PURE;
+    STDMETHOD(SetColorSource)(THIS_ D3DRMCOLORSOURCE) PURE;
+    STDMETHOD(GetBox)(THIS_ D3DRMBOX *) PURE;
+    STDMETHOD(GenerateNormals)(THIS_ D3DVALUE crease, DWORD flags) PURE;
+    STDMETHOD_(D3DRMCOLORSOURCE, GetColorSource)(THIS) PURE;
+    STDMETHOD(AddMesh)(THIS_ LPDIRECT3DRMMESH) PURE;
+    STDMETHOD(AddMeshBuilder)(THIS_ LPDIRECT3DRMMESHBUILDER3) PURE;
+    STDMETHOD(AddFrame)(THIS_ LPDIRECT3DRMFRAME3) PURE;
+    STDMETHOD(AddFace)(THIS_ LPDIRECT3DRMFACE2) PURE;
+    STDMETHOD(AddFaces)(THIS_ DWORD vcount, D3DVECTOR *vertices, DWORD ncount, D3DVECTOR *normals, DWORD *data,
+        LPDIRECT3DRMFACEARRAY*) PURE;
+    STDMETHOD(ReserveSpace)(THIS_ DWORD vertex_Count, DWORD normal_count, DWORD face_count) PURE;
+    STDMETHOD(SetColorRGB)(THIS_ D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE;
+    STDMETHOD(SetColor)(THIS_ D3DCOLOR) PURE;
+    STDMETHOD(SetTexture)(THIS_ LPDIRECT3DRMTEXTURE3) PURE;
+    STDMETHOD(SetMaterial)(THIS_ LPDIRECT3DRMMATERIAL2) PURE;
+    STDMETHOD(SetTextureTopology)(THIS_ BOOL wrap_u, BOOL wrap_v) PURE;
+    STDMETHOD(SetQuality)(THIS_ D3DRMRENDERQUALITY) PURE;
+    STDMETHOD(SetPerspective)(THIS_ BOOL) PURE;
+    STDMETHOD(SetVertex)(THIS_ DWORD index, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE;
+    STDMETHOD(SetNormal)(THIS_ DWORD index, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE;
+    STDMETHOD(SetTextureCoordinates)(THIS_ DWORD index, D3DVALUE u, D3DVALUE v) PURE;
+    STDMETHOD(SetVertexColor)(THIS_ DWORD index, D3DCOLOR) PURE;
+    STDMETHOD(SetVertexColorRGB)(THIS_ DWORD index, D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE;
+    STDMETHOD(GetFaces)(THIS_ LPDIRECT3DRMFACEARRAY*) PURE;
+    STDMETHOD(GetGeometry)(THIS_ DWORD *vcount, D3DVECTOR *vertices, DWORD *ncount, D3DVECTOR *normals,
+        DWORD *face_data_size, DWORD *face_data) PURE;
+    STDMETHOD(GetTextureCoordinates)(THIS_ DWORD index, D3DVALUE *u, D3DVALUE *v) PURE;
+    STDMETHOD_(int, AddVertex)(THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE;
+    STDMETHOD_(int, AddNormal)(THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE;
+    STDMETHOD(CreateFace)(THIS_ LPDIRECT3DRMFACE2*) PURE;
+    STDMETHOD_(D3DRMRENDERQUALITY, GetQuality)(THIS) PURE;
+    STDMETHOD_(BOOL, GetPerspective)(THIS) PURE;
+    STDMETHOD_(int, GetFaceCount)(THIS) PURE;
+    STDMETHOD_(int, GetVertexCount)(THIS) PURE;
+    STDMETHOD_(D3DCOLOR, GetVertexColor)(THIS_ DWORD index) PURE;
+    STDMETHOD(CreateMesh)(THIS_ LPDIRECT3DRMMESH*) PURE;
+    STDMETHOD(GetFace)(THIS_ DWORD index, LPDIRECT3DRMFACE2 *) PURE;
+    STDMETHOD(GetVertex)(THIS_ DWORD index, LPD3DVECTOR pVector) PURE;
+    STDMETHOD(GetNormal)(THIS_ DWORD index, LPD3DVECTOR pVector) PURE;
+    STDMETHOD(DeleteVertices)(THIS_ DWORD IndexFirst, DWORD count) PURE;
+    STDMETHOD(DeleteNormals)(THIS_ DWORD IndexFirst, DWORD count) PURE;
+    STDMETHOD(DeleteFace)(THIS_ LPDIRECT3DRMFACE2) PURE;
+    STDMETHOD(Empty)(THIS_ DWORD flags) PURE;
+    STDMETHOD(Optimize)(THIS_ DWORD flags) PURE;
+    STDMETHOD(AddFacesIndexed)(THIS_ DWORD flags, DWORD *pvIndices, DWORD *pIndexFirst, DWORD *pCount) PURE;
+    STDMETHOD(CreateSubMesh)(THIS_ LPUNKNOWN *) PURE;
+    STDMETHOD(GetParentMesh)(THIS_ DWORD, LPUNKNOWN *) PURE;
+    STDMETHOD(GetSubMeshes)(THIS_ LPDWORD pCount, LPUNKNOWN *) PURE;
+    STDMETHOD(DeleteSubMesh)(THIS_ LPUNKNOWN) PURE;
+    STDMETHOD(Enable)(THIS_ DWORD) PURE;
+    STDMETHOD(GetEnable)(THIS_ DWORD *) PURE;
+    STDMETHOD(AddTriangles)(THIS_ DWORD flags, DWORD format, DWORD VertexCount, LPVOID pvData) PURE;
+    STDMETHOD(SetVertices)(THIS_ DWORD IndexFirst, DWORD count, LPD3DVECTOR) PURE;
+    STDMETHOD(GetVertices)(THIS_ DWORD IndexFirst, LPDWORD pCount, LPD3DVECTOR) PURE;
+    STDMETHOD(SetNormals)(THIS_ DWORD IndexFirst, DWORD count, LPD3DVECTOR) PURE;
+    STDMETHOD(GetNormals)(THIS_ DWORD IndexFirst, LPDWORD pCount, LPD3DVECTOR) PURE;
+    STDMETHOD_(int, GetNormalCount)(THIS) PURE;
+};
+#undef INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IDirect3DRMMeshBuilder3_QueryInterface(p,a,b)            (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DRMMeshBuilder3_AddRef(p)                        (p)->lpVtbl->AddRef(p)
+#define IDirect3DRMMeshBuilder3_Release(p)                       (p)->lpVtbl->Release(p)
+/*** IDirect3DRMObject methods ***/
+#define IDirect3DRMMeshBuilder3_Clone(p,a,b,c)                   (p)->lpVtbl->Clone(p,a,b,c)
+#define IDirect3DRMMeshBuilder3_AddDestroyCallback(p,a,b)        (p)->lpVtbl->AddDestroyCallback(p,a,b)
+#define IDirect3DRMMeshBuilder3_DeleteDestroyCallback(p,a,b)     (p)->lpVtbl->DeleteDestroyCallback(p,a,b)
+#define IDirect3DRMMeshBuilder3_SetAppData(p,a)                  (p)->lpVtbl->SetAppData(p,a)
+#define IDirect3DRMMeshBuilder3_GetAppData(p)                    (p)->lpVtbl->GetAppData(p)
+#define IDirect3DRMMeshBuilder3_SetName(p,a)                     (p)->lpVtbl->SetName(p,a)
+#define IDirect3DRMMeshBuilder3_GetName(p,a,b)                   (p)->lpVtbl->GetName(p,a,b)
+#define IDirect3DRMMeshBuilder3_GetClassName(p,a,b)              (p)->lpVtbl->GetClassName(p,a,b)
+/*** IDirect3DRMMeshBuilder3 methods ***/
+#define IDirect3DRMMeshBuilder3_Load(p,a,b,c,d,e)                (p)->lpVtbl->Load(p,a,b,c,d,e)
+#define IDirect3DRMMeshBuilder3_Save(p,a,b,c)                    (p)->lpVtbl->Save(p,a,b,c)
+#define IDirect3DRMMeshBuilder3_Scale(p,a,b,c)                   (p)->lpVtbl->Scale(p,a,b,c)
+#define IDirect3DRMMeshBuilder3_Translate(p,a,b,c)               (p)->lpVtbl->Translate(p,a)
+#define IDirect3DRMMeshBuilder3_SetColorSource(p,a)              (p)->lpVtbl->SetColorSource(p,a,b,c)
+#define IDirect3DRMMeshBuilder3_GetBox(p,a)                      (p)->lpVtbl->GetBox(p,a)
+#define IDirect3DRMMeshBuilder3_GenerateNormals(p,a,b)           (p)->lpVtbl->GenerateNormals(p,a,b)
+#define IDirect3DRMMeshBuilder3_GetColorSource(p)                (p)->lpVtbl->GetColorSource(p)
+#define IDirect3DRMMeshBuilder3_AddMesh(p,a)                     (p)->lpVtbl->AddMesh(p,a)
+#define IDirect3DRMMeshBuilder3_AddMeshBuilder(p,a)              (p)->lpVtbl->AddMeshBuilder(p,a)
+#define IDirect3DRMMeshBuilder3_AddFrame(p,a)                    (p)->lpVtbl->AddFrame(p,a)
+#define IDirect3DRMMeshBuilder3_AddFace(p,a)                     (p)->lpVtbl->AddFace(p,a)
+#define IDirect3DRMMeshBuilder3_AddFaces(p,a,b,c,d,e,f)          (p)->lpVtbl->AddFaces(p,a,b,c,d,e,f)
+#define IDirect3DRMMeshBuilder3_ReserveSpace(p,a,b,c)            (p)->lpVtbl->ReserveSpace(p,a,b,c)
+#define IDirect3DRMMeshBuilder3_SetColorRGB(p,a,b,c)             (p)->lpVtbl->SetColorRGB(p,a,b,c)
+#define IDirect3DRMMeshBuilder3_SetColor(p,a)                    (p)->lpVtbl->SetColor(p,a)
+#define IDirect3DRMMeshBuilder3_SetTexture(p,a)                  (p)->lpVtbl->SetTexture(p,a)
+#define IDirect3DRMMeshBuilder3_SetMateria(p,a)                  (p)->lpVtbl->SetMateria(p,a)
+#define IDirect3DRMMeshBuilder3_SetTextureTopology(p,a,b)        (p)->lpVtbl->SetTextureTopology(p,a,b)
+#define IDirect3DRMMeshBuilder3_SetQuality(p,a)                  (p)->lpVtbl->SetQuality(p,a)
+#define IDirect3DRMMeshBuilder3_SetPerspective(p,a)              (p)->lpVtbl->SetPerspective(p,a)
+#define IDirect3DRMMeshBuilder3_SetVertex(p,a,b,c,d)             (p)->lpVtbl->SetVertex(p,a,b,c,d)
+#define IDirect3DRMMeshBuilder3_SetNormal(p,a,b,c,d)             (p)->lpVtbl->SetNormal(p,a,b,c,d)
+#define IDirect3DRMMeshBuilder3_SetTextureCoordinates(p,a,b,c)   (p)->lpVtbl->SetTextureCoordinates(p,a,b,c)
+#define IDirect3DRMMeshBuilder3_SetVertexColor(p,a,b)            (p)->lpVtbl->SetVertexColor(p,a,b)
+#define IDirect3DRMMeshBuilder3_SetVertexColorRGB(p,a,b,c,d)     (p)->lpVtbl->SetVertexColorRGB(p,a,b,c,d)
+#define IDirect3DRMMeshBuilder3_GetFaces(p,a)                    (p)->lpVtbl->GetFaces(p,a)
+#define IDirect3DRMMeshBuilder3_GetGeometry(p,a,b,c,d,e,f)       (p)->lpVtbl->GetGeometry(p,a,b,c,d,e,f)
+#define IDirect3DRMMeshBuilder3_GetTextureCoordinates(p,a,b,c)   (p)->lpVtbl->GetTextureCoordinates(p,a,b,c)
+#define IDirect3DRMMeshBuilder3_AddVertex(p,a,b,c)               (p)->lpVtbl->AddVertex(p,a,b,c)
+#define IDirect3DRMMeshBuilder3_AddNormal(p,a,b,c)               (p)->lpVtbl->AddNormal(p,a,b,c)
+#define IDirect3DRMMeshBuilder3_CreateFace(p,a)                  (p)->lpVtbl->CreateFace(p,a)
+#define IDirect3DRMMeshBuilder3_GetQuality(p)                    (p)->lpVtbl->GetQuality(p)
+#define IDirect3DRMMeshBuilder3_GetPerspective(p)                (p)->lpVtbl->GetPerspective(p)
+#define IDirect3DRMMeshBuilder3_GetFaceCount(p)                  (p)->lpVtbl->GetFaceCount(p)
+#define IDirect3DRMMeshBuilder3_GetVertexCount(p)                (p)->lpVtbl->GetVertexCount(p)
+#define IDirect3DRMMeshBuilder3_GetVertexColor(p,a)              (p)->lpVtbl->GetVertexColor(p,a)
+#define IDirect3DRMMeshBuilder3_CreateMesh(p,a)                  (p)->lpVtbl->CreateMesh(p,a)
+#define IDirect3DRMMeshBuilder3_GetFace(p,a,b)                   (p)->lpVtbl->GetFace(p,a,b)
+#define IDirect3DRMMeshBuilder3_GetVertex(p,a,b)                 (p)->lpVtbl->GetVertex(p,a,b)
+#define IDirect3DRMMeshBuilder3_GetNormal(p,a,b)                 (p)->lpVtbl->GetNormal(p,a,b)
+#define IDirect3DRMMeshBuilder3_DeleteVertices(p,a,b)            (p)->lpVtbl->DeleteVertices(p,a,b)
+#define IDirect3DRMMeshBuilder3_DeleteNormals(p,a,b)             (p)->lpVtbl->DeleteNormals(p,a,b)
+#define IDirect3DRMMeshBuilder3_DeleteFace(p,a)                  (p)->lpVtbl->DeleteFace(p,a)
+#define IDirect3DRMMeshBuilder3_Empty(p,a)                       (p)->lpVtbl->Empty(p,a)
+#define IDirect3DRMMeshBuilder3_Optimize(p,a)                    (p)->lpVtbl->Optimize(p,a)
+#define IDirect3DRMMeshBuilder3_AddFacesIndexed(p,a,b,c,d)       (p)->lpVtbl->AddFacesIndexed(p,a,b,c,d)
+#define IDirect3DRMMeshBuilder3_CreateSubMesh(p,a)               (p)->lpVtbl->CreateSubMesh(p,a)
+#define IDirect3DRMMeshBuilder3_GetParentMesh(p,a,b)             (p)->lpVtbl->GetParentMesh(p,a,b)
+#define IDirect3DRMMeshBuilder3_GetSubMeshes(p,a,b)              (p)->lpVtbl->GetSubMeshes(p,a,b)
+#define IDirect3DRMMeshBuilder3_DeleteSubMesh(p,a)               (p)->lpVtbl->DeleteSubMesh(p,a)
+#define IDirect3DRMMeshBuilder3_Enable(p,a)                      (p)->lpVtbl->Enable(p,a)
+#define IDirect3DRMMeshBuilder3_AddTriangles(p,a,b,c,d)          (p)->lpVtbl->AddTriangles(p,a,b,c,d)
+#define IDirect3DRMMeshBuilder3_SetVertices(p,a,b,c)             (p)->lpVtbl->SetVertices(p,a,b,c)
+#define IDirect3DRMMeshBuilder3_GetVertices(p,a,b,c)             (p)->lpVtbl->GetVertices(p,a,b,c)
+#define IDirect3DRMMeshBuilder3_SetNormals(p,a,b,c)              (p)->lpVtbl->SetNormals(p,a,b,c)
+#define IDirect3DRMMeshBuilder3_GetNormals(p,a,b,c)              (p)->lpVtbl->GetNormals(p,a,b,c)
+#define IDirect3DRMMeshBuilder3_GetNormalCount(p)                (p)->lpVtbl->GetNormalCount(p,a)
+#else
+/*** IUnknown methods ***/
+#define IDirect3DRMMeshBuilder3_QueryInterface(p,a,b)            (p)->QueryInterface(a,b)
+#define IDirect3DRMMeshBuilder3_AddRef(p)                        (p)->AddRef()
+#define IDirect3DRMMeshBuilder3_Release(p)                       (p)->Release()
+/*** IDirect3DRMObject methods ***/
+#define IDirect3DRMMeshBuilder3_Clone(p,a,b,c)                   (p)->Clone(a,b,c)
+#define IDirect3DRMMeshBuilder3_AddDestroyCallback(p,a,b)        (p)->AddDestroyCallback(a,b)
+#define IDirect3DRMMeshBuilder3_DeleteDestroyCallback(p,a,b)     (p)->DeleteDestroyCallback(a,b)
+#define IDirect3DRMMeshBuilder3_SetAppData(p,a)                  (p)->SetAppData(a)
+#define IDirect3DRMMeshBuilder3_GetAppData(p)                    (p)->GetAppData()
+#define IDirect3DRMMeshBuilder3_SetName(p,a)                     (p)->SetName(a)
+#define IDirect3DRMMeshBuilder3_GetName(p,a,b)                   (p)->GetName(a,b)
+#define IDirect3DRMMeshBuilder3_GetClassName(p,a,b)              (p)->GetClassName(a,b)
+/*** IDirect3DRMMeshBuilder3 methods ***/
+#define IDirect3DRMMeshBuilder3_Load(p,a,b,c,d,e)                (p)->Load(a,b,c,d,e)
+#define IDirect3DRMMeshBuilder3_Save(p,a,b,c)                    (p)->Save(a,b,c)
+#define IDirect3DRMMeshBuilder3_Scale(p,a,b,c)                   (p)->Scale(a,b,c)
+#define IDirect3DRMMeshBuilder3_Translate(p,a,b,c)               (p)->Translate(a)
+#define IDirect3DRMMeshBuilder3_SetColorSource(p,a)              (p)->SetColorSource(a,b,c)
+#define IDirect3DRMMeshBuilder3_GetBox(p,a)                      (p)->GetBox(a)
+#define IDirect3DRMMeshBuilder3_GenerateNormals(p,a,b)           (p)->GenerateNormals(a,b)
+#define IDirect3DRMMeshBuilder3_GetColorSource(p)                (p)->GetColorSource()
+#define IDirect3DRMMeshBuilder3_AddMesh(p,a)                     (p)-->AddMesh(a)
+#define IDirect3DRMMeshBuilder3_AddMeshBuilder(p,a)              (p)->AddMeshBuilder(a)
+#define IDirect3DRMMeshBuilder3_AddFrame(p,a)                    (p)->AddFrame(a)
+#define IDirect3DRMMeshBuilder3_AddFace(p,a)                     (p)->AddFace(a)
+#define IDirect3DRMMeshBuilder3_AddFaces(p,a,b,c,d,e,f)          (p)->AddFaces(a,b,c,d,e,f)
+#define IDirect3DRMMeshBuilder3_ReserveSpace(p,a,b,c)            (p)->ReserveSpace(a,b,c)
+#define IDirect3DRMMeshBuilder3_SetColorRGB(p,a,b,c)             (p)->SetColorRGB(a,b,c)
+#define IDirect3DRMMeshBuilder3_SetColor(p,a)                    (p)->SetColor(a)
+#define IDirect3DRMMeshBuilder3_SetTexture(p,a)                  (p)->SetTexture(a)
+#define IDirect3DRMMeshBuilder3_SetMateria(p,a)                  (p)->SetMateria(a)
+#define IDirect3DRMMeshBuilder3_SetTextureTopology(p,a,b)        (p)->SetTextureTopology(a,b)
+#define IDirect3DRMMeshBuilder3_SetQuality(p,a)                  (p)->SetQuality(a)
+#define IDirect3DRMMeshBuilder3_SetPerspective(p,a)              (p)->SetPerspective(a)
+#define IDirect3DRMMeshBuilder3_SetVertex(p,a,b,c,d)             (p)->SetVertex(a,b,c,d)
+#define IDirect3DRMMeshBuilder3_SetNormal(p,a,b,c,d)             (p)->SetNormal(a,b,c,d)
+#define IDirect3DRMMeshBuilder3_SetTextureCoordinates(p,a,b,c)   (p)->SetTextureCoordinates(a,b,c)
+#define IDirect3DRMMeshBuilder3_SetVertexColor(p,a,b)            (p)->SetVertexColor(a,b)
+#define IDirect3DRMMeshBuilder3_SetVertexColorRGB(p,a,b,c,d)     (p)->SetVertexColorRGB(a,b,c,d)
+#define IDirect3DRMMeshBuilder3_GetFaces(p,a)                    (p)->GetFaces(a)
+#define IDirect3DRMMeshBuilder3_GetGeometry(p,a,b,c,d,e,f)       (p)->GetGeometry(a,b,c,d,e,f)
+#define IDirect3DRMMeshBuilder3_GetTextureCoordinates(p,a,b,c)   (p)->GetTextureCoordinates(a,b,c)
+#define IDirect3DRMMeshBuilder3_AddVertex(p,a,b,c)               (p)->AddVertex(a,b,c)
+#define IDirect3DRMMeshBuilder3_AddNormal(p,a,b,c)               (p)->AddNormal(a,b,c)
+#define IDirect3DRMMeshBuilder3_CreateFace(p,a)                  (p)->CreateFace(a)
+#define IDirect3DRMMeshBuilder3_GetQuality(p)                    (p)->GetQuality()
+#define IDirect3DRMMeshBuilder3_GetPerspective(p)                (p)->GetPerspective()
+#define IDirect3DRMMeshBuilder3_GetFaceCount(p)                  (p)->GetFaceCount()
+#define IDirect3DRMMeshBuilder3_GetVertexCount(p)                (p)->GetVertexCount()
+#define IDirect3DRMMeshBuilder3_GetVertexColor(p,a)              (p)->GetVertexColor(a)
+#define IDirect3DRMMeshBuilder3_CreateMesh(p,a)                  (p)->CreateMesh(a)
+#define IDirect3DRMMeshBuilder3_GetFace(p,a,b)                   (p)->GetFace(p,a,b)
+#define IDirect3DRMMeshBuilder3_GetVertex(p,a,b)                 (p)->GetVertex(p,a,b)
+#define IDirect3DRMMeshBuilder3_GetNormal(p,a,b)                 (p)->GetNormal(p,a,b)
+#define IDirect3DRMMeshBuilder3_DeleteVertices(p,a,b)            (p)->DeleteVertices(p,a,b)
+#define IDirect3DRMMeshBuilder3_DeleteNormals(p,a,b)             (p)->DeleteNormals(p,a,b)
+#define IDirect3DRMMeshBuilder3_DeleteFace(p,a)                  (p)->DeleteFace(p,a)
+#define IDirect3DRMMeshBuilder3_Empty(p,a)                       (p)->Empty(p,a)
+#define IDirect3DRMMeshBuilder3_Optimize(p,a)                    (p)->Optimize(p,a)
+#define IDirect3DRMMeshBuilder3_AddFacesIndexed(p,a,b,c,d)       (p)->AddFacesIndexed(p,a,b,c,d)
+#define IDirect3DRMMeshBuilder3_CreateSubMesh(p,a)               (p)->CreateSubMesh(p,a)
+#define IDirect3DRMMeshBuilder3_GetParentMesh(p,a,b)             (p)->GetParentMesh(p,a,b)
+#define IDirect3DRMMeshBuilder3_GetSubMeshes(p,a,b)              (p)->GetSubMeshes(p,a,b)
+#define IDirect3DRMMeshBuilder3_DeleteSubMesh(p,a)               (p)->DeleteSubMesh(p,a)
+#define IDirect3DRMMeshBuilder3_Enable(p,a)                      (p)->Enable(p,a)
+#define IDirect3DRMMeshBuilder3_AddTriangles(p,a,b,c,d)          (p)->AddTriangles(p,a,b,c,d)
+#define IDirect3DRMMeshBuilder3_SetVertices(p,a,b,c)             (p)->SetVertices(p,a,b,c)
+#define IDirect3DRMMeshBuilder3_GetVertices(p,a,b,c)             (p)->GetVertices(p,a,b,c)
+#define IDirect3DRMMeshBuilder3_SetNormals(p,a,b,c)              (p)->SetNormals(p,a,b,c)
+#define IDirect3DRMMeshBuilder3_GetNormals(p,a,b,c)              (p)->GetNormals(p,a,b,c)
+#define IDirect3DRMMeshBuilder3_GetNormalCount(p)                (p)->GetNormalCount(p,a)
+#endif
+
 #ifdef __cplusplus
 };
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3dx8.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3dx8.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3dx8.h	(revision 28475)
@@ -26,49 +26,4 @@
  */
 
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
- */
-
 #ifndef __D3DX8_H__
 #define __D3DX8_H__
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3dx8core.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3dx8core.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3dx8core.h	(revision 28475)
@@ -15,49 +15,4 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
  */
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3dx8math.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3dx8math.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3dx8math.h	(revision 28475)
@@ -16,49 +16,4 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
  */
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3dx8math.inl
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3dx8math.inl	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3dx8math.inl	(revision 28475)
@@ -27,49 +27,4 @@
  */
 
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
- */
-
 #ifndef __D3DX8MATH_INL__
 #define __D3DX8MATH_INL__
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3dx8mesh.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3dx8mesh.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3dx8mesh.h	(revision 28475)
@@ -15,49 +15,4 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
  */
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3dx9.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3dx9.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3dx9.h	(revision 28475)
@@ -42,4 +42,5 @@
 #include "d3dx9mesh.h"
 #include "d3dx9shader.h"
+#include "d3dx9effect.h"
 #include "d3dx9tex.h"
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3dx9mesh.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3dx9mesh.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3dx9mesh.h	(revision 28475)
@@ -31,4 +31,102 @@
 #define __WINE_D3DX9MESH_H
 
+DEFINE_GUID(IID_ID3DXBaseMesh, 0x7ed943dd, 0x52e8, 0x40b5, 0xa8, 0xd8, 0x76, 0x68, 0x5c, 0x40, 0x63, 0x30);
+DEFINE_GUID(IID_ID3DXMesh,     0x4020e5c2, 0x1403, 0x4929, 0x88, 0x3f, 0xe2, 0xe8, 0x49, 0xfa, 0xc1, 0x95);
+
+enum _MAX_FVF_DECL_SIZE
+{
+    MAX_FVF_DECL_SIZE = MAXD3DDECLLENGTH + 1
+};
+
+typedef struct ID3DXBaseMesh* LPD3DXBASEMESH;
+typedef struct ID3DXMesh* LPD3DXMESH;
+
+typedef struct _D3DXATTRIBUTERANGE {
+    DWORD AttribId;
+    DWORD FaceStart;
+    DWORD FaceCount;
+    DWORD VertexStart;
+    DWORD VertexCount;
+} D3DXATTRIBUTERANGE;
+
+typedef D3DXATTRIBUTERANGE* LPD3DXATTRIBUTERANGE;
+
+#undef INTERFACE
+#define INTERFACE ID3DXBaseMesh
+
+DECLARE_INTERFACE_(ID3DXBaseMesh, IUnknown)
+{
+    /*** IUnknown methods ***/
+    STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID* object) PURE;
+    STDMETHOD_(ULONG, AddRef)(THIS) PURE;
+    STDMETHOD_(ULONG, Release)(THIS) PURE;
+    /*** ID3DXBaseMesh ***/
+    STDMETHOD(DrawSubset)(THIS_ DWORD attrib_id) PURE;
+    STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE;
+    STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE;
+    STDMETHOD_(DWORD, GetFVF)(THIS) PURE;
+    STDMETHOD(GetDeclaration)(THIS_ D3DVERTEXELEMENT9 declaration[MAX_FVF_DECL_SIZE]) PURE;
+    STDMETHOD_(DWORD, GetNumBytesPerVertex)(THIS) PURE;
+    STDMETHOD_(DWORD, GetOptions)(THIS) PURE;
+    STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* device) PURE;
+    STDMETHOD(CloneMeshFVF)(THIS_ DWORD options, DWORD fvf, LPDIRECT3DDEVICE9 device, LPD3DXMESH* clone_mesh) PURE;
+    STDMETHOD(CloneMesh)(THIS_ DWORD options, CONST D3DVERTEXELEMENT9* declaration, LPDIRECT3DDEVICE9 device,
+        LPD3DXMESH* clone_mesh) PURE;
+    STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER9* vertex_buffer) PURE;
+    STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER9* index_buffer) PURE;
+    STDMETHOD(LockVertexBuffer)(THIS_ DWORD flags, LPVOID* data) PURE;
+    STDMETHOD(UnlockVertexBuffer)(THIS) PURE;
+    STDMETHOD(LockIndexBuffer)(THIS_ DWORD flags, LPVOID* data) PURE;
+    STDMETHOD(UnlockIndexBuffer)(THIS) PURE;
+    STDMETHOD(GetAttributeTable)(THIS_ D3DXATTRIBUTERANGE* attrib_table, DWORD* attrib_table_size) PURE;
+    STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* point_reps, DWORD* adjacency) PURE;
+    STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* adjacency, DWORD* point_reps) PURE;
+    STDMETHOD(GenerateAdjacency)(THIS_ FLOAT epsilon, DWORD* adjacency) PURE;
+    STDMETHOD(UpdateSemantics)(THIS_ D3DVERTEXELEMENT9 declaration[MAX_FVF_DECL_SIZE]) PURE;
+};
+
+
+#undef INTERFACE
+#define INTERFACE ID3DXMesh
+
+DECLARE_INTERFACE_(ID3DXMesh, ID3DXBaseMesh)
+{
+    /*** IUnknown methods ***/
+    STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID* object) PURE;
+    STDMETHOD_(ULONG, AddRef)(THIS) PURE;
+    STDMETHOD_(ULONG, Release)(THIS) PURE;
+    /*** ID3DXBaseMesh ***/
+    STDMETHOD(DrawSubset)(THIS_ DWORD attrib_id) PURE;
+    STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE;
+    STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE;
+    STDMETHOD_(DWORD, GetFVF)(THIS) PURE;
+    STDMETHOD(GetDeclaration)(THIS_ D3DVERTEXELEMENT9 declaration[MAX_FVF_DECL_SIZE]) PURE;
+    STDMETHOD_(DWORD, GetNumBytesPerVertex)(THIS) PURE;
+    STDMETHOD_(DWORD, GetOptions)(THIS) PURE;
+    STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* device) PURE;
+    STDMETHOD(CloneMeshFVF)(THIS_ DWORD options, DWORD fvf, LPDIRECT3DDEVICE9 device, LPD3DXMESH* clone_mesh) PURE;
+    STDMETHOD(CloneMesh)(THIS_ DWORD options, CONST D3DVERTEXELEMENT9* declaration, LPDIRECT3DDEVICE9 device,
+        LPD3DXMESH* clone_mesh) PURE;
+    STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER9* vertex_buffer) PURE;
+    STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER9* index_buffer) PURE;
+    STDMETHOD(LockVertexBuffer)(THIS_ DWORD flags, LPVOID* data) PURE;
+    STDMETHOD(UnlockVertexBuffer)(THIS) PURE;
+    STDMETHOD(LockIndexBuffer)(THIS_ DWORD flags, LPVOID* data) PURE;
+    STDMETHOD(UnlockIndexBuffer)(THIS) PURE;
+    STDMETHOD(GetAttributeTable)(THIS_ D3DXATTRIBUTERANGE* attrib_table, DWORD* attrib_table_size) PURE;
+    STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* point_reps, DWORD* adjacency) PURE;
+    STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* adjacency, DWORD* point_reps) PURE;
+    STDMETHOD(GenerateAdjacency)(THIS_ FLOAT epsilon, DWORD* adjacency) PURE;
+    STDMETHOD(UpdateSemantics)(THIS_ D3DVERTEXELEMENT9 declaration[MAX_FVF_DECL_SIZE]) PURE;
+    /*** ID3DXMesh ***/
+    STDMETHOD(LockAttributeBuffer)(THIS_ DWORD flags, DWORD** data) PURE;
+    STDMETHOD(UnlockAttributeBuffer)(THIS) PURE;
+    STDMETHOD(Optimize)(THIS_ DWORD flags, CONST DWORD* adjacency_in, DWORD* adjacency_out,
+        DWORD* face_remap, LPD3DXBUFFER* vertex_remap, LPD3DXMESH* opt_mesh) PURE;
+    STDMETHOD(OptimizeInplace)(THIS_ DWORD flags, CONST DWORD* adjacency_in, DWORD* adjacency_out,
+                     DWORD* face_remap, LPD3DXBUFFER* vertex_remap) PURE;
+    STDMETHOD(SetAttributeTable)(THIS_ CONST D3DXATTRIBUTERANGE* attrib_table, DWORD attrib_table_size) PURE;
+};
+
 #ifdef __cplusplus
 extern "C" {
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3dx9shader.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3dx9shader.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3dx9shader.h	(revision 28475)
@@ -53,4 +53,13 @@
 
 typedef LPCSTR D3DXHANDLE;
+
+typedef enum _D3DXREGISTER_SET
+{
+    D3DXRS_BOOL,
+    D3DXRS_INT4,
+    D3DXRS_FLOAT4,
+    D3DXRS_SAMPLER,
+    D3DXRS_FORCE_DWORD = 0x7fffffff
+} D3DXREGISTER_SET, *LPD3DXREGISTER_SET;
 
 typedef enum D3DXPARAMETER_CLASS
@@ -90,4 +99,132 @@
 } D3DXPARAMETER_TYPE, *LPD3DXPARAMETER_TYPE;
 
+typedef struct _D3DXCONSTANTTABLE_DESC
+{
+    LPCSTR Creator;
+    DWORD Version;
+    UINT Constants;
+} D3DXCONSTANTTABLE_DESC, *LPD3DXCONSTANTTABLE_DESC;
+
+typedef struct _D3DXCONSTANT_DESC
+{
+    LPCSTR Name;
+    D3DXREGISTER_SET RegisterSet;
+    UINT RegisterIndex;
+    UINT RegisterCount;
+    D3DXPARAMETER_CLASS Class;
+    D3DXPARAMETER_TYPE Type;
+    UINT Rows;
+    UINT Columns;
+    UINT Elements;
+    UINT StructMembers;
+    UINT Bytes;
+    LPCVOID DefaultValue;
+} D3DXCONSTANT_DESC, *LPD3DXCONSTANT_DESC;
+
+DEFINE_GUID(IID_ID3DXConstantTable, 0x9dca3190, 0x38b9, 0x4fc3, 0x92, 0xe3, 0x39, 0xc6, 0xdd, 0xfb, 0x35, 0x8b);
+
+#undef INTERFACE
+#define INTERFACE ID3DXConstantTable
+
+DECLARE_INTERFACE_(ID3DXConstantTable, ID3DXBuffer)
+{
+    /*** IUnknown methods ***/
+    STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
+    STDMETHOD_(ULONG, AddRef)(THIS) PURE;
+    STDMETHOD_(ULONG, Release)(THIS) PURE;
+    /*** ID3DXBuffer methods ***/
+    STDMETHOD_(LPVOID, GetBufferPointer)(THIS) PURE;
+    STDMETHOD_(DWORD, GetBufferSize)(THIS) PURE;
+    /*** ID3DXConstantTable methods ***/
+    STDMETHOD(GetDesc)(THIS_ D3DXCONSTANTTABLE_DESC *pDesc) PURE;
+    STDMETHOD(GetConstantDesc)(THIS_ D3DXHANDLE hConstant, D3DXCONSTANT_DESC *pConstantDesc, UINT *pCount) PURE;
+    STDMETHOD_(UINT, GetSamplerIndex)(THIS_ D3DXHANDLE hConstant) PURE;
+    STDMETHOD_(D3DXHANDLE, GetConstant)(THIS_ D3DXHANDLE hConstant, UINT Index) PURE;
+    STDMETHOD_(D3DXHANDLE, GetConstantByName)(THIS_ D3DXHANDLE hConstant, LPCSTR pName) PURE;
+    STDMETHOD_(D3DXHANDLE, GetConstantElement)(THIS_ D3DXHANDLE hConstant, UINT Index) PURE;
+    STDMETHOD(SetDefaults)(THIS_ LPDIRECT3DDEVICE9 pDevice) PURE;
+    STDMETHOD(SetValue)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, LPCVOID pData, UINT Bytes) PURE;
+    STDMETHOD(SetBool)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, BOOL b) PURE;
+    STDMETHOD(SetBoolArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST BOOL* pb, UINT Count) PURE;
+    STDMETHOD(SetInt)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, INT n) PURE;
+    STDMETHOD(SetIntArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST INT* pn, UINT Count) PURE;
+    STDMETHOD(SetFloat)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, FLOAT f) PURE;
+    STDMETHOD(SetFloatArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST FLOAT* pf, UINT Count) PURE;
+    STDMETHOD(SetVector)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXVECTOR4* pVector) PURE;
+    STDMETHOD(SetVectorArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXVECTOR4* pVector, UINT Count) PURE;
+    STDMETHOD(SetMatrix)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix) PURE;
+    STDMETHOD(SetMatrixArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix, UINT Count) PURE;
+    STDMETHOD(SetMatrixPointerArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX** ppMatrix, UINT Count) PURE;
+    STDMETHOD(SetMatrixTranspose)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix) PURE;
+    STDMETHOD(SetMatrixTransposeArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix, UINT Count) PURE;
+    STDMETHOD(SetMatrixTransposePointerArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX** ppMatrix, UINT Count) PURE;
+};
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define ID3DXConstantTable_QueryInterface(p,a,b)                      (p)->lpVtbl->QueryInterface(p,a,b)
+#define ID3DXConstantTable_AddRef(p)                                  (p)->lpVtbl->AddRef(p)
+#define ID3DXConstantTable_Release(p)                                 (p)->lpVtbl->Release(p)
+/*** ID3DXBuffer methods ***/
+#define ID3DXConstantTable_GetBufferPointer(p)                        (p)->lpVtbl->GetBufferPointer(p)
+#define ID3DXConstantTable_GetBufferSize(p)                           (p)->lpVtbl->GetBufferSize(p)
+/*** ID3DXConstantTable methods ***/
+#define ID3DXConstantTable_GetDesc(p,a)                               (p)->lpVtbl->GetDesc(p,a)
+#define ID3DXConstantTable_GetConstantDesc(p,a,b,c)                   (p)->lpVtbl->GetConstantDesc(p,a,b,c)
+#define ID3DXConstantTable_GetSamplerIndex(p,a)                       (p)->lpVtbl->GetSamplerIndex(p,a)
+#define ID3DXConstantTable_GetConstant(p,a,b)                         (p)->lpVtbl->GetConstant(p,a,b)
+#define ID3DXConstantTable_GetConstantByName(p,a,b)                   (p)->lpVtbl->GetConstantByName(p,a,b)
+#define ID3DXConstantTable_GetConstantElement(p,a,b)                  (p)->lpVtbl->GetConstantElement(p,a,b)
+#define ID3DXConstantTable_SetDefaults(p,a)                           (p)->lpVtbl->SetDefaults(p,a)
+#define ID3DXConstantTable_SetValue(p,a,b,c,d)                        (p)->lpVtbl->SetValue(p,a,b,c,d)
+#define ID3DXConstantTable_SetBool(p,a,b,c)                           (p)->lpVtbl->SetBool(p,a,b,c)
+#define ID3DXConstantTable_SetBoolArray(p,a,b,c,d)                    (p)->lpVtbl->SetBoolArray(p,a,b,c,d)
+#define ID3DXConstantTable_SetInt(p,a,b,c)                            (p)->lpVtbl->SetInt(p,a,b,c)
+#define ID3DXConstantTable_SetIntArray(p,a,b,c,d)                     (p)->lpVtbl->SetIntArray(p,a,b,c,d)
+#define ID3DXConstantTable_SetFloat(p,a,b,c)                          (p)->lpVtbl->SetFloat(p,a,b,c)
+#define ID3DXConstantTable_SetFloatArray(p,a,b,c,d)                   (p)->lpVtbl->SetFloatArray(p,a,b,c,d)
+#define ID3DXConstantTable_SetVector(p,a,b,c)                         (p)->lpVtbl->SetVector(p,a,b,c)
+#define ID3DXConstantTable_SetVectorArray(p,a,b,c,d)                  (p)->lpVtbl->SetVectorArray(p,a,b,c,d)
+#define ID3DXConstantTable_SetMatrix(p,a,b,c)                         (p)->lpVtbl->SetMatrix(p,a,b,c)
+#define ID3DXConstantTable_SetMatrixArray(p,a,b,c,d)                  (p)->lpVtbl->SetMatrixArray(p,a,b,c,d)
+#define ID3DXConstantTable_SetMatrixPointerArray(p,a,b,c,d)           (p)->lpVtbl->SetMatrixPointerArray(p,a,b,c,d)
+#define ID3DXConstantTable_SetMatrixTranspose(p,a,b,c)                (p)->lpVtbl->SetMatrixTranspose(p,a,b,c)
+#define ID3DXConstantTable_SetMatrixTransposeArray(p,a,b,c,d)         (p)->lpVtbl->SetMatrixTransposeArray(p,a,b,c,d)
+#define ID3DXConstantTable_SetMatrixTransposePointerArray(p,a,b,c,d)  (p)->lpVtbl->SetMatrixTransposePointerArray(p,a,b,c,d)
+#else
+/*** IUnknown methods ***/
+#define ID3DXConstantTable_QueryInterface(p,a,b)                      (p)->QueryInterface(a,b)
+#define ID3DXConstantTable_AddRef(p)                                  (p)->AddRef()
+#define ID3DXConstantTable_Release(p)                                 (p)->Release()
+/*** ID3DXBuffer methods ***/
+#define ID3DXConstantTable_GetBufferPointer(p)                        (p)->GetBufferPointer()
+#define ID3DXConstantTable_GetBufferSize(p)                           (p)->GetBufferSize()
+/*** ID3DXConstantTable methods ***/
+#define ID3DXConstantTable_GetDesc(p,a)                               (p)->GetDesc(a)
+#define ID3DXConstantTable_GetConstantDesc(p,a,b,c)                   (p)->GetConstantDesc(a,b,c)
+#define ID3DXConstantTable_GetSamplerIndex(p,a)                       (p)->GetConstantDesc(a)
+#define ID3DXConstantTable_GetConstant(p,a,b)                         (p)->GetConstant(a,b)
+#define ID3DXConstantTable_GetConstantByName(p,a,b)                   (p)->GetConstantByName(a,b)
+#define ID3DXConstantTable_GetConstantElement(p,a,b)                  (p)->GetConstantElement(a,b)
+#define ID3DXConstantTable_SetDefaults(p,a)                           (p)->SetDefaults(a)
+#define ID3DXConstantTable_SetValue(p,a,b,c,d)                        (p)->SetValue(a,b,c,d)
+#define ID3DXConstantTable_SetBool(p,a,b,c)                           (p)->SetBool(a,b,c)
+#define ID3DXConstantTable_SetBoolArray(p,a,b,c,d)                    (p)->SetBoolArray(a,b,c,d)
+#define ID3DXConstantTable_SetInt(p,a,b,c)                            (p)->SetInt(a,b,c)
+#define ID3DXConstantTable_SetIntArray(p,a,b,c,d)                     (p)->SetIntArray(a,b,c,d)
+#define ID3DXConstantTable_SetFloat(p,a,b,c)                          (p)->SetFloat(a,b,c)
+#define ID3DXConstantTable_SetFloatArray(p,a,b,c,d)                   (p)->SetFloatArray(a,b,c,d)
+#define ID3DXConstantTable_SetVector(p,a,b,c)                         (p)->SetVector(a,b,c)
+#define ID3DXConstantTable_SetVectorArray(p,a,b,c,d)                  (p)->SetVectorArray(a,b,c,d)
+#define ID3DXConstantTable_SetMatrix(p,a,b,c)                         (p)->SetMatrix(a,b,c)
+#define ID3DXConstantTable_SetMatrixArray(p,a,b,c,d)                  (p)->SetMatrixArray(a,b,c,d)
+#define ID3DXConstantTable_SetMatrixPointerArray(p,a,b,c,d)           (p)->SetMatrixPointerArray(a,b,c,d)
+#define ID3DXConstantTable_SetMatrixTranspose(p,a,b,c)                (p)->SetMatrixTranspose(a,b,c)
+#define ID3DXConstantTable_SetMatrixTransposeArray(p,a,b,c,d)         (p)->SetMatrixTransposeArray(a,b,c,d)
+#define ID3DXConstantTable_SetMatrixTransposePointerArray(p,a,b,c,d)  (p)->SetMatrixTransposePointerArray(a,b,c,d)
+#endif
+
+typedef struct ID3DXConstantTable *LPD3DXCONSTANTTABLE;
+
 typedef struct _D3DXMACRO {
     LPCSTR Name;
@@ -95,4 +232,9 @@
 } D3DXMACRO, *LPD3DXMACRO;
 
+typedef struct _D3DXSEMANTIC {
+    UINT Usage;
+    UINT UsageIndex;
+} D3DXSEMANTIC, *LPD3DXSEMANTIC;
+
 typedef enum _D3DXINCLUDE_TYPE
 {
@@ -124,4 +266,5 @@
 DWORD WINAPI D3DXGetShaderVersion(const DWORD *byte_code);
 LPCSTR WINAPI D3DXGetVertexShaderProfile(LPDIRECT3DDEVICE9 device);
+HRESULT WINAPI D3DXFindShaderComment(CONST DWORD* byte_code, DWORD fourcc, LPCVOID* data, UINT* size);
 
 HRESULT WINAPI D3DXAssembleShaderFromFileA(LPCSTR filename,
@@ -163,7 +306,53 @@
                                   LPD3DXBUFFER* error_messages);
 
+HRESULT WINAPI D3DXGetShaderConstantTableEx(CONST DWORD* byte_code,
+                                            DWORD flags,
+                                            LPD3DXCONSTANTTABLE* constant_table);
+
+HRESULT WINAPI D3DXGetShaderConstantTable(CONST DWORD* byte_code,
+                                          LPD3DXCONSTANTTABLE* constant_table);
+
 #ifdef __cplusplus
 }
 #endif
 
+typedef struct _D3DXSHADER_CONSTANTTABLE
+{
+    DWORD Size;
+    DWORD Creator;
+    DWORD Version;
+    DWORD Constants;
+    DWORD ConstantInfo;
+    DWORD Flags;
+    DWORD Target;
+} D3DXSHADER_CONSTANTTABLE, *LPD3DXSHADER_CONSTANTTABLE;
+
+typedef struct _D3DXSHADER_CONSTANTINFO
+{
+    DWORD Name;
+    WORD  RegisterSet;
+    WORD  RegisterIndex;
+    WORD  RegisterCount;
+    WORD  Reserved;
+    DWORD TypeInfo;
+    DWORD DefaultValue;
+} D3DXSHADER_CONSTANTINFO, *LPD3DXSHADER_CONSTANTINFO;
+
+typedef struct _D3DXSHADER_TYPEINFO
+{
+    WORD  Class;
+    WORD  Type;
+    WORD  Rows;
+    WORD  Columns;
+    WORD  Elements;
+    WORD  StructMembers;
+    DWORD StructMemberInfo;
+} D3DXSHADER_TYPEINFO, *LPD3DXSHADER_TYPEINFO;
+
+typedef struct _D3DXSHADER_STRUCTMEMBERINFO
+{
+    DWORD Name;
+    DWORD TypeInfo;
+} D3DXSHADER_STRUCTMEMBERINFO, *LPD3DXSHADER_STRUCTMEMBERINFO;
+
 #endif /* __D3DX9SHADER_H__ */
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/dbs.idl
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/dbs.idl	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/dbs.idl	(revision 28475)
@@ -193,8 +193,25 @@
 };
 
-cpp_quote("DEFINE_GUID(DBGUID_SESSION,    0xc8b522f5, 0x5cf3, 0x11ce, 0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d);")
-cpp_quote("DEFINE_GUID(DBGUID_ROWSET,     0xc8b522f6, 0x5cf3, 0x11ce, 0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d);")
-cpp_quote("DEFINE_GUID(DBGUID_ROW,        0xc8b522f7, 0x5cf3, 0x11ce, 0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d);")
-cpp_quote("DEFINE_GUID(DBGUID_STREAM,     0xc8b522f9, 0x5cf3, 0x11ce, 0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d);")
+cpp_quote("#ifdef DBINITCONSTANTS")
+cpp_quote("#ifdef __cplusplus")
+cpp_quote("#define DEFINE_DBGUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \\")
+cpp_quote("        EXTERN_C const GUID name DECLSPEC_HIDDEN;     \\")
+cpp_quote("        EXTERN_C const GUID name =                    \\")
+cpp_quote("	{ l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } }")
+cpp_quote("#else")
+cpp_quote("#define DEFINE_DBGUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \\")
+cpp_quote("        const GUID name DECLSPEC_HIDDEN;      \\")
+cpp_quote("        const GUID name =                             \\")
+cpp_quote("	{ l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } }")
+cpp_quote("#endif")
+cpp_quote("#else")
+cpp_quote("#define DEFINE_DBGUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \\")
+cpp_quote("    EXTERN_C const GUID name DECLSPEC_HIDDEN")
+cpp_quote("#endif")
+
+cpp_quote("DEFINE_DBGUID(DBGUID_SESSION,    0xc8b522f5, 0x5cf3, 0x11ce, 0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d);")
+cpp_quote("DEFINE_DBGUID(DBGUID_ROWSET,     0xc8b522f6, 0x5cf3, 0x11ce, 0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d);")
+cpp_quote("DEFINE_DBGUID(DBGUID_ROW,        0xc8b522f7, 0x5cf3, 0x11ce, 0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d);")
+cpp_quote("DEFINE_DBGUID(DBGUID_STREAM,     0xc8b522f9, 0x5cf3, 0x11ce, 0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d);")
 
 typedef struct tagDBCOLUMNACCESS
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/ddk/usb.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/ddk/usb.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/ddk/usb.h	(revision 28475)
@@ -94,4 +94,9 @@
 #define USBD_STATUS_SUCCESS                          ((USBD_STATUS)0x00000000)
 #define USBD_STATUS_PENDING                          ((USBD_STATUS)0x40000000)
+#define USBD_STATUS_ERROR                            ((USBD_STATUS)0x80000000)
+#define USBD_STATUS_HALTED                           ((USBD_STATUS)0xC0000000)
+
+#define USBD_STATUS_CANCELED                         ((USBD_STATUS)0x00010000)
+#define USBD_STATUS_CANCELING                        ((USBD_STATUS)0x00020000)
 #define USBD_STATUS_CRC                              ((USBD_STATUS)0xC0000001)
 #define USBD_STATUS_BTSTUFF                          ((USBD_STATUS)0xC0000002)
@@ -113,7 +118,9 @@
 #define USBD_STATUS_DATA_BUFFER_ERROR                ((USBD_STATUS)0xC0000013)
 #define USBD_STATUS_ENDPOINT_HALTED                  ((USBD_STATUS)0xC0000030)
+#define USBD_STATUS_NO_MEMORY                        ((USBD_STATUS)0x80000100)
 #define USBD_STATUS_INVALID_URB_FUNCTION             ((USBD_STATUS)0x80000200)
 #define USBD_STATUS_INVALID_PARAMETER                ((USBD_STATUS)0x80000300)
 #define USBD_STATUS_ERROR_BUSY                       ((USBD_STATUS)0x80000400)
+#define USBD_STATUS_REQUEST_FAILED                   ((USBD_STATUS)0x80000500)
 #define USBD_STATUS_INVALID_PIPE_HANDLE              ((USBD_STATUS)0x80000600)
 #define USBD_STATUS_NO_BANDWIDTH                     ((USBD_STATUS)0x80000700)
@@ -134,5 +141,4 @@
 #define USBD_STATUS_DEVICE_GONE                      ((USBD_STATUS)0xC0007000)
 #define USBD_STATUS_STATUS_NOT_MAPPED                ((USBD_STATUS)0xC0008000)
-#define USBD_STATUS_CANCELED                         ((USBD_STATUS)0xC0010000)
 #define USBD_STATUS_ISO_NOT_ACCESSED_BY_HW           ((USBD_STATUS)0xC0020000)
 #define USBD_STATUS_ISO_TD_ERROR                     ((USBD_STATUS)0xC0030000)
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/ddk/usb100.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/ddk/usb100.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/ddk/usb100.h	(revision 28475)
@@ -58,4 +58,10 @@
 typedef struct _USB_DEVICE_DESCRIPTOR *PUSB_DEVICE_DESCRIPTOR;
 
+#define USB_ENDPOINT_TYPE_MASK            0x03
+#define USB_ENDPOINT_TYPE_CONTROL         0x00
+#define USB_ENDPOINT_TYPE_ISOCHRONOUS     0x01
+#define USB_ENDPOINT_TYPE_BULK            0x02
+#define USB_ENDPOINT_TYPE_INTERRUPT       0x03
+
 typedef struct _USB_ENDPOINT_DESCRIPTOR {
     UCHAR bLength;
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/ddk/usbdlib.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/ddk/usbdlib.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/ddk/usbdlib.h	(revision 28475)
@@ -35,3 +35,10 @@
 typedef struct _USBD_INTERFACE_LIST_ENTRY *PUSBD_INTERFACE_LIST_ENTRY;
 
+PURB WINAPI USBD_CreateConfigurationRequest(PUSB_CONFIGURATION_DESCRIPTOR,PUSHORT);
+PURB WINAPI USBD_CreateConfigurationRequestEx(PUSB_CONFIGURATION_DESCRIPTOR,PUSBD_INTERFACE_LIST_ENTRY);
+ULONG WINAPI USBD_GetInterfaceLength(PUSB_INTERFACE_DESCRIPTOR,PUCHAR);
+VOID WINAPI USBD_GetUSBDIVersion(PUSBD_VERSION_INFORMATION);
+PUSB_COMMON_DESCRIPTOR WINAPI USBD_ParseDescriptors(PVOID,ULONG,PVOID,LONG);
+PUSB_INTERFACE_DESCRIPTOR WINAPI USBD_ParseConfigurationDescriptorEx(PUSB_CONFIGURATION_DESCRIPTOR,PVOID,LONG,LONG,LONG,LONG,LONG);
+
 #endif
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/ddk/wdm.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/ddk/wdm.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/ddk/wdm.h	(revision 28475)
@@ -433,5 +433,5 @@
           PVOID  DriverContext[4];
         } DUMMYSTRUCTNAME;
-      } DUMMYUNIONNAME;
+      } DUMMYUNIONNAME1;
       PETHREAD  Thread;
       PCHAR  AuxiliaryBuffer;
@@ -441,5 +441,5 @@
           struct _IO_STACK_LOCATION  *CurrentStackLocation;
           ULONG  PacketType;
-        } DUMMYUNIONNAME;
+        } DUMMYUNIONNAME2;
       } DUMMYSTRUCTNAME;
       struct _FILE_OBJECT  *OriginalFileObject;
@@ -698,4 +698,27 @@
   BusQueryDeviceSerialNumber
 } BUS_QUERY_ID_TYPE, *PBUS_QUERY_ID_TYPE;
+
+typedef enum {
+  DevicePropertyDeviceDescription,
+  DevicePropertyHardwareID,
+  DevicePropertyCompatibleIDs,
+  DevicePropertyBootConfiguration,
+  DevicePropertyBootConfigurationTranslated,
+  DevicePropertyClassName,
+  DevicePropertyClassGuid,
+  DevicePropertyDriverKeyName,
+  DevicePropertyManufacturer,
+  DevicePropertyFriendlyName,
+  DevicePropertyLocationInformation,
+  DevicePropertyPhysicalDeviceObjectName,
+  DevicePropertyBusTypeGuid,
+  DevicePropertyLegacyBusType,
+  DevicePropertyBusNumber,
+  DevicePropertyEnumeratorName,
+  DevicePropertyAddress,
+  DevicePropertyUINumber,
+  DevicePropertyInstallState,
+  DevicePropertyRemovalPolicy
+} DEVICE_REGISTRY_PROPERTY;
 
 typedef enum _DEVICE_TEXT_TYPE {
@@ -1031,5 +1054,21 @@
 NTSTATUS WINAPI ObCloseHandle(IN HANDLE handle);
 
-#define IoGetCurrentIrpStackLocation(_Irp) ((_Irp)->Tail.Overlay.CurrentStackLocation)
+#ifdef NONAMELESSUNION
+# ifdef NONAMELESSSTRUCT
+#  define IoGetCurrentIrpStackLocation(_Irp) ((_Irp)->Tail.Overlay.s.u2.CurrentStackLocation)
+#  define IoGetNextIrpStackLocation(_Irp) ((_Irp)->Tail.Overlay.s.u2.CurrentStackLocation - 1)
+# else
+#  define IoGetCurrentIrpStackLocation(_Irp) ((_Irp)->Tail.Overlay.u2.CurrentStackLocation)
+#  define IoGetNextIrpStackLocation(_Irp) ((_Irp)->Tail.Overlay.u2.CurrentStackLocation - 1)
+# endif
+#else
+# ifdef NONAMELESSSTRUCT
+#  define IoGetCurrentIrpStackLocation(_Irp) ((_Irp)->Tail.Overlay.s.CurrentStackLocation)
+#  define IoGetNextIrpStackLocation(_Irp) ((_Irp)->Tail.Overlay.s.CurrentStackLocation - 1)
+# else
+#  define IoGetCurrentIrpStackLocation(_Irp) ((_Irp)->Tail.Overlay.CurrentStackLocation)
+#  define IoGetNextIrpStackLocation(_Irp) ((_Irp)->Tail.Overlay.CurrentStackLocation - 1)
+# endif
+#endif
 
 #define KernelMode 0
@@ -1057,4 +1096,6 @@
 PVOID     WINAPI IoAllocateErrorLogEntry(PVOID,UCHAR);
 PIRP      WINAPI IoAllocateIrp(CCHAR,BOOLEAN);
+NTSTATUS  WINAPI IoCallDriver(DEVICE_OBJECT*,IRP*);
+VOID      WINAPI IoCompleteRequest(IRP*,UCHAR);
 NTSTATUS  WINAPI IoCreateDevice(DRIVER_OBJECT*,ULONG,UNICODE_STRING*,DEVICE_TYPE,ULONG,BOOLEAN,DEVICE_OBJECT**);
 NTSTATUS  WINAPI IoCreateDriver(UNICODE_STRING*,PDRIVER_INITIALIZE);
@@ -1066,4 +1107,5 @@
 PEPROCESS WINAPI IoGetCurrentProcess(void);
 NTSTATUS  WINAPI IoGetDeviceObjectPointer(UNICODE_STRING*,ACCESS_MASK,PFILE_OBJECT*,PDEVICE_OBJECT*);
+NTSTATUS  WINAPI IoGetDeviceProperty(PDEVICE_OBJECT,DEVICE_REGISTRY_PROPERTY,ULONG,PVOID,PULONG);
 PVOID     WINAPI IoGetDriverObjectExtension(PDRIVER_OBJECT,PVOID);
 PDEVICE_OBJECT WINAPI IoGetRelatedDeviceObject(PFILE_OBJECT);
@@ -1075,4 +1117,6 @@
 ULONG     WINAPI KeQueryTimeIncrement(void);
 LONG      WINAPI KeReleaseSemaphore(PRKSEMAPHORE,KPRIORITY,LONG,BOOLEAN);
+LONG      WINAPI KeResetEvent(PRKEVENT);
+LONG      WINAPI KeSetEvent(PRKEVENT,KPRIORITY,BOOLEAN);
 KPRIORITY WINAPI KeSetPriorityThread(PKTHREAD,KPRIORITY);
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/dispex.idl
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/dispex.idl	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/dispex.idl	(revision 28475)
@@ -91,11 +91,11 @@
     [local]
     HRESULT InvokeEx(
-            [in] DISPID id,
-            [in] LCID lcid,
-            [in] WORD wFlags,
-            [in] DISPPARAMS *pdp,
-            [out] VARIANT *pvarRes,
-            [out] EXCEPINFO *pei,
-            [in, unique] IServiceProvider *pspCaller);
+            [in, annotation("__in")] DISPID id,
+            [in, annotation("__in")] LCID lcid,
+            [in, annotation("__in")] WORD wFlags,
+            [in, annotation("__in")] DISPPARAMS *pdp,
+            [out, annotation("__out_opt")] VARIANT *pvarRes,
+            [out, annotation("__out_opt")] EXCEPINFO *pei,
+            [in, unique, annotation("__in_opt")] IServiceProvider *pspCaller);
 
     [call_as(InvokeEx)]
@@ -201,2 +201,14 @@
             [in] VARIANT *pvar);
 }
+
+[
+    object,
+    uuid(10e2414a-ec59-49d2-bc51-5add2c36febc),
+    pointer_default(unique)
+]
+interface IProvideRuntimeContext : IUnknown
+{
+    HRESULT GetCurrentSourceContext(
+            [out] DWORD_PTR *pdwContext,
+            [out] VARIANT_BOOL *pfExecutingGlobalCode);
+}
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/dls1.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/dls1.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/dls1.h	(revision 28475)
@@ -26,5 +26,5 @@
  * of the LGPL is applied is otherwise unspecified.
  */
- 
+
 #ifndef __WINE_INCLUDE_DLS1_H
 #define __WINE_INCLUDE_DLS1_H
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/dmoreg.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/dmoreg.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/dmoreg.h	(revision 28475)
@@ -30,4 +30,8 @@
 
 #include "mediaobj.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 typedef struct _DMO_PARTIAL_MEDIATYPE
@@ -77,3 +81,7 @@
             0xe88c9ba0,0xc557,0x11d0,0x8a,0x2b,0x00,0xa0,0xc9,0x25,0x5a,0xc1);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* __DMOREG_H__ */
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/dsound.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/dsound.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/dsound.h	(revision 28475)
@@ -1108,5 +1108,5 @@
 #define IDirectSound3DBuffer_GetVelocity(p,a)              (p)->GetVelocity(a)
 #define IDirectSound3DBuffer_SetAllParameters(p,a,b)       (p)->SetAllParameters(a,b)
-#define IDirectSound3DBuffer_SetConeAngles(p,a,b)          (p)->SetConeAngles(a,b)
+#define IDirectSound3DBuffer_SetConeAngles(p,a,b,c)        (p)->SetConeAngles(a,b,c)
 #define IDirectSound3DBuffer_SetConeOrientation(p,a,b,c,d) (p)->SetConeOrientation(a,b,c,d)
 #define IDirectSound3DBuffer_SetConeOutsideVolume(p,a,b)   (p)->SetConeOutsideVolume(a,b)
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/gdipluscolormatrix.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/gdipluscolormatrix.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/gdipluscolormatrix.h	(revision 28475)
@@ -55,5 +55,5 @@
 {
     Color oldColor;
-    Color newCOlor;
+    Color newColor;
 };
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/gdiplusflat.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/gdiplusflat.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/gdiplusflat.h	(revision 28475)
@@ -571,6 +571,7 @@
 GpStatus WINGDIPAPI GdipSetPathGradientSigmaBlend(GpPathGradient*,REAL,REAL);
 GpStatus WINGDIPAPI GdipSetPathGradientSurroundColorsWithCount(GpPathGradient*,
-    ARGB*,INT*);
+    GDIPCONST ARGB*,INT*);
 GpStatus WINGDIPAPI GdipSetPathGradientWrapMode(GpPathGradient*,GpWrapMode);
+GpStatus WINGDIPAPI GdipGetPathGradientSurroundColorCount(GpPathGradient*,INT*);
 
 /* PathIterator */
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/iphlpapi.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/iphlpapi.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/iphlpapi.h	(revision 28475)
@@ -25,4 +25,5 @@
  * of the LGPL is applied is otherwise unspecified.
  */
+
 #ifndef WINE_IPHLPAPI_H__
 #define WINE_IPHLPAPI_H__
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/iprtrmib.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/iprtrmib.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/iprtrmib.h	(revision 28475)
@@ -25,4 +25,5 @@
  * of the LGPL is applied is otherwise unspecified.
  */
+
 #ifndef WINE_IPRTRMIB_H__
 #define WINE_IPRTRMIB_H__
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/ksmedia.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/ksmedia.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/ksmedia.h	(revision 28475)
@@ -44,5 +44,8 @@
 #define KSAUDIO_SPEAKER_7POINT1 (KSAUDIO_SPEAKER_5POINT1 | SPEAKER_FRONT_LEFT_OF_CENTER | SPEAKER_FRONT_RIGHT_OF_CENTER)
 
+#ifndef REFERENCE_TIME_DEFINED
+#define REFERENCE_TIME_DEFINED
 typedef LONGLONG REFERENCE_TIME;
+#endif
 
 typedef enum
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/lmmsg.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/lmmsg.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/lmmsg.h	(revision 28475)
@@ -25,4 +25,5 @@
  * of the LGPL is applied is otherwise unspecified.
  */
+
 #ifndef _LMMSG_
 #define _LMMSG_
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/lmserver.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/lmserver.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/lmserver.h	(revision 28475)
@@ -25,4 +25,5 @@
  * of the LGPL is applied is otherwise unspecified.
  */
+
 #ifndef _LMSERVER_
 #define _LMSERVER_
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/lmshare.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/lmshare.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/lmshare.h	(revision 28475)
@@ -25,4 +25,5 @@
  * of the LGPL is applied is otherwise unspecified.
  */
+
 #ifndef _LMSHARE_H
 #define _LMSHARE_H
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/lmuse.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/lmuse.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/lmuse.h	(revision 28475)
@@ -25,4 +25,5 @@
  * of the LGPL is applied is otherwise unspecified.
  */
+
 #ifndef _LMUSE_H
 #define _LMUSE_H
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/mapitags.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/mapitags.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/mapitags.h	(revision 28475)
@@ -27,4 +27,5 @@
  * of the LGPL is applied is otherwise unspecified.
  */
+
 #ifndef MAPITAGS_H
 #define MAPITAGS_H
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/mlang.idl
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/mlang.idl	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/mlang.idl	(revision 28475)
@@ -678,5 +678,5 @@
         [in] UINT uiCodePage,
         [in] LCID lcid,
-        [in,out] LPWSTR lpWideCharStr,
+        [in,out,size_is(cchWideChar)] LPWSTR lpWideCharStr,
         [in] int cchWideChar);
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/mmddk.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/mmddk.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/mmddk.h	(revision 28475)
@@ -386,4 +386,7 @@
 #define MCI_CONSTANT            8
 #define MCI_END_CONSTANT        9
+#define MCI_HWND                10
+#define MCI_HPAL                11
+#define MCI_HDC                 12
 
 #define MAKEMCIRESOURCE(wRet, wRes) MAKELRESULT((wRet), (wRes))
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/mmsystem.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/mmsystem.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/mmsystem.h	(revision 28475)
@@ -667,4 +667,6 @@
 #define MOD_FMSYNTH     4  /* FM internal synth */
 #define MOD_MAPPER      5  /* MIDI mapper */
+#define MOD_WAVETABLE   6  /* hardware watetable internal synth */
+#define MOD_SWSYNTH     7  /* software synth */
 
 #define MIDICAPS_VOLUME		0x0001  /* supports volume control */
@@ -728,4 +730,5 @@
     struct midihdr_tag *lpNext;
     DWORD_PTR	reserved;
+    /* Win 32 extended the structure with these 2 fields */
     DWORD	dwOffset;
     DWORD_PTR	dwReserved[8];
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msctf.idl
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msctf.idl	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msctf.idl	(revision 28475)
@@ -30,5 +30,5 @@
 import "comcat.idl";
 import "textstor.idl";
-/* import "ctfutb.idl"; */
+import "ctfutb.idl";
 #endif
 cpp_quote("#include <winuser.h>")
@@ -42,4 +42,5 @@
 cpp_quote("HRESULT WINAPI TF_GetThreadMgr(ITfThreadMgr **pptim);")
 cpp_quote("HRESULT WINAPI TF_CreateInputProcessorProfiles(ITfInputProcessorProfiles **ppipr);")
+cpp_quote("HRESULT WINAPI TF_CreateLangBarMgr(ITfLangBarMgr **pppbm);")
 
 cpp_quote("EXTERN_C const GUID GUID_PROP_TEXTOWNER;")
@@ -51,6 +52,7 @@
 cpp_quote("EXTERN_C const CLSID CLSID_TF_ThreadMgr;")
 cpp_quote("EXTERN_C const CLSID CLSID_TF_InputProcessorProfiles;")
+cpp_quote("EXTERN_C const CLSID CLSID_TF_LangBarMgr;")
 cpp_quote("EXTERN_C const CLSID CLSID_TF_CategoryMgr;")
-cpp_quote("DEFINE_GUID(CLSID_TF_DisplayAttributeMgr,0x3ce74de4,0x53d3,0x4d74,0x8b,0x83,0x43,0x1b,0x38,0x28,0xba,0x53);")
+cpp_quote("EXTERN_C const CLSID CLSID_TF_DisplayAttributeMgr;")
 
 /* GUIDs for Compartments */
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/mshtmdid.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/mshtmdid.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/mshtmdid.h	(revision 28475)
@@ -135,4 +135,9 @@
 #define DISPID_IE8_ELEMENTMAX   (DISPID_SITE-1)
 #define DISPID_IE8_ELEMENT      DISPID_IE8_ELEMENTBASE
+
+#define DISPID_IE8_FRAMESITEBASE  (DISPID_FRAMESITE+1120)
+#define DISPID_IE8_FRAMEMAX       (WEBOC_DISPIDBASE-1)
+#define DISPID_IE8_FRAME          DISPID_IE8_FRAMESITEBASE
+#define DISPID_IE8_IFRAME         DISPID_IE8_FRAMESITEBASE
 
 #define DISPID_COLLECTION      (DISPID_NORMAL_FIRST+500)
@@ -2497,4 +2502,7 @@
 #define DISPID_IHTMLSCRIPTELEMENT2_CHARSET  DISPID_SCRIPT+10
 
+/* IHTMLScriptElement3 */
+#define DISPID_IHTMLSCRIPTELEMENT3_IE8_SRC  DISPID_IE8_SCRIPT
+
 /* IHTMLFrameBase */
 #define DISPID_IHTMLFRAMEBASE_SRC           DISPID_FRAMESITE+0
@@ -2517,4 +2525,17 @@
 /* IHTMLFrameBase3 */
 #define DISPID_IHTMLFRAMEBASE3_LONGDESC  DISPID_FRAMESITE+10
+
+/* IHTMLFrameElement */
+#define DISPID_IHTMLFRAMEELEMENT_BORDERCOLOR  DISPID_FRAME+1
+
+/* IHTMLFrameElement2 */
+#define DISPID_IHTMLFRAMEELEMENT2_HEIGHT  STDPROPID_XOBJ_HEIGHT
+#define DISPID_IHTMLFRAMEELEMENT2_WIDTH   STDPROPID_XOBJ_WIDTH
+
+/* IHTMLFrameElement3 */
+#define DISPID_IHTMLFRAMEELEMENT3_CONTENTDOCUMENT  DISPID_IE8_FRAME
+#define DISPID_IHTMLFRAMEELEMENT3_IE8_SRC          DISPID_IE8_FRAME+1
+#define DISPID_IHTMLFRAMEELEMENT3_IE8_LONGDESC     DISPID_IE8_FRAME+2
+#define DISPID_IHTMLFRAMEELEMENT3_IE8_FRAMEBORDER  DISPID_IE8_FRAME+3
 
 /* IHTMLIFrameElement */
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/mshtml.idl
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/mshtml.idl	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/mshtml.idl	(revision 28475)
@@ -1,4 +1,4 @@
 /*
- * Copyright 2004-2007 Jacek Caban for CodeWeavers
+ * Copyright 2004-2010 Jacek Caban for CodeWeavers
  * Copyright 2008      Konstantin Kondratyuk (Etersoft)
  *
@@ -2886,5 +2886,5 @@
     [propget, id(DISPID_IHTMLCURRENTSTYLE4_MAXWIDTH), displaybind, bindable]
     HRESULT maxWidth([retval, out] VARIANT * p);
-};
+}
 
 /*****************************************************************************
@@ -5913,5 +5913,5 @@
                         interface IHTMLStyleSheetPage;
                         interface IHTMLDOMConstructor;
-};
+}
 
 [
@@ -6712,5 +6712,5 @@
     [id(DISPID_HTMLFORMELEMENTEVENTS_ONRESET)]
     VARIANT_BOOL onreset();
-};
+}
 
 interface IHTMLEventObj;
@@ -6915,5 +6915,5 @@
     [id(DISPID_HTMLFORMELEMENTEVENTS2_ONRESET)]
     VARIANT_BOOL onreset([in] IHTMLEventObj* pEvtObj);
-};
+}
 
 [
@@ -7375,5 +7375,5 @@
     [propget, id(DISPID_IHTMLCONTROLELEMENT_CLIENTLEFT), displaybind, bindable]
     HRESULT clientLeft([retval, out] LONG * p);
-};
+}
 
 /*****************************************************************************
@@ -7644,5 +7644,5 @@
     [propget, id(DISPID_IHTMLBODYELEMENT2_ONAFTERPRINT), displaybind, bindable]
     VARIANT onafterprint();
-};
+}
 
 [
@@ -7665,5 +7665,5 @@
                         interface IHTMLBodyElement;
                         interface IHTMLBodyElement2;
-};
+}
 
 /*****************************************************************************
@@ -8981,4 +8981,90 @@
 
 /*****************************************************************************
+ *    DispHTMLTextAreaElement dispinterface
+ */
+[
+    hidden,
+    uuid(3050f521-98b5-11cf-bb82-00aa00bdce0b)
+]
+dispinterface DispHTMLTextAreaElement
+{
+properties:
+methods:
+    WINE_HTMLDATAELEMENT_DISPINTERFACE_DECL;
+
+    [propget, id(DISPID_IHTMLTEXTAREAELEMENT_TYPE)]
+    BSTR type();
+
+    [propput, id(DISPID_IHTMLTEXTAREAELEMENT_VALUE), displaybind, bindable]
+    void value(BSTR v);
+
+    [propget, id(DISPID_IHTMLTEXTAREAELEMENT_VALUE), displaybind, bindable]
+    BSTR value();
+
+    [propput, id(DISPID_IHTMLTEXTAREAELEMENT_NAME), displaybind, bindable]
+    void name(BSTR v);
+
+    [propget, id(DISPID_IHTMLTEXTAREAELEMENT_NAME), displaybind, bindable]
+    BSTR name();
+
+    [propput, id(DISPID_IHTMLTEXTAREAELEMENT_STATUS)]
+    void status(VARIANT v);
+
+    [propget, id(DISPID_IHTMLTEXTAREAELEMENT_STATUS)]
+    VARIANT status();
+
+    [propget, id(DISPID_IHTMLTEXTAREAELEMENT_FORM)]
+    IHTMLFormElement *form();
+
+    [propput, id(DISPID_IHTMLTEXTAREAELEMENT_DEFAULTVALUE), displaybind, bindable, hidden]
+    void defaultValue(BSTR v);
+
+    [propget, id(DISPID_IHTMLTEXTAREAELEMENT_DEFAULTVALUE), displaybind, bindable, hidden]
+    BSTR defaultValue();
+
+    [id(DISPID_IHTMLTEXTAREAELEMENT_SELECT)]
+    void select();
+
+    [propput, id(DISPID_IHTMLTEXTAREAELEMENT_ONCHANGE), displaybind, bindable]
+    void onchange(VARIANT v);
+
+    [propget, id(DISPID_IHTMLTEXTAREAELEMENT_ONCHANGE), displaybind, bindable]
+    VARIANT onchange();
+
+    [propput, id(DISPID_IHTMLTEXTAREAELEMENT_ONSELECT), displaybind, bindable]
+    void onselect(VARIANT v);
+
+    [propget, id(DISPID_IHTMLTEXTAREAELEMENT_ONSELECT), displaybind, bindable]
+    VARIANT onselect();
+
+    [propput, id(DISPID_IHTMLTEXTAREAELEMENT_READONLY), displaybind, bindable]
+    void readOnly(VARIANT_BOOL v);
+
+    [propget, id(DISPID_IHTMLTEXTAREAELEMENT_READONLY), displaybind, bindable]
+    VARIANT_BOOL readOnly();
+
+    [propput, id(DISPID_IHTMLTEXTAREAELEMENT_ROWS), displaybind, bindable]
+    void rows(LONG v);
+
+    [propget, id(DISPID_IHTMLTEXTAREAELEMENT_ROWS), displaybind, bindable]
+    LONG rows();
+
+    [propput, id(DISPID_IHTMLTEXTAREAELEMENT_COLS), displaybind, bindable]
+    void cols(LONG v);
+
+    [propget, id(DISPID_IHTMLTEXTAREAELEMENT_COLS), displaybind, bindable]
+    LONG cols();
+
+    [propput, id(DISPID_IHTMLTEXTAREAELEMENT_WRAP), displaybind, bindable]
+    void wrap(BSTR v);
+
+    [propget, id(DISPID_IHTMLTEXTAREAELEMENT_WRAP), displaybind, bindable]
+    BSTR wrap();
+
+    [id(DISPID_IHTMLTEXTAREAELEMENT_CREATETEXTRANGE)]
+    IHTMLTxtRange *createTextRange();
+}
+
+/*****************************************************************************
  *    DispHTMLUnknownElement interface
  */
@@ -10255,5 +10341,5 @@
     [propget, id(DISPID_IHTMLWINDOW4_FRAMEELEMENT)]
     HRESULT frameElement([retval, out] IHTMLFrameBase* * p);
-};
+}
 
 /*****************************************************************************
@@ -10273,5 +10359,5 @@
     [propget, id(DISPID_IHTMLWINDOW5_XMLHTTPREQUEST)]
     HRESULT XMLHttpRequest([retval, out] VARIANT * p);
-};
+}
 
 /*****************************************************************************
@@ -10912,5 +10998,5 @@
     [propget, id(DISPID_IHTMLWINDOW5_XMLHTTPREQUEST)]
     VARIANT XMLHttpRequest();
-};
+}
 
 /*****************************************************************************
@@ -10959,5 +11045,5 @@
     [id(DISPID_HTMLWINDOWEVENTS_ONAFTERPRINT)]
     void onafterprint();
-};
+}
 
 /*****************************************************************************
@@ -11006,5 +11092,5 @@
     [id(DISPID_HTMLWINDOWEVENTS2_ONAFTERPRINT)]
     void onafterprint([in] IHTMLEventObj* pEvtObj);
-};
+}
 
 /*****************************************************************************
@@ -11023,5 +11109,5 @@
                         interface IHTMLWindow4;
                         interface IHTMLWindow5;
-};
+}
 
 /*****************************************************************************
@@ -11483,5 +11569,5 @@
     [id(DISPID_HTMLTEXTCONTAINEREVENTS_ONSELECT)]
     void onselect();
-};
+}
 
 /*****************************************************************************
@@ -11687,5 +11773,5 @@
     [id(DISPID_HTMLTEXTCONTAINEREVENTS2_ONSELECT)]
     void onselect([in] IHTMLEventObj* pEvtObj);
-};
+}
 
 /*****************************************************************************
@@ -13339,5 +13425,6 @@
     [id(DISPID_HTMLELEMENTEVENTS2_ONMOUSEWHEEL)]
     VARIANT_BOOL onmousewheel([in] IHTMLEventObj* pEvtObj);
-};
+}
+
 [
     hidden,
@@ -13536,6 +13623,5 @@
     [id(DISPID_HTMLELEMENTEVENTS_ONFOCUSOUT)]
     void onfocusout();
-
-};
+}
 
 [
@@ -13953,5 +14039,5 @@
     [id(DISPID_HTMLELEMENTEVENTS2_ONMOUSEWHEEL)]
     VARIANT_BOOL onmousewheel([in] IHTMLEventObj* pEvtObj);
-};
+}
 
 /*****************************************************************************
@@ -14163,5 +14249,5 @@
         [defaultvalue(-1), in] LONG indexTo,
         [retval, out] IDispatch** row);
-};
+}
 
 [
@@ -14178,5 +14264,5 @@
     [propget, id(DISPID_IHTMLTABLE3_SUMMARY), displaybind, bindable]
     HRESULT summary([retval, out] BSTR * p);
-};
+}
 
 [
@@ -14201,5 +14287,5 @@
                         interface IHTMLTable2;
                         interface IHTMLTable3;
-};
+}
 
 [
@@ -14637,4 +14723,72 @@
 
 /*****************************************************************************
+ *    DispHTMLScriptElement dispinterface
+ */
+[
+    hidden,
+    uuid(3050f530-98b5-11cf-bb82-00aa00bdce0b)
+]
+dispinterface DispHTMLScriptElement
+{
+properties:
+methods:
+    WINE_HTMLELEMENT_DISPINTERFACE_DECL;
+
+    [propput, id(DISPID_IHTMLSCRIPTELEMENT_SRC), displaybind, bindable]
+    void src(BSTR v);
+
+    [propget, id(DISPID_IHTMLSCRIPTELEMENT_SRC), displaybind, bindable]
+    BSTR src();
+
+    [propput, id(DISPID_IHTMLSCRIPTELEMENT_HTMLFOR), displaybind, bindable]
+    void htmlFor(BSTR v);
+
+    [propget, id(DISPID_IHTMLSCRIPTELEMENT_HTMLFOR), displaybind, bindable]
+    BSTR htmlFor();
+
+    [propput, id(DISPID_IHTMLSCRIPTELEMENT_EVENT), displaybind, bindable]
+    void event(BSTR v);
+
+    [propget, id(DISPID_IHTMLSCRIPTELEMENT_EVENT), displaybind, bindable]
+    BSTR event();
+
+    [propput, id(DISPID_IHTMLSCRIPTELEMENT_TEXT), displaybind, bindable]
+    void text(BSTR v);
+
+    [propget, id(DISPID_IHTMLSCRIPTELEMENT_TEXT), displaybind, bindable]
+    BSTR text();
+
+    [propput, id(DISPID_IHTMLSCRIPTELEMENT_DEFER), displaybind, bindable]
+    void defer(VARIANT_BOOL v);
+
+    [propget, id(DISPID_IHTMLSCRIPTELEMENT_DEFER), displaybind, bindable]
+    VARIANT_BOOL defer();
+
+    [propput, id(DISPID_IHTMLSCRIPTELEMENT_ONERROR), displaybind, bindable]
+    void onerror(VARIANT v);
+
+    [propget, id(DISPID_IHTMLSCRIPTELEMENT_ONERROR), displaybind, bindable]
+    VARIANT onerror();
+
+    [propput, id(DISPID_IHTMLSCRIPTELEMENT_TYPE), displaybind, bindable]
+    void type(BSTR v);
+
+    [propget, id(DISPID_IHTMLSCRIPTELEMENT_TYPE), displaybind, bindable]
+    BSTR type();
+
+    [propput, id(DISPID_IHTMLSCRIPTELEMENT2_CHARSET), displaybind, bindable]
+    void charset(BSTR v);
+
+    [propget, id(DISPID_IHTMLSCRIPTELEMENT2_CHARSET), displaybind, bindable]
+    BSTR charset();
+
+    [propput, id(DISPID_IHTMLSCRIPTELEMENT3_IE8_SRC)]
+    void ie8_src(BSTR v);
+
+    [propget, id(DISPID_IHTMLSCRIPTELEMENT3_IE8_SRC)]
+    BSTR ie8_src();
+}
+
+/*****************************************************************************
  *    IHTMLFrameBase interface
  */
@@ -14702,4 +14856,59 @@
 }
 
+#define WINE_IHTMLFRAMEBASE_DISPINTERFACE_DECL          \
+    [propput, id(DISPID_IHTMLFRAMEBASE_SRC)]            \
+    void src(BSTR v);                                   \
+                                                        \
+    [propget, id(DISPID_IHTMLFRAMEBASE_SRC)]            \
+    BSTR src();                                         \
+                                                        \
+    [propput, id(DISPID_IHTMLFRAMEBASE_NAME)]           \
+    void name(BSTR v);                                  \
+                                                        \
+    [propget, id(DISPID_IHTMLFRAMEBASE_NAME)]           \
+    BSTR name();                                        \
+                                                        \
+    [propput, id(DISPID_IHTMLFRAMEBASE_BORDER)]         \
+    void border(VARIANT v);                             \
+                                                        \
+    [propget, id(DISPID_IHTMLFRAMEBASE_BORDER)]         \
+    VARIANT border();                                   \
+                                                        \
+    [propput, id(DISPID_IHTMLFRAMEBASE_FRAMEBORDER)]    \
+    void frameBorder(BSTR v);                           \
+                                                        \
+    [propget, id(DISPID_IHTMLFRAMEBASE_FRAMEBORDER)]    \
+    BSTR frameBorder();                                 \
+                                                        \
+    [propput, id(DISPID_IHTMLFRAMEBASE_FRAMESPACING)]   \
+    void frameSpacing(VARIANT v);                       \
+                                                        \
+    [propget, id(DISPID_IHTMLFRAMEBASE_FRAMESPACING)]   \
+    VARIANT frameSpacing();                             \
+                                                        \
+    [propput, id(DISPID_IHTMLFRAMEBASE_MARGINWIDTH)]    \
+    void marginWidth(VARIANT v);                        \
+                                                        \
+    [propget, id(DISPID_IHTMLFRAMEBASE_MARGINWIDTH)]    \
+    VARIANT marginWidth();                              \
+                                                        \
+    [propput, id(DISPID_IHTMLFRAMEBASE_MARGINHEIGHT)]   \
+    void marginHeight(VARIANT v);                       \
+                                                        \
+    [propget, id(DISPID_IHTMLFRAMEBASE_MARGINHEIGHT)]   \
+    VARIANT marginHeight();                             \
+                                                        \
+    [propput, id(DISPID_IHTMLFRAMEBASE_NORESIZE)]       \
+    void noResize(VARIANT_BOOL v);                      \
+                                                        \
+    [propget, id(DISPID_IHTMLFRAMEBASE_NORESIZE)]       \
+    VARIANT_BOOL noResize();                            \
+                                                        \
+    [propput, id(DISPID_IHTMLFRAMEBASE_SCROLLING)]      \
+    void scrolling(BSTR v);                             \
+                                                        \
+    [propget, id(DISPID_IHTMLFRAMEBASE_SCROLLING)]      \
+    BSTR scrolling()
+
 /*****************************************************************************
  *    IHTMLFrameBase2 interface
@@ -14738,4 +14947,150 @@
 }
 
+#define WINE_IHTMLFRAMEBASE2_DISPINTERFACE_DECL                         \
+    [propget, id(DISPID_IHTMLFRAMEBASE2_CONTENTWINDOW)]                 \
+    IHTMLWindow2 *contentWindow();                                      \
+                                                                        \
+    [propput, id(DISPID_IHTMLFRAMEBASE2_ONLOAD), displaybind, bindable] \
+    void onload(VARIANT v);                                             \
+                                                                        \
+    [propget, id(DISPID_IHTMLFRAMEBASE2_ONLOAD), displaybind, bindable] \
+    VARIANT onload();                                                   \
+                                                                        \
+    [propput, id(DISPID_IHTMLFRAMEBASE2_ALLOWTRANSPARENCY)]             \
+    void allowTransparency(VARIANT_BOOL v);                             \
+                                                                        \
+    [propget, id(DISPID_IHTMLFRAMEBASE2_ALLOWTRANSPARENCY)]             \
+    VARIANT_BOOL allowTransparency()
+
+#define WINE_IHTMLFRAMEBASE3_DISPINTERFACE_DECL                           \
+    [propput, id(DISPID_IHTMLFRAMEBASE3_LONGDESC), displaybind, bindable] \
+    void longDesc(BSTR v);                                                \
+                                                                          \
+    [propget, id(DISPID_IHTMLFRAMEBASE3_LONGDESC), displaybind, bindable] \
+    BSTR longDesc()
+
+
+#define WINE_HTMLFRAMEBASE_DISPINTERFACE_DECL \
+    WINE_HTMLDATAELEMENT_DISPINTERFACE_DECL;  \
+    WINE_IHTMLFRAMEBASE_DISPINTERFACE_DECL;   \
+    WINE_IHTMLFRAMEBASE2_DISPINTERFACE_DECL;  \
+    WINE_IHTMLFRAMEBASE3_DISPINTERFACE_DECL
+
+/*****************************************************************************
+ *    IHTMLFrameElement3 interface
+ */
+[
+    odl,
+    oleautomation,
+    dual,
+    uuid(3051042d-98b5-11cf-bb82-00aa00bdce0b)
+]
+interface IHTMLFrameElement3 : IDispatch
+{
+    [propget, id(DISPID_IHTMLFRAMEELEMENT3_CONTENTDOCUMENT)]
+    HRESULT contentDocument([out, retval] IDispatch **p);
+
+    [propput, id(DISPID_IHTMLFRAMEELEMENT3_IE8_SRC)]
+    HRESULT src([in] BSTR v);
+
+    [propget, id(DISPID_IHTMLFRAMEELEMENT3_IE8_SRC)]
+    HRESULT src([out, retval] BSTR *p);
+
+    [propput, id(DISPID_IHTMLFRAMEELEMENT3_IE8_LONGDESC)]
+    HRESULT longDesc([in] BSTR v);
+
+    [propget, id(DISPID_IHTMLFRAMEELEMENT3_IE8_LONGDESC)]
+    HRESULT longDesc([out, retval] BSTR *p);
+
+    [propput, id(DISPID_IHTMLFRAMEELEMENT3_IE8_FRAMEBORDER)]
+    HRESULT frameBorder([in] BSTR v);
+
+    [propget, id(DISPID_IHTMLFRAMEELEMENT3_IE8_FRAMEBORDER)]
+    HRESULT frameBorder([out, retval] BSTR * p);
+}
+
+/*****************************************************************************
+ *    DispHTMLFrameElement dispinterface
+ */
+[
+    hidden,
+    uuid(3050f513-98b5-11cf-bb82-00aa00bdce0b)
+]
+dispinterface DispHTMLFrameElement
+{
+properties:
+methods:
+    WINE_HTMLFRAMEBASE_DISPINTERFACE_DECL;
+
+    [propput, id(DISPID_IHTMLFRAMEELEMENT_BORDERCOLOR)]
+    void borderColor(VARIANT v);
+
+    [propget, id(DISPID_IHTMLFRAMEELEMENT_BORDERCOLOR)]
+    VARIANT borderColor();
+
+    [propput, id(DISPID_IHTMLFRAMEELEMENT2_HEIGHT)]
+    void height(VARIANT v);
+
+    [propget, id(DISPID_IHTMLFRAMEELEMENT2_HEIGHT)]
+    VARIANT height();
+
+    [propput, id(DISPID_IHTMLFRAMEELEMENT2_WIDTH)]
+    void width(VARIANT v);
+
+    [propget, id(DISPID_IHTMLFRAMEELEMENT2_WIDTH)]
+    VARIANT width();
+
+    [propget, id(DISPID_IHTMLFRAMEELEMENT3_CONTENTDOCUMENT)]
+    IDispatch *contentDocument();
+
+    [propput, id(DISPID_IHTMLFRAMEELEMENT3_IE8_SRC)]
+    void ie8_src(BSTR v);
+
+    [propget, id(DISPID_IHTMLFRAMEELEMENT3_IE8_SRC)]
+    BSTR ie8_src();
+
+    [propput, id(DISPID_IHTMLFRAMEELEMENT3_IE8_LONGDESC)]
+    void ie8_longDesc(BSTR v);
+
+    [propget, id(DISPID_IHTMLFRAMEELEMENT3_IE8_LONGDESC)]
+    BSTR ie8_longDesc();
+
+    [propput, id(DISPID_IHTMLFRAMEELEMENT3_IE8_FRAMEBORDER)]
+    void ie8_frameBorder(BSTR v);
+
+    [propget, id(DISPID_IHTMLFRAMEELEMENT3_IE8_FRAMEBORDER)]
+    BSTR ie8_frameBorder();
+}
+
+/*****************************************************************************
+ *    IHTMLIFrameElement interface
+ */
+[
+    odl,
+    oleautomation,
+    dual,
+    uuid(3050f315-98b5-11cf-bb82-00aa00bdce0b)
+]
+interface IHTMLIFrameElement : IDispatch
+{
+    [propput, id(DISPID_IHTMLIFRAMEELEMENT_VSPACE)]
+    HRESULT vspace([in] LONG v);
+
+    [propget, id(DISPID_IHTMLIFRAMEELEMENT_VSPACE)]
+    HRESULT vspace([retval, out] LONG *p);
+
+    [propput, id(DISPID_IHTMLIFRAMEELEMENT_HSPACE)]
+    HRESULT hspace([in] LONG v);
+
+    [propget, id(DISPID_IHTMLIFRAMEELEMENT_HSPACE)]
+    HRESULT hspace([retval, out] LONG *p);
+
+    [propput, id(DISPID_IHTMLIFRAMEELEMENT_ALIGN), displaybind, bindable]
+    HRESULT align([in] BSTR v);
+
+    [propget, id(DISPID_IHTMLIFRAMEELEMENT_ALIGN), displaybind, bindable]
+    HRESULT align([retval, out] BSTR *p);
+}
+
 /*****************************************************************************
  *    DispHTMLIFrame dispinterface
@@ -14749,80 +15104,5 @@
 properties:
 methods:
-    WINE_HTMLDATAELEMENT_DISPINTERFACE_DECL;
-
-    [propput, id(DISPID_IHTMLFRAMEBASE_SRC)]
-    void src(BSTR v);
-
-    [propget, id(DISPID_IHTMLFRAMEBASE_SRC)]
-    BSTR src();
-
-    [propput, id(DISPID_IHTMLFRAMEBASE_NAME)]
-    void name(BSTR v);
-
-    [propget, id(DISPID_IHTMLFRAMEBASE_NAME)]
-    BSTR name();
-
-    [propput, id(DISPID_IHTMLFRAMEBASE_BORDER)]
-    void border(VARIANT v);
-
-    [propget, id(DISPID_IHTMLFRAMEBASE_BORDER)]
-    VARIANT border();
-
-    [propput, id(DISPID_IHTMLFRAMEBASE_FRAMEBORDER)]
-    void frameBorder(BSTR v);
-
-    [propget, id(DISPID_IHTMLFRAMEBASE_FRAMEBORDER)]
-    BSTR frameBorder();
-
-    [propput, id(DISPID_IHTMLFRAMEBASE_FRAMESPACING)]
-    void frameSpacing(VARIANT v);
-
-    [propget, id(DISPID_IHTMLFRAMEBASE_FRAMESPACING)]
-    VARIANT frameSpacing();
-
-    [propput, id(DISPID_IHTMLFRAMEBASE_MARGINWIDTH)]
-    void marginWidth(VARIANT v);
-
-    [propget, id(DISPID_IHTMLFRAMEBASE_MARGINWIDTH)]
-    VARIANT marginWidth();
-
-    [propput, id(DISPID_IHTMLFRAMEBASE_MARGINHEIGHT)]
-    void marginHeight(VARIANT v);
-
-    [propget, id(DISPID_IHTMLFRAMEBASE_MARGINHEIGHT)]
-    VARIANT marginHeight();
-
-    [propput, id(DISPID_IHTMLFRAMEBASE_NORESIZE)]
-    void noResize(VARIANT_BOOL v);
-
-    [propget, id(DISPID_IHTMLFRAMEBASE_NORESIZE)]
-    VARIANT_BOOL noResize();
-
-    [propput, id(DISPID_IHTMLFRAMEBASE_SCROLLING)]
-    void scrolling(BSTR v);
-
-    [propget, id(DISPID_IHTMLFRAMEBASE_SCROLLING)]
-    BSTR scrolling();
-
-    [propget, id(DISPID_IHTMLFRAMEBASE2_CONTENTWINDOW)]
-    IHTMLWindow2 *contentWindow();
-
-    [propput, id(DISPID_IHTMLFRAMEBASE2_ONLOAD), displaybind, bindable]
-    void onload(VARIANT v);
-
-    [propget, id(DISPID_IHTMLFRAMEBASE2_ONLOAD), displaybind, bindable]
-    VARIANT onload();
-
-    [propput, id(DISPID_IHTMLFRAMEBASE2_ALLOWTRANSPARENCY)]
-    void allowTransparency(VARIANT_BOOL v);
-
-    [propget, id(DISPID_IHTMLFRAMEBASE2_ALLOWTRANSPARENCY)]
-    VARIANT_BOOL allowTransparency();
-
-    [propput, id(DISPID_IHTMLFRAMEBASE3_LONGDESC), displaybind, bindable]
-    void longDesc(BSTR v);
-
-    [propget, id(DISPID_IHTMLFRAMEBASE3_LONGDESC), displaybind, bindable]
-    BSTR longDesc();
+    WINE_HTMLFRAMEBASE_DISPINTERFACE_DECL;
 
     [propput, id(DISPID_IHTMLIFRAMEELEMENT_VSPACE)]
@@ -15137,2 +15417,22 @@
 
 } /* library MSHTML */
+
+interface IOleCommandTarget;
+
+/*****************************************************************************
+ *    IHTMLPrivateWindow interface
+ */
+[
+    object,
+    uuid(3050f6dc-98b5-11cf-bb82-00aa00bdce0b),
+    local
+]
+interface IHTMLPrivateWindow : IUnknown
+{
+    HRESULT SuperNavigate(BSTR url, BSTR arg2, BSTR arg3, BSTR arg4, VARIANT *post_data, VARIANT *headers, ULONG flags);
+    HRESULT GetPendingUrl(BSTR *url);
+    HRESULT SetPICSTarget(IOleCommandTarget *cmdtrg);
+    HRESULT PICSComplete(int arg);
+    HRESULT FindWindowByName(LPCWSTR name, IHTMLWindow2 **ret);
+    HRESULT GetAddressBarUrl(BSTR *url);
+}
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msi.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msi.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msi.h	(revision 28475)
@@ -513,4 +513,8 @@
 #define     MsiGetPatchInfoEx WINELIB_NAME_AW(MsiGetPatchInfoEx)
 
+UINT WINAPI MsiGetPatchInfoA(LPCSTR, LPCSTR, LPSTR, LPDWORD);
+UINT WINAPI MsiGetPatchInfoW(LPCWSTR, LPCWSTR, LPWSTR, LPDWORD);
+#define     MsiGetPatchInfo WINELIB_NAME_AW(MsiGetPatchInfo)
+
 UINT WINAPI MsiEnableLogA(DWORD, LPCSTR, DWORD);
 UINT WINAPI MsiEnableLogW(DWORD, LPCWSTR, DWORD);
@@ -607,4 +611,8 @@
 #define     MsiSourceListEnumSources WINELIB_NAME_AW(MsiSourceListEnumSources)
 
+UINT WINAPI MsiSourceListClearSourceA(LPCSTR, LPCSTR, MSIINSTALLCONTEXT, DWORD, LPCSTR);
+UINT WINAPI MsiSourceListClearSourceW(LPCWSTR, LPCWSTR, MSIINSTALLCONTEXT, DWORD, LPCWSTR);
+#define     MsiSourceListClearSource WINELIB_NAME_AW(MsiSourceListClearSource)
+
 UINT WINAPI MsiSourceListClearAllA(LPCSTR, LPCSTR, DWORD);
 UINT WINAPI MsiSourceListClearAllW(LPCWSTR, LPCWSTR, DWORD);
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msidefs.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msidefs.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msidefs.h	(revision 28475)
@@ -230,4 +230,13 @@
     msidbRemoveFileInstallModeOnRemove = 0x00000002,
     msidbRemoveFileInstallModeOnBoth = 0x00000003,
+};
+
+enum
+{
+    msidbIniFileActionAddLine    = 0x00000000,
+    msidbIniFileActionCreateLine = 0x00000001,
+    msidbIniFileActionRemoveLine = 0x00000002,
+    msidbIniFileActionAddTag     = 0x00000003,
+    msidbIniFileActionRemoveTag  = 0x00000004
 };
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/mstcpip.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/mstcpip.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/mstcpip.h	(revision 28475)
@@ -28,7 +28,7 @@
 struct tcp_keepalive
 {
-    u_long onoff;
-    u_long keepalivetime;
-    u_long keepaliveinterval;
+    ULONG onoff;
+    ULONG keepalivetime;
+    ULONG keepaliveinterval;
 };
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msvcrt/conio.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msvcrt/conio.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msvcrt/conio.h	(revision 28475)
@@ -6,4 +6,5 @@
  * This file is in the public domain.
  */
+
 /*
  * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msvcrt/crtdbg.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msvcrt/crtdbg.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msvcrt/crtdbg.h	(revision 28475)
@@ -27,4 +27,5 @@
  * of the LGPL is applied is otherwise unspecified.
  */
+
 #ifndef __WINE_CRTDBG_H_
 #define __WINE_CRTDBG_H_
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msvcrt/ctype.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msvcrt/ctype.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msvcrt/ctype.h	(revision 28475)
@@ -6,4 +6,5 @@
  * This file is in the public domain.
  */
+
 /*
  * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msvcrt/direct.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msvcrt/direct.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msvcrt/direct.h	(revision 28475)
@@ -6,4 +6,5 @@
  * This file is in the public domain.
  */
+
 /*
  * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msvcrt/dos.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msvcrt/dos.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msvcrt/dos.h	(revision 28475)
@@ -6,4 +6,5 @@
  * This file is in the public domain.
  */
+
 /*
  * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msvcrt/eh.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msvcrt/eh.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msvcrt/eh.h	(revision 28475)
@@ -18,4 +18,5 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
+
 /*
  * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msvcrt/fcntl.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msvcrt/fcntl.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msvcrt/fcntl.h	(revision 28475)
@@ -6,4 +6,5 @@
  * This file is in the public domain.
  */
+
 /*
  * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msvcrt/io.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msvcrt/io.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msvcrt/io.h	(revision 28475)
@@ -6,4 +6,5 @@
  * This file is in the public domain.
  */
+
 /*
  * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msvcrt/setjmp.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msvcrt/setjmp.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msvcrt/setjmp.h	(revision 28475)
@@ -53,10 +53,51 @@
 } _JUMP_BUFFER;
 
-#endif /* __i386__ */
+#define _JBLEN 16
+#define _JBTYPE int
 
-#define _JBLEN                     16
-#define _JBTYPE                    int
-typedef _JBTYPE                    jmp_buf[_JBLEN];
+#elif defined(__x86_64__)
 
+typedef struct _SETJMP_FLOAT128
+{
+    unsigned __int64 DECLSPEC_ALIGN(16) Part[2];
+} SETJMP_FLOAT128;
+
+typedef struct _JUMP_BUFFER
+{
+    unsigned __int64 Frame;
+    unsigned __int64 Rbx;
+    unsigned __int64 Rsp;
+    unsigned __int64 Rbp;
+    unsigned __int64 Rsi;
+    unsigned __int64 Rdi;
+    unsigned __int64 R12;
+    unsigned __int64 R13;
+    unsigned __int64 R14;
+    unsigned __int64 R15;
+    unsigned __int64 Rip;
+    unsigned __int64 Spare;
+    SETJMP_FLOAT128  Xmm6;
+    SETJMP_FLOAT128  Xmm7;
+    SETJMP_FLOAT128  Xmm8;
+    SETJMP_FLOAT128  Xmm9;
+    SETJMP_FLOAT128  Xmm10;
+    SETJMP_FLOAT128  Xmm11;
+    SETJMP_FLOAT128  Xmm12;
+    SETJMP_FLOAT128  Xmm13;
+    SETJMP_FLOAT128  Xmm14;
+    SETJMP_FLOAT128  Xmm15;
+} _JUMP_BUFFER;
+
+#define _JBLEN  16
+typedef SETJMP_FLOAT128 _JBTYPE;
+
+#else
+
+#define _JBLEN 1
+#define _JBTYPE int
+
+#endif
+
+typedef _JBTYPE jmp_buf[_JBLEN];
 
 #ifdef __cplusplus
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msvcrt/stdlib.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msvcrt/stdlib.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msvcrt/stdlib.h	(revision 28475)
@@ -229,4 +229,10 @@
 #endif /* _WSTDLIB_DEFINED */
 
+typedef void (__cdecl *_invalid_parameter_handler)(const wchar_t*, const wchar_t*, const wchar_t*, unsigned, uintptr_t);
+_invalid_parameter_handler __cdecl _set_invalid_parameter_handler(_invalid_parameter_handler);
+_invalid_parameter_handler __cdecl _get_invalid_parameter_handler(void);
+void __cdecl _invalid_parameter(const wchar_t *expr, const wchar_t *func, const wchar_t *file,
+                                unsigned int line, uintptr_t arg);
+
 #ifdef __cplusplus
 }
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msvcrt/sys/locking.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msvcrt/sys/locking.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msvcrt/sys/locking.h	(revision 28475)
@@ -27,4 +27,5 @@
  * of the LGPL is applied is otherwise unspecified.
  */
+
 #ifndef __WINE_SYS_LOCKING_H__
 #define __WINE_SYS_LOCKING_H__
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/mswsock.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/mswsock.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/mswsock.h	(revision 28475)
@@ -25,4 +25,5 @@
  * of the LGPL is applied is otherwise unspecified.
  */
+
 #ifndef _MSWSOCK_
 #define _MSWSOCK_
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msxml.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msxml.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msxml.h	(revision 28475)
@@ -1,3 +1,3 @@
-/*** Autogenerated by WIDL 1.1.36 from ../../include/msxml.idl - Do not edit ***/
+/*** Autogenerated by WIDL 1.1.43 from ../../include/msxml.idl - Do not edit ***/
 
 #include <rpc.h>
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msxml2.idl
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msxml2.idl	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msxml2.idl	(revision 28475)
@@ -95,4 +95,20 @@
 interface IMXWriter;
 
+interface IXMLDOMSchemaCollection2;
+interface ISchemaStringCollection;
+interface ISchemaItemCollection;
+interface ISchemaItem;
+interface ISchema;
+interface ISchemaParticle;
+interface ISchemaAttribute;
+interface ISchemaElement;
+interface ISchemaType;
+interface ISchemaComplexType;
+interface ISchemaAttributeGroup;
+interface ISchemaModelGroup;
+interface ISchemaAny;
+interface ISchemaIdentityConstraint;
+interface ISchemaNotation;
+
 
 cpp_quote("#define DOMDocument DOMDocument2")
@@ -118,4 +134,132 @@
 cpp_quote("#endif   /* __WIDL_XMLDOM_H */")
 
+typedef enum _SOMITEMTYPE
+{
+    SOMITEM_SCHEMA                      = 0x1000,
+    SOMITEM_ATTRIBUTE                   = 0x1001,
+    SOMITEM_ATTRIBUTEGROUP              = 0x1002,
+    SOMITEM_NOTATION                    = 0x1003,
+    SOMITEM_IDENTITYCONSTRAINT          = 0x1100,
+    SOMITEM_KEY                         = 0x1101,
+    SOMITEM_KEYREF                      = 0x1102,
+    SOMITEM_UNIQUE                      = 0x1103,
+    SOMITEM_ANYTYPE                     = 0x2000,
+    SOMITEM_DATATYPE                    = 0x2100,
+    SOMITEM_DATATYPE_ANYTYPE            = 0x2101,
+    SOMITEM_DATATYPE_ANYURI             = 0x2102,
+    SOMITEM_DATATYPE_BASE64BINARY       = 0x2103,
+    SOMITEM_DATATYPE_BOOLEAN            = 0x2104,
+    SOMITEM_DATATYPE_BYTE               = 0x2105,
+    SOMITEM_DATATYPE_DATE               = 0x2106,
+    SOMITEM_DATATYPE_DATETIME           = 0x2107,
+    SOMITEM_DATATYPE_DAY                = 0x2108,
+    SOMITEM_DATATYPE_DECIMAL            = 0x2109,
+    SOMITEM_DATATYPE_DOUBLE             = 0x210A,
+    SOMITEM_DATATYPE_DURATION           = 0x210B,
+    SOMITEM_DATATYPE_ENTITIES           = 0x210C,
+    SOMITEM_DATATYPE_ENTITY             = 0x210D,
+    SOMITEM_DATATYPE_FLOAT              = 0x210E,
+    SOMITEM_DATATYPE_HEXBINARY          = 0x210F,
+    SOMITEM_DATATYPE_ID                 = 0x2110,
+    SOMITEM_DATATYPE_IDREF              = 0x2111,
+    SOMITEM_DATATYPE_IDREFS             = 0x2112,
+    SOMITEM_DATATYPE_INT                = 0x2113,
+    SOMITEM_DATATYPE_INTEGER            = 0x2114,
+    SOMITEM_DATATYPE_LANGUAGE           = 0x2115,
+    SOMITEM_DATATYPE_LONG               = 0x2116,
+    SOMITEM_DATATYPE_MONTH              = 0x2117,
+    SOMITEM_DATATYPE_MONTHDAY           = 0x2118,
+    SOMITEM_DATATYPE_NAME               = 0x2119,
+    SOMITEM_DATATYPE_NCNAME             = 0x211A,
+    SOMITEM_DATATYPE_NEGATIVEINTEGER    = 0x211B,
+    SOMITEM_DATATYPE_NMTOKEN            = 0x211C,
+    SOMITEM_DATATYPE_NMTOKENS           = 0x211D,
+    SOMITEM_DATATYPE_NONNEGATIVEINTEGER = 0x211E,
+    SOMITEM_DATATYPE_NONPOSITIVEINTEGER = 0x211F,
+    SOMITEM_DATATYPE_NORMALIZEDSTRING   = 0x2120,
+    SOMITEM_DATATYPE_NOTATION           = 0x2121,
+    SOMITEM_DATATYPE_POSITIVEINTEGER    = 0x2122,
+    SOMITEM_DATATYPE_QNAME              = 0x2123,
+    SOMITEM_DATATYPE_SHORT              = 0x2124,
+    SOMITEM_DATATYPE_STRING             = 0x2125,
+    SOMITEM_DATATYPE_TIME               = 0x2126,
+    SOMITEM_DATATYPE_TOKEN              = 0x2127,
+    SOMITEM_DATATYPE_UNSIGNEDBYTE       = 0x2128,
+    SOMITEM_DATATYPE_UNSIGNEDINT        = 0x2129,
+    SOMITEM_DATATYPE_UNSIGNEDLONG       = 0x212A,
+    SOMITEM_DATATYPE_UNSIGNEDSHORT      = 0x212B,
+    SOMITEM_DATATYPE_YEAR               = 0x212C,
+    SOMITEM_DATATYPE_YEARMONTH          = 0x212D,
+    SOMITEM_DATATYPE_ANYSIMPLETYPE      = 0x21FF,
+    SOMITEM_SIMPLETYPE                  = 0x2200,
+    SOMITEM_COMPLEXTYPE                 = 0x2400,
+    SOMITEM_PARTICLE                    = 0x4000,
+    SOMITEM_ANY                         = 0x4001,
+    SOMITEM_ANYATTRIBUTE                = 0x4002,
+    SOMITEM_ELEMENT                     = 0x4003,
+    SOMITEM_GROUP                       = 0x4100,
+    SOMITEM_ALL                         = 0x4101,
+    SOMITEM_CHOICE                      = 0x4102,
+    SOMITEM_SEQUENCE                    = 0x4103,
+    SOMITEM_EMPTYPARTICLE               = 0x4104,
+    SOMITEM_NULL                        = 0x0800,
+    SOMITEM_NULL_TYPE                   = 0x2800,
+    SOMITEM_NULL_ANY                    = 0x4801,
+    SOMITEM_NULL_ANYATTRIBUTE           = 0x4802,
+    SOMITEM_NULL_ELEMENT                = 0x4803,
+} SOMITEMTYPE;
+
+typedef enum _SCHEMAUSE
+{
+    SCHEMAUSE_OPTIONAL,
+    SCHEMAUSE_PROHIBITED,
+    SCHEMAUSE_REQUIRED,
+} SCHEMAUSE;
+
+typedef enum _SCHEMADERIVATIONMETHOD
+{
+    SCHEMADERIVATIONMETHOD_EMPTY        = 0x0000,
+    SCHEMADERIVATIONMETHOD_SUBSTITUTION = 0x0001,
+    SCHEMADERIVATIONMETHOD_EXTENSION    = 0x0002,
+    SCHEMADERIVATIONMETHOD_RESTRICTION  = 0x0004,
+    SCHEMADERIVATIONMETHOD_LIST         = 0x0008,
+    SCHEMADERIVATIONMETHOD_UNION        = 0x0010,
+    SCHEMADERIVATIONMETHOD_ALL          = 0x00FF,
+    SCHEMADERIVATIONMETHOD_NONE         = 0x0100,
+} SCHEMADERIVATIONMETHOD;
+
+typedef enum _SCHEMACONTENTTYPE
+{
+    SCHEMACONTENTTYPE_EMPTY,
+    SCHEMACONTENTTYPE_TEXTONLY,
+    SCHEMACONTENTTYPE_ELEMENTONLY,
+    SCHEMACONTENTTYPE_MIXED,
+} SCHEMACONTENTTYPE;
+
+typedef enum _SCHEMAPROCESSCONTENTS
+{
+    SCHEMAPROCESSCONTENTS_NONE,
+    SCHEMAPROCESSCONTENTS_SKIP,
+    SCHEMAPROCESSCONTENTS_LAX,
+    SCHEMAPROCESSCONTENTS_STRICT,
+} SCHEMAPROCESSCONTENTS;
+
+typedef enum _SCHEMAWHITESPACE
+{
+    SCHEMAWHITESPACE_NONE       = -1,
+    SCHEMAWHITESPACE_PRESERVE   =  0,
+    SCHEMAWHITESPACE_REPLACE    =  1,
+    SCHEMAWHITESPACE_COLLAPSE   =  2,
+} SCHEMAWHITESPACE;
+
+
+typedef enum _SCHEMATYPEVARIETY
+{
+    SCHEMATYPEVARIETY_NONE      = -1,
+    SCHEMATYPEVARIETY_ATOMIC    =  0,
+    SCHEMATYPEVARIETY_LIST      =  1,
+    SCHEMATYPEVARIETY_UNION     =  2,
+} SCHEMATYPEVARIETY;
+
 [
 local,
@@ -426,4 +570,33 @@
     HRESULT _newEnum([retval, out] IUnknown **ppUnk);
 }
+
+[
+    local,
+    object,
+    uuid(50ea08b0-dd1b-4664-9a50-c2f40f4bd79a),
+]
+interface IXMLDOMSchemaCollection2 : IXMLDOMSchemaCollection
+{
+    [id(DISPID_SOM_VALIDATE)]
+    HRESULT validate();
+
+    [propput, id(DISPID_SOM_VALIDATEONLOAD)]
+    HRESULT validateOnLoad(
+        [in] VARIANT_BOOL validateOnLoad);
+
+    [propget, id(DISPID_SOM_VALIDATEONLOAD)]
+    HRESULT validateOnLoad(
+        [out,retval] VARIANT_BOOL* validateOnLoad);
+
+    [id(DISPID_SOM_GETSCHEMA)]
+    HRESULT getSchema(
+        [in] BSTR namespaceURI,
+        [out,retval] ISchema** schema);
+
+    [id(DISPID_SOM_GETDECLARATION)]
+    HRESULT getDeclaration(
+        [in] IXMLDOMNode* node,
+        [out,retval]ISchemaItem** item);
+};
 
 [
@@ -1080,4 +1253,12 @@
 }
 
+[
+    uuid(88d969c0-f192-11d4-a65f-0040963251e5)
+]
+coclass DOMDocument40
+{
+    [default] interface IXMLDOMDocument2;
+    [default, source] dispinterface XMLDOMDocumentEvents;
+}
 
 [
@@ -1962,4 +2143,441 @@
 
 [
+    local,
+    object,
+    uuid(50ea08b1-dd1b-4664-9a50-c2f40f4bd79a),
+    dual
+]
+interface ISchemaStringCollection : IDispatch
+{
+    [id(DISPID_VALUE), propget]
+    HRESULT item(
+        [in] long index,
+        [out,retval] BSTR* bstr);
+
+    [id(DISPID_SOM_LENGTH), propget]
+    HRESULT length(
+        [out,retval] long* length);
+
+    [id(DISPID_NEWENUM), hidden, restricted, propget]
+    HRESULT _newEnum(
+        [out,retval] IUnknown** ppunk);
+};
+
+[
+    local,
+    object,
+    uuid(50ea08b2-dd1b-4664-9a50-c2f40f4bd79a),
+    dual
+]
+interface ISchemaItemCollection : IDispatch
+{
+    [id(DISPID_VALUE), propget]
+    HRESULT item(
+        [in] long index,
+        [out,retval]ISchemaItem** item);
+
+    [id(DISPID_SOM_ITEMBYNAME)]
+    HRESULT itemByName(
+        [in] BSTR name,
+        [out,retval] ISchemaItem** item);
+
+    [id(DISPID_SOM_ITEMBYQNAME)]
+    HRESULT itemByQName(
+        [in] BSTR name,
+        [in] BSTR namespaceURI,
+        [out,retval] ISchemaItem** item);
+
+    [id(DISPID_SOM_LENGTH), propget]
+    HRESULT length(
+        [out,retval]long* length);
+
+    [id(DISPID_NEWENUM), hidden, restricted, propget]
+    HRESULT _newEnum(
+        [out,retval]IUnknown** ppunk);
+};
+
+[
+    local,
+    object,
+    uuid(50ea08b3-dd1b-4664-9a50-c2f40f4bd79a),
+    dual
+]
+interface ISchemaItem : IDispatch
+{
+    [id(DISPID_SOM_NAME), propget]
+    HRESULT name(
+        [out,retval] BSTR* name);
+
+    [id(DISPID_SOM_NAMESPACEURI), propget]
+    HRESULT namespaceURI(
+        [out,retval] BSTR* namespaceURI);
+
+    [id(DISPID_SOM_SCHEMA), propget]
+    HRESULT schema(
+        [out,retval] ISchema** schema);
+
+    [id(DISPID_SOM_ID), propget]
+    HRESULT id(
+        [out,retval] BSTR* id);
+
+    [id(DISPID_SOM_ITEMTYPE), propget]
+    HRESULT itemType(
+        [out,retval] SOMITEMTYPE* itemType);
+
+    [id(DISPID_SOM_UNHANDLEDATTRS), propget]
+    HRESULT unhandledAttributes(
+        [out,retval] IVBSAXAttributes** attributes);
+
+    [id(DISPID_SOM_WRITEANNOTATION)]
+    HRESULT writeAnnotation(
+        [in] IUnknown* annotationSink,
+        [out,retval] VARIANT_BOOL* isWritten);
+};
+
+[
+    local,
+    object,
+    uuid(50ea08b4-dd1b-4664-9a50-c2f40f4bd79a),
+    dual
+]
+interface ISchema : ISchemaItem
+{
+    [id(DISPID_SOM_TARGETNAMESPACE), propget]
+    HRESULT targetNamespace(
+        [out,retval] BSTR* targetNamespace);
+
+    [id(DISPID_SOM_VERSION), propget]
+    HRESULT version(
+        [out,retval] BSTR* version);
+
+    [id(DISPID_SOM_TYPES), propget]
+    HRESULT types(
+        [out,retval] ISchemaItemCollection** types);
+
+    [id(DISPID_SOM_ELEMENTS), propget]
+    HRESULT elements(
+        [out,retval] ISchemaItemCollection** elements);
+
+    [id(DISPID_SOM_ATTRIBUTES), propget]
+    HRESULT attributes(
+        [out,retval] ISchemaItemCollection** attributes);
+
+    [id(DISPID_SOM_ATTRIBUTEGROUPS), propget]
+    HRESULT attributeGroups(
+        [out,retval] ISchemaItemCollection** attributeGroups);
+
+    [id(DISPID_SOM_MODELGROUPS), propget]
+    HRESULT modelGroups(
+        [out,retval] ISchemaItemCollection** modelGroups);
+
+    [id(DISPID_SOM_NOTATIONS), propget]
+    HRESULT notations(
+        [out,retval] ISchemaItemCollection** notations);
+
+    [id(DISPID_SOM_SCHEMALOCATIONS), propget]
+    HRESULT schemaLocations(
+        [out,retval] ISchemaStringCollection** schemaLocations);
+};
+
+[
+    local,
+    object,
+    uuid(50ea08b5-dd1b-4664-9a50-c2f40f4bd79a),
+    dual
+]
+interface ISchemaParticle : ISchemaItem
+{
+    [id(DISPID_SOM_MINOCCURS), propget]
+    HRESULT minOccurs(
+        [out,retval] VARIANT* minOccurs);
+
+    [id(DISPID_SOM_MAXOCCURS), propget]
+    HRESULT maxOccurs(
+        [out,retval] VARIANT* maxOccurs);
+};
+
+[
+    object,
+    uuid(50ea08b6-dd1b-4664-9a50-c2f40f4bd79a),
+    dual,
+]
+interface ISchemaAttribute : ISchemaItem
+{
+    [id(DISPID_SOM_TYPE), propget]
+    HRESULT type(
+        [out,retval] ISchemaType** type);
+
+    [id(DISPID_SOM_SCOPE), propget]
+    HRESULT scope(
+        [out,retval] ISchemaComplexType** scope);
+
+    [id(DISPID_SOM_DEFAULTVALUE), propget]
+    HRESULT defaultValue(
+        [out,retval]BSTR* defaultValue);
+
+    [id(DISPID_SOM_FIXEDVALUE), propget]
+    HRESULT fixedValue(
+        [out,retval] BSTR* fixedValue);
+
+    [id(DISPID_SOM_USE), propget]
+    HRESULT use(
+        [out,retval] SCHEMAUSE* use);
+
+    [id(DISPID_SOM_ISREFERENCE), propget]
+    HRESULT isReference(
+        [out,retval] VARIANT_BOOL* reference);
+};
+
+[
+    local,
+    object,
+    uuid(50ea08b7-dd1b-4664-9a50-c2f40f4bd79a),
+    dual
+]
+interface ISchemaElement : ISchemaParticle
+{
+    [id(DISPID_SOM_TYPE), propget]
+    HRESULT type(
+        [out,retval] ISchemaType** type);
+
+    [id(DISPID_SOM_SCOPE), propget]
+    HRESULT scope(
+        [out,retval] ISchemaComplexType** scope);
+
+    [id(DISPID_SOM_DEFAULTVALUE), propget]
+    HRESULT defaultValue(
+        [out,retval] BSTR* defaultValue);
+
+    [id(DISPID_SOM_FIXEDVALUE), propget]
+    HRESULT fixedValue(
+        [out,retval] BSTR* fixedValue);
+
+    [id(DISPID_SOM_ISNILLABLE), propget]
+    HRESULT isNillable(
+        [out,retval] VARIANT_BOOL* nillable);
+
+    [id(DISPID_SOM_IDCONSTRAINTS), propget]
+    HRESULT identityConstraints(
+        [out,retval] ISchemaItemCollection** constraints);
+
+    [id(DISPID_SOM_SUBSTITUTIONGROUP), propget]
+    HRESULT substitutionGroup(
+        [out,retval] ISchemaElement** element);
+
+    [id(DISPID_SOM_EXCLUSIONS), propget]
+    HRESULT substitutionGroupExclusions(
+        [out,retval] SCHEMADERIVATIONMETHOD* exclusions);
+
+    [id(DISPID_SOM_DISALLOWED), propget]
+    HRESULT disallowedSubstitutions(
+        [out,retval] SCHEMADERIVATIONMETHOD* disallowed);
+
+    [id(DISPID_SOM_ISABSTRACT), propget]
+    HRESULT isAbstract(
+        [out,retval] VARIANT_BOOL* abstract);
+
+    [id(DISPID_SOM_ISREFERENCE), propget]
+    HRESULT isReference(
+        [out,retval] VARIANT_BOOL* reference);
+};
+
+[
+    local,
+    object,
+    uuid(50ea08b8-dd1b-4664-9a50-c2f40f4bd79a),
+    dual
+]
+interface ISchemaType : ISchemaItem
+{
+    [id(DISPID_SOM_BASETYPES), propget]
+    HRESULT baseTypes(
+        [out,retval] ISchemaItemCollection** baseTypes);
+
+    [id(DISPID_SOM_FINAL), propget]
+    HRESULT final(
+        [out,retval] SCHEMADERIVATIONMETHOD* final);
+
+    [id(DISPID_SOM_VARIETY), propget]
+    HRESULT variety(
+        [out,retval] SCHEMATYPEVARIETY* variety);
+
+    [id(DISPID_SOM_DERIVEDBY), propget]
+    HRESULT derivedBy(
+        [out,retval] SCHEMADERIVATIONMETHOD* derivedBy);
+
+    [id(DISPID_SOM_ISVALID)]
+    HRESULT isValid(
+        [in] BSTR data,
+        [out,retval] VARIANT_BOOL* valid);
+
+    [id(DISPID_SOM_MINEXCLUSIVE), propget]
+    HRESULT minExclusive(
+        [out,retval]BSTR* minExclusive);
+
+    [id(DISPID_SOM_MININCLUSIVE), propget]
+    HRESULT minInclusive(
+        [out,retval] BSTR* minInclusive);
+
+    [id(DISPID_SOM_MAXEXCLUSIVE), propget]
+    HRESULT maxExclusive(
+        [out,retval] BSTR* maxExclusive);
+
+    [id(DISPID_SOM_MAXINCLUSIVE), propget]
+    HRESULT maxInclusive(
+        [out,retval] BSTR* maxInclusive);
+
+    [id(DISPID_SOM_TOTALDIGITS), propget]
+    HRESULT totalDigits(
+        [out,retval] VARIANT* totalDigits);
+
+    [id(DISPID_SOM_FRACTIONDIGITS), propget]
+    HRESULT fractionDigits(
+        [out,retval] VARIANT* fractionDigits);
+
+    [id(DISPID_SOM_LENGTH), propget]
+    HRESULT length(
+        [out,retval] VARIANT* length);
+
+    [id(DISPID_SOM_MINLENGTH), propget]
+    HRESULT minLength(
+        [out,retval]VARIANT* minLength);
+
+    [id(DISPID_SOM_MAXLENGTH), propget]
+    HRESULT maxLength(
+        [out,retval]VARIANT* maxLength);
+
+    [id(DISPID_SOM_ENUMERATION), propget]
+    HRESULT enumeration(
+        [out,retval] ISchemaStringCollection** enumeration);
+
+    [id(DISPID_SOM_WHITESPACE), propget]
+    HRESULT whitespace(
+        [out,retval]SCHEMAWHITESPACE* whitespace);
+
+    [id(DISPID_SOM_PATTERNS), propget]
+    HRESULT patterns(
+        [out,retval] ISchemaStringCollection** patterns);
+};
+
+[
+    local,
+    object,
+    uuid(50ea08b9-dd1b-4664-9a50-c2f40f4bd79a),
+    dual,
+]
+interface ISchemaComplexType : ISchemaType
+{
+    [id(DISPID_SOM_ISABSTRACT), propget]
+    HRESULT isAbstract(
+        [out,retval] VARIANT_BOOL* abstract);
+
+    [id(DISPID_SOM_ANYATTRIBUTE), propget]
+    HRESULT anyAttribute(
+        [out,retval] ISchemaAny** anyAttribute);
+
+    [id(DISPID_SOM_ATTRIBUTES), propget]
+    HRESULT attributes(
+        [out,retval] ISchemaItemCollection** attributes);
+
+    [id(DISPID_SOM_CONTENTTYPE), propget]
+    HRESULT contentType(
+        [out,retval] SCHEMACONTENTTYPE* contentType);
+
+    [id(DISPID_SOM_CONTENTMODEL), propget]
+    HRESULT contentModel(
+        [out,retval] ISchemaModelGroup** contentModel);
+
+    [id(DISPID_SOM_PROHIBITED), propget]
+    HRESULT prohibitedSubstitutions(
+        [out,retval] SCHEMADERIVATIONMETHOD* prohibited);
+};
+
+[
+    local,
+    object,
+    uuid(50ea08ba-dd1b-4664-9a50-c2f40f4bd79a),
+    dual,
+]
+interface ISchemaAttributeGroup : ISchemaItem
+{
+    [id(DISPID_SOM_ANYATTRIBUTE), propget]
+    HRESULT anyAttribute(
+        [out,retval] ISchemaAny** anyAttribute);
+
+    [id(DISPID_SOM_ATTRIBUTES), propget]
+        HRESULT attributes(
+            [out,retval] ISchemaItemCollection** attributes);
+};
+
+[
+    local,
+    object,
+    uuid(50ea08bb-dd1b-4664-9a50-c2f40f4bd79a),
+    dual,
+]
+interface ISchemaModelGroup : ISchemaParticle
+{
+    [id(DISPID_SOM_PARTICLES), propget]
+    HRESULT particles(
+        [out,retval] ISchemaItemCollection** particles);
+};
+
+[
+    local,
+    object,
+    uuid(50ea08bc-dd1b-4664-9a50-c2f40f4bd79a),
+    dual
+]
+interface ISchemaAny : ISchemaParticle
+{
+    [id(DISPID_SOM_NAMESPACES), propget]
+    HRESULT namespaces(
+        [out,retval] ISchemaStringCollection** namespaces);
+
+    [id(DISPID_SOM_PROCESSCONTENTS), propget]
+    HRESULT processContents(
+        [out,retval] SCHEMAPROCESSCONTENTS* processContents);
+};
+
+[
+    local,
+    object,
+    uuid(50ea08bd-dd1b-4664-9a50-c2f40f4bd79a),
+    dual
+]
+interface ISchemaIdentityConstraint : ISchemaItem
+{
+    [id(DISPID_SOM_SELECTOR), propget]
+    HRESULT selector(
+        [out,retval] BSTR* selector);
+
+    [id(DISPID_SOM_FIELDS), propget]
+        HRESULT fields(
+            [out,retval] ISchemaStringCollection** fields);
+
+    [id(DISPID_SOM_REFERENCEDKEY), propget]
+    HRESULT referencedKey(
+        [out,retval] ISchemaIdentityConstraint** key);
+};
+
+[
+    local,
+    object,
+    uuid(50ea08be-dd1b-4664-9a50-c2f40f4bd79a),
+    dual
+]
+interface ISchemaNotation : ISchemaItem
+{
+    [id(DISPID_SOM_SYSTEMIDENTIFIER), propget]
+    HRESULT systemIdentifier(
+        [out,retval] BSTR* uri);
+
+    [id(DISPID_SOM_PUBLICIDENTIFIER), propget]
+    HRESULT publicIdentifier(
+        [out,retval] BSTR* uri);
+};
+
+
+[
     uuid(079aa557-4a18-424a-8eee-e39f0a8d41b9)
 ]
@@ -1979,4 +2597,13 @@
     interface ISAXXMLReader;
     interface IMXReaderControl;
+};
+
+[
+    uuid(7c6e29bc-8b8b-4c3d-859e-af6cd158be0f)
+]
+coclass SAXXMLReader40
+{
+    [default] interface IVBSAXXMLReader;
+    interface ISAXXMLReader;
 };
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msxml2did.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msxml2did.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/msxml2did.h	(revision 28475)
@@ -404,4 +404,86 @@
 #define DISPID_MX_READER_CONTROL_SUSPEND                0x00000578
 
+#define DISPID_MX_SCHEMADECLHANDLER                     0x0000057a
+#define DISPID_MX_SCHEMADECLHANDLER_SCHEMAELEMENTDECL   0x0000057b
+
+#define DISPID_MX_NSMGR                                 0x0000057d
+#define DISPID_MX_NSMGR_ALLOWOVERRIDE                   0x0000057e
+#define DISPID_MX_NSMGR_RESET                           0x0000057f
+#define DISPID_MX_NSMGR_PUSHCONTEXT                     0x00000580
+#define DISPID_MX_NSMGR_PUSHNODECONTEXT                 0x00000581
+#define DISPID_MX_NSMGR_POPCONTEXT                      0x00000582
+#define DISPID_MX_NSMGR_DECLAREPREFIX                   0x00000583
+#define DISPID_MX_NSMGR_GETDECLAREDPREFIXES             0x00000584
+#define DISPID_MX_NSMGR_GETPREFIXES                     0x00000585
+#define DISPID_MX_NSMGR_GETURI                          0x00000586
+#define DISPID_MX_NSMGR_GETURIFROMNODE                  0x00000587
+#define DISPID_MX_NSMGR_LENGTH                          0x00000588
+
+#define DISPID_SOM_VALIDATE                             0x0000058b
+#define DISPID_SOM_VALIDATEONLOAD                       0x0000058c
+#define DISPID_SOM_GETSCHEMA                            0x0000058d
+#define DISPID_SOM_GETDECLARATION                       0x0000058e
+#define DISPID_SOM_ITEMBYNAME                           0x0000058f
+#define DISPID_SOM_ITEMBYQNAME                          0x00000590
+#define DISPID_SOM_ANYATTRIBUTE                         0x00000591
+#define DISPID_SOM_ATTRIBUTEGROUPS                      0x00000592
+#define DISPID_SOM_ATTRIBUTES                           0x00000593
+#define DISPID_SOM_BASETYPES                            0x00000594
+#define DISPID_SOM_CONTENTMODEL                         0x00000595
+#define DISPID_SOM_CONTENTTYPE                          0x00000596
+#define DISPID_SOM_DEFAULTVALUE                         0x00000597
+#define DISPID_SOM_DERIVEDBY                            0x00000598
+#define DISPID_SOM_DISALLOWED                           0x00000599
+#define DISPID_SOM_ELEMENTS                             0x0000059a
+#define DISPID_SOM_ENUMERATION                          0x0000059b
+#define DISPID_SOM_FIELDS                               0x0000059c
+#define DISPID_SOM_FINAL                                0x0000059d
+#define DISPID_SOM_FIXEDVALUE                           0x0000059e
+#define DISPID_SOM_FRACTIONDIGITS                       0x0000059f
+#define DISPID_SOM_ID                                   0x000005a0
+#define DISPID_SOM_IDCONSTRAINTS                        0x000005a1
+#define DISPID_SOM_ISABSTRACT                           0x000005a2
+#define DISPID_SOM_ISNILLABLE                           0x000005a3
+#define DISPID_SOM_ISREFERENCE                          0x000005a4
+#define DISPID_SOM_ISVALID                              0x000005a5
+#define DISPID_SOM_ITEMTYPE                             0x000005a6
+#define DISPID_SOM_LENGTH                               0x000005a7
+#define DISPID_SOM_MAXEXCLUSIVE                         0x000005a8
+#define DISPID_SOM_MAXINCLUSIVE                         0x000005a9
+#define DISPID_SOM_MAXLENGTH                            0x000005aa
+#define DISPID_SOM_MAXOCCURS                            0x000005ab
+#define DISPID_SOM_MINEXCLUSIVE                         0x000005ac
+#define DISPID_SOM_MININCLUSIVE                         0x000005ad
+#define DISPID_SOM_MINLENGTH                            0x000005ae
+#define DISPID_SOM_MINOCCURS                            0x000005af
+#define DISPID_SOM_MODELGROUPS                          0x000005b0
+#define DISPID_SOM_NAME                                 0x000005b1
+#define DISPID_SOM_NAMESPACES                           0x000005b2
+#define DISPID_SOM_NAMESPACEURI                         0x000005b3
+#define DISPID_SOM_NOTATIONS                            0x000005b4
+#define DISPID_SOM_PARTICLES                            0x000005b5
+#define DISPID_SOM_PATTERNS                             0x000005b6
+#define DISPID_SOM_PROCESSCONTENTS                      0x000005b7
+#define DISPID_SOM_PROHIBITED                           0x000005b8
+#define DISPID_SOM_PUBLICIDENTIFIER                     0x000005b9
+#define DISPID_SOM_REFERENCEDKEY                        0x000005ba
+#define DISPID_SOM_SCHEMA                               0x000005bb
+#define DISPID_SOM_SCHEMALOCATIONS                      0x000005bc
+#define DISPID_SOM_SCOPE                                0x000005bd
+#define DISPID_SOM_SELECTOR                             0x000005be
+#define DISPID_SOM_SUBSTITUTIONGROUP                    0x000005bf
+#define DISPID_SOM_EXCLUSIONS                           0x000005c0
+#define DISPID_SOM_SYSTEMIDENTIFIER                     0x000005c1
+#define DISPID_SOM_TARGETNAMESPACE                      0x000005c2
+#define DISPID_SOM_TOTALDIGITS                          0x000005c3
+#define DISPID_SOM_TYPE                                 0x000005c4
+#define DISPID_SOM_TYPES                                0x000005c5
+#define DISPID_SOM_UNHANDLEDATTRS                       0x000005c6
+#define DISPID_SOM_USE                                  0x000005c7
+#define DISPID_SOM_VARIETY                              0x000005c8
+#define DISPID_SOM_VERSION                              0x000005c9
+#define DISPID_SOM_WHITESPACE                           0x000005ca
+#define DISPID_SOM_WRITEANNOTATION                      0x000005cb
+
 
 #endif /* __MSXML2DID_H__ */
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/npapi.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/npapi.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/npapi.h	(revision 28475)
@@ -25,4 +25,5 @@
  * of the LGPL is applied is otherwise unspecified.
  */
+
 #ifndef __WINE_NPAPI_H__
 #define __WINE_NPAPI_H__
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/ntsecapi.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/ntsecapi.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/ntsecapi.h	(revision 28475)
@@ -347,6 +347,10 @@
 
 #define RtlGenRandom                    SystemFunction036
+#define RtlEncryptMemory                SystemFunction040
+#define RtlDecryptMemory                SystemFunction041
 
 BOOLEAN WINAPI RtlGenRandom(PVOID,ULONG);
+NTSTATUS WINAPI RtlEncryptMemory(PVOID,ULONG,ULONG);
+NTSTATUS WINAPI RtlDecryptMemory(PVOID,ULONG,ULONG);
 
 NTSTATUS WINAPI LsaAddAccountRights(LSA_HANDLE,PSID,PLSA_UNICODE_STRING,ULONG);
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/ntstatus.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/ntstatus.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/ntstatus.h	(revision 28475)
@@ -915,4 +915,87 @@
 #define STATUS_VDM_DISALLOWED            ((NTSTATUS) 0xC0000414)
 #define STATUS_HUNG_DISPLAY_DRIVER_THREAD ((NTSTATUS) 0xC0000415)
+#define STATUS_INSUFFICIENT_RESOURCE_FOR_SPECIFIED_SHARED_SECTION_SIZE ((NTSTATUS) 0xC0000416)
+#define STATUS_INVALID_CRUNTIME_PARAMETER   ((NTSTATUS) 0xC0000417)
+#define STATUS_NTLM_BLOCKED                 ((NTSTATUS) 0xC0000418)
+#define STATUS_ASSERTION_FAILURE            ((NTSTATUS) 0xC0000420)
+#define STATUS_VERIFIER_STOP                ((NTSTATUS) 0xC0000421)
+#define STATUS_CALLBACK_POP_STACK           ((NTSTATUS) 0xC0000423)
+#define STATUS_INCOMPATIBLE_DRIVER_BLOCKED  ((NTSTATUS) 0xC0000424)
+#define STATUS_HIVE_UNLOADED                ((NTSTATUS) 0xC0000425)
+#define STATUS_COMPRESSION_DISABLED         ((NTSTATUS) 0xC0000426)
+#define STATUS_FILE_SYSTEM_LIMITATION       ((NTSTATUS) 0xC0000427)
+#define STATUS_INVALID_IMAGE_HASH           ((NTSTATUS) 0xC0000428)
+#define STATUS_NOT_CAPABLE                  ((NTSTATUS) 0xC0000429)
+#define STATUS_REQUEST_OUT_OF_SEQUENCE      ((NTSTATUS) 0xC000042A)
+#define STATUS_IMPLEMENTATION_LIMIT         ((NTSTATUS) 0xC000042B)
+#define STATUS_ELEVATION_REQUIRED           ((NTSTATUS) 0xC000042C)
+#define STATUS_BEYOND_VDL                   ((NTSTATUS) 0xC0000432)
+#define STATUS_ENCOUNTERED_WRITE_IN_PROGRESS ((NTSTATUS) 0xC0000433)
+#define STATUS_PTE_CHANGED                  ((NTSTATUS) 0xC0000434)
+#define STATUS_PURGE_FAILED                 ((NTSTATUS) 0xC0000435)
+#define STATUS_CRED_REQUIRES_CONFIRMATION   ((NTSTATUS) 0xC0000440)
+#define STATUS_CS_ENCRYPTION_INVALID_SERVER_RESPONSE ((NTSTATUS) 0xC0000441)
+#define STATUS_CS_ENCRYPTION_UNSUPPORTED_SERVER ((NTSTATUS) 0xC0000442)
+#define STATUS_CS_ENCRYPTION_EXISTING_ENCRYPTED_FILE ((NTSTATUS) 0xC0000443)
+#define STATUS_CS_ENCRYPTION_NEW_ENCRYPTED_FILE ((NTSTATUS) 0xC0000444)
+#define STATUS_CS_ENCRYPTION_FILE_NOT_CSE   ((NTSTATUS) 0xC0000445)
+#define STATUS_INVALID_LABEL                ((NTSTATUS) 0xC0000446)
+#define STATUS_DRIVER_PROCESS_TERMINATED    ((NTSTATUS) 0xC0000450)
+#define STATUS_AMBIGUOUS_SYSTEM_DEVICE      ((NTSTATUS) 0xC0000451)
+#define STATUS_SYSTEM_DEVICE_NOT_FOUND      ((NTSTATUS) 0xC0000452)
+#define STATUS_RESTART_BOOT_APPLICATION     ((NTSTATUS) 0xC0000453)
+#define STATUS_INVALID_TASK_NAME            ((NTSTATUS) 0xC0000500)
+#define STATUS_INVALID_TASK_INDEX           ((NTSTATUS) 0xC0000501)
+#define STATUS_THREAD_ALREADY_IN_TASK       ((NTSTATUS) 0xC0000502)
+#define STATUS_CALLBACK_BYPASS              ((NTSTATUS) 0xC0000503)
+#define STATUS_PORT_CLOSED                  ((NTSTATUS) 0xC0000700)
+#define STATUS_MESSAGE_LOST                 ((NTSTATUS) 0xC0000701)
+#define STATUS_INVALID_MESSAGE              ((NTSTATUS) 0xC0000702)
+#define STATUS_REQUEST_CANCELED             ((NTSTATUS) 0xC0000703)
+#define STATUS_RECURSIVE_DISPATCH           ((NTSTATUS) 0xC0000704)
+#define STATUS_LPC_RECEIVE_BUFFER_EXPECTED  ((NTSTATUS) 0xC0000705)
+#define STATUS_LPC_INVALID_CONNECTION_USAGE ((NTSTATUS) 0xC0000706)
+#define STATUS_LPC_REQUESTS_NOT_ALLOWED     ((NTSTATUS) 0xC0000707)
+#define STATUS_RESOURCE_IN_USE              ((NTSTATUS) 0xC0000708)
+#define STATUS_HARDWARE_MEMORY_ERROR        ((NTSTATUS) 0xC0000709)
+#define STATUS_THREADPOOL_HANDLE_EXCEPTION  ((NTSTATUS) 0xC000070A)
+#define STATUS_THREADPOOL_SET_EVENT_ON_COMPLETION_FAILED ((NTSTATUS) 0xC000070B)
+#define STATUS_THREADPOOL_RELEASE_SEMAPHORE_ON_COMPLETION_FAILED ((NTSTATUS) 0xC000070C)
+#define STATUS_THREADPOOL_RELEASE_MUTEX_ON_COMPLETION_FAILED ((NTSTATUS) 0xC000070D)
+#define STATUS_THREADPOOL_FREE_LIBRARY_ON_COMPLETION_FAILED ((NTSTATUS) 0xC000070E)
+#define STATUS_THREADPOOL_RELEASED_DURING_OPERATION ((NTSTATUS) 0xC000070F)
+#define STATUS_CALLBACK_RETURNED_WHILE_IMPERSONATING ((NTSTATUS) 0xC0000710)
+#define STATUS_APC_RETURNED_WHILE_IMPERSONATING ((NTSTATUS) 0xC0000711)
+#define STATUS_PROCESS_IS_PROTECTED         ((NTSTATUS) 0xC0000712)
+#define STATUS_MCA_EXCEPTION                ((NTSTATUS) 0xC0000713)
+#define STATUS_CERTIFICATE_MAPPING_NOT_UNIQUE ((NTSTATUS) 0xC0000714)
+#define STATUS_SYMLINK_CLASS_DISABLED       ((NTSTATUS) 0xC0000715)
+#define STATUS_INVALID_IDN_NORMALIZATION    ((NTSTATUS) 0xC0000716)
+#define STATUS_NO_UNICODE_TRANSLATION       ((NTSTATUS) 0xC0000717)
+#define STATUS_ALREADY_REGISTERED           ((NTSTATUS) 0xC0000718)
+#define STATUS_CONTEXT_MISMATCH             ((NTSTATUS) 0xC0000719)
+#define STATUS_PORT_ALREADY_HAS_COMPLETION_LIST ((NTSTATUS) 0xC000071A)
+#define STATUS_CALLBACK_RETURNED_THREAD_PRIORITY ((NTSTATUS) 0xC000071B)
+#define STATUS_INVALID_THREAD               ((NTSTATUS) 0xC000071C)
+#define STATUS_CALLBACK_RETURNED_TRANSACTION ((NTSTATUS) 0xC000071D)
+#define STATUS_CALLBACK_RETURNED_LDR_LOCK   ((NTSTATUS) 0xC000071E)
+#define STATUS_CALLBACK_RETURNED_LANG       ((NTSTATUS) 0xC000071F)
+#define STATUS_CALLBACK_RETURNED_PRI_BACK   ((NTSTATUS) 0xC0000720)
+#define STATUS_CALLBACK_RETURNED_THREAD_AFFINITY ((NTSTATUS) 0xC0000721)
+#define STATUS_DISK_REPAIR_DISABLED         ((NTSTATUS) 0xC0000800)
+#define STATUS_DS_DOMAIN_RENAME_IN_PROGRESS ((NTSTATUS) 0xC0000801)
+#define STATUS_DISK_QUOTA_EXCEEDED          ((NTSTATUS) 0xC0000802)
+#define STATUS_CONTENT_BLOCKED              ((NTSTATUS) 0xC0000804)
+#define STATUS_BAD_CLUSTERS                 ((NTSTATUS) 0xC0000805)
+#define STATUS_VOLUME_DIRTY                 ((NTSTATUS) 0xC0000806)
+#define STATUS_FILE_CHECKED_OUT             ((NTSTATUS) 0xC0000901)
+#define STATUS_CHECKOUT_REQUIRED            ((NTSTATUS) 0xC0000902)
+#define STATUS_BAD_FILE_TYPE                ((NTSTATUS) 0xC0000903)
+#define STATUS_FILE_TOO_LARGE               ((NTSTATUS) 0xC0000904)
+#define STATUS_FORMS_AUTH_REQUIRED          ((NTSTATUS) 0xC0000905)
+#define STATUS_VIRUS_INFECTED               ((NTSTATUS) 0xC0000906)
+#define STATUS_VIRUS_DELETED                ((NTSTATUS) 0xC0000907)
+#define STATUS_BAD_MCFG_TABLE               ((NTSTATUS) 0xC0000908)
+
 #define STATUS_WOW_ASSERTION             ((NTSTATUS) 0xC0009898)
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/oaidl.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/oaidl.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/oaidl.h	(revision 28475)
@@ -1,3 +1,3 @@
-/*** Autogenerated by WIDL 1.1.36 from ../../include/oaidl.idl - Do not edit ***/
+/*** Autogenerated by WIDL 1.1.43 from ../../include/oaidl.idl - Do not edit ***/
 
 #include <rpc.h>
@@ -446,5 +446,5 @@
 
 typedef struct tagIDLDESC {
-    ULONG dwReserved;
+    ULONG_PTR dwReserved;
     USHORT wIDLFlags;
 } IDLDESC;
@@ -509,6 +509,6 @@
     BSTR bstrHelpFile;
     DWORD dwHelpContext;
-    ULONG pvReserved;
-    ULONG pfnDeferredFillIn;
+    ULONG_PTR pvReserved;
+    ULONG_PTR pfnDeferredFillIn;
     SCODE scode;
 } EXCEPINFO;
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/oaidl.idl
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/oaidl.idl	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/oaidl.idl	(revision 28475)
@@ -353,5 +353,5 @@
 
 typedef struct tagIDLDESC {
-  ULONG dwReserved;
+  ULONG_PTR dwReserved;
   USHORT wIDLFlags;
 } IDLDESC, *LPIDLDESC;
@@ -414,6 +414,6 @@
   BSTR bstrHelpFile;
   DWORD dwHelpContext;
-  ULONG pvReserved;
-  ULONG pfnDeferredFillIn;
+  ULONG_PTR pvReserved;
+  ULONG_PTR pfnDeferredFillIn;
   SCODE scode;
 } EXCEPINFO;
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/objbase.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/objbase.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/objbase.h	(revision 28475)
@@ -441,5 +441,5 @@
  */
 HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR*);
-HRESULT WINAPI CLSIDFromString(LPOLESTR, CLSID *);
+HRESULT WINAPI CLSIDFromString(LPCOLESTR, LPCLSID);
 HRESULT WINAPI CLSIDFromProgID(LPCOLESTR progid, LPCLSID riid);
 HRESULT WINAPI ProgIDFromCLSID(REFCLSID clsid, LPOLESTR *lplpszProgID);
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/objidl.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/objidl.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/objidl.h	(revision 28475)
@@ -1,3 +1,3 @@
-/*** Autogenerated by WIDL 1.1.36 from ../../include/objidl.idl - Do not edit ***/
+/*** Autogenerated by WIDL 1.1.43 from ../../include/objidl.idl - Do not edit ***/
 
 #include <rpc.h>
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/objsel.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/objsel.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/objsel.h	(revision 28475)
@@ -15,4 +15,14 @@
  *
  */
+
+/*
+ * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
+ * other than GPL or LGPL is available it will apply instead, Sun elects to use only
+ * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
+ * a choice of LGPL license versions is made available with the language indicating
+ * that LGPLv2 or any later version may be used, or where a choice of which version
+ * of the LGPL is applied is otherwise unspecified.
+ */
+
 #ifndef __OBJSEL_H_
 #define __OBJSEL_H_
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/oledb.idl
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/oledb.idl	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/oledb.idl	(revision 28475)
@@ -16,5 +16,5 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
-cpp_quote("#ifdef _WIN64")
+
 /*
  * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
@@ -26,4 +26,5 @@
  */
 
+cpp_quote("#ifdef _WIN64")
 cpp_quote("#include <pshpack8.h>")
 cpp_quote("#else")
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/oleidl.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/oleidl.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/oleidl.h	(revision 28475)
@@ -1,3 +1,3 @@
-/*** Autogenerated by WIDL 1.1.36 from ../../include/oleidl.idl - Do not edit ***/
+/*** Autogenerated by WIDL 1.1.43 from ../../include/oleidl.idl - Do not edit ***/
 
 #include <rpc.h>
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/pdh.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/pdh.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/pdh.h	(revision 28475)
@@ -47,4 +47,8 @@
 typedef HANDLE PDH_HLOG;
 
+#define PDH_CVERSION_WIN40  0x0400
+#define PDH_CVERSION_WIN50  0x0500
+#define PDH_VERSION         0x0503
+
 #define PDH_MAX_SCALE 7
 #define PDH_MIN_SCALE (-7)
@@ -58,4 +62,8 @@
 #define PDH_FMT_1000        0x00002000
 #define PDH_FMT_NOCAP100    0x00008000
+
+#define DATA_SOURCE_REGISTRY    0x00000001
+#define DATA_SOURCE_LOGFILE     0x00000002
+#define DATA_SOURCE_WBEM        0x00000004
 
 typedef struct _PDH_FMT_COUNTERVALUE
@@ -192,4 +200,5 @@
 #define    PdhGetCounterInfo WINELIB_NAME_AW(PdhGetCounterInfo)
 PDH_STATUS WINAPI PdhGetCounterTimeBase(PDH_HCOUNTER, LONGLONG *);
+PDH_STATUS WINAPI PdhGetDllVersion(LPDWORD);
 PDH_STATUS WINAPI PdhGetFormattedCounterValue(PDH_HCOUNTER, DWORD, LPDWORD, PPDH_FMT_COUNTERVALUE);
 PDH_STATUS WINAPI PdhGetRawCounterValue(PDH_HCOUNTER, LPDWORD, PPDH_RAW_COUNTER);
@@ -208,4 +217,5 @@
 PDH_STATUS WINAPI PdhRemoveCounter(PDH_HCOUNTER);
 PDH_STATUS WINAPI PdhSetCounterScaleFactor(PDH_HCOUNTER, LONG);
+PDH_STATUS WINAPI PdhSetDefaultRealTimeDataSource(DWORD);
 PDH_STATUS WINAPI PdhValidatePathA(LPCSTR);
 PDH_STATUS WINAPI PdhValidatePathW(LPCWSTR);
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/propidl.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/propidl.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/propidl.h	(revision 28475)
@@ -1,3 +1,3 @@
-/*** Autogenerated by WIDL 1.1.36 from ../../include/propidl.idl - Do not edit ***/
+/*** Autogenerated by WIDL 1.1.43 from ../../include/propidl.idl - Do not edit ***/
 
 #include <rpc.h>
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/raserror.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/raserror.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/raserror.h	(revision 28475)
@@ -33,4 +33,5 @@
 #define ERROR_BUFFER_INVALID                   (RASBASE+10)
 #define ERROR_INVALID_SIZE                     (RASBASE+32)
+#define ERROR_STATE_MACHINES_NOT_STARTED       (RASBASE+95)
 #define ERROR_RASMAN_CANNOT_INITIALIZE         (RASBASE+111)
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/rpcasync.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/rpcasync.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/rpcasync.h	(revision 28475)
@@ -25,4 +25,5 @@
  * of the LGPL is applied is otherwise unspecified.
  */
+
 #ifndef __WINE_RPCASYNC_H
 #define __WINE_RPCASYNC_H
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/schannel.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/schannel.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/schannel.h	(revision 28475)
@@ -25,4 +25,5 @@
  * of the LGPL is applied is otherwise unspecified.
  */
+
 #ifndef __WINE_SCHANNEL_H__
 #define __WINE_SCHANNEL_H__
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/schnlsp.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/schnlsp.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/schnlsp.h	(revision 28475)
@@ -25,4 +25,5 @@
  * of the LGPL is applied is otherwise unspecified.
  */
+
 #ifndef __WINE_SHNLSP_H__
 #define __WINE_SHNLSP_H__
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/sddl.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/sddl.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/sddl.h	(revision 28475)
@@ -25,4 +25,5 @@
  * of the LGPL is applied is otherwise unspecified.
  */
+
 #ifndef __SDDL_H__
 #define __SDDL_H__
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/servprov.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/servprov.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/servprov.h	(revision 28475)
@@ -1,3 +1,3 @@
-/*** Autogenerated by WIDL 1.1.36 from ../../include/servprov.idl - Do not edit ***/
+/*** Autogenerated by WIDL 1.1.43 from ../../include/servprov.idl - Do not edit ***/
 
 #include <rpc.h>
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/shlobj.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/shlobj.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/shlobj.h	(revision 28475)
@@ -33,4 +33,8 @@
 #include <prsht.h>
 #include <shlguid.h>
+
+#ifdef WINE_NO_UNICODE_MACROS
+#undef GetObject
+#endif
 
 #ifdef __cplusplus
@@ -549,4 +553,93 @@
 #endif
 
+/****************************************************************************
+ * IShellFolderView interface
+ */
+
+typedef struct _ITEMSPACING
+{
+    int cxSmall;
+    int cySmall;
+    int cxLarge;
+    int cyLarge;
+} ITEMSPACING;
+
+#define INTERFACE IShellFolderView
+DEFINE_GUID(IID_IShellFolderView,0x37a378c0,0xf82d,0x11ce,0xae,0x65,0x08,0x00,0x2b,0x2e,0x12,0x62);
+DECLARE_INTERFACE_(IShellFolderView, IUnknown)
+{
+    /*** IUnknown methods ***/
+    STDMETHOD_(HRESULT,QueryInterface) (THIS_ REFIID riid, void **ppv) PURE;
+    STDMETHOD_(ULONG,AddRef) (THIS)  PURE;
+    STDMETHOD_(ULONG,Release) (THIS) PURE;
+
+    /*** IShellFolderView methods ***/
+    STDMETHOD(Rearrange) (THIS_ LPARAM lParamSort) PURE;
+    STDMETHOD(GetArrangeParam) (THIS_ LPARAM *plParamSort) PURE;
+    STDMETHOD(ArrangeGrid) (THIS) PURE;
+    STDMETHOD(AutoArrange) (THIS) PURE;
+    STDMETHOD(GetAutoArrange) (THIS) PURE;
+    STDMETHOD(AddObject) (THIS_ PITEMID_CHILD pidl, UINT *puItem) PURE;
+    STDMETHOD(GetObject) (THIS_ PITEMID_CHILD *ppidl, UINT uItem) PURE;
+    STDMETHOD(RemoveObject) (THIS_ PITEMID_CHILD pidl, UINT *puItem) PURE;
+    STDMETHOD(GetObjectCount) (THIS_ UINT *puCount) PURE;
+    STDMETHOD(SetObjectCount) (THIS_ UINT uCount, UINT dwFlags) PURE;
+    STDMETHOD(UpdateObject) (THIS_ PITEMID_CHILD pidlOld, PITEMID_CHILD pidlNew, UINT *puItem) PURE;
+    STDMETHOD(RefreshObject) (THIS_ PITEMID_CHILD pidl, UINT *puItem) PURE;
+    STDMETHOD(SetRedraw) (THIS_ BOOL bRedraw) PURE;
+    STDMETHOD(GetSelectedCount) (THIS_ UINT *puSelected) PURE;
+    STDMETHOD(GetSelectedObjects) (THIS_ PCITEMID_CHILD **pppidl, UINT *puItems) PURE;
+    STDMETHOD(IsDropOnSource) (THIS_ IDropTarget *pDropTarget) PURE;
+    STDMETHOD(GetDragPoint) (THIS_ POINT *ppt) PURE;
+    STDMETHOD(GetDropPoint) (THIS_ POINT *ppt) PURE;
+    STDMETHOD(MoveIcons) (THIS_ IDataObject *pDataObject) PURE;
+    STDMETHOD(SetItemPos) (THIS_ PCUITEMID_CHILD pidl, POINT *ppt) PURE;
+    STDMETHOD(IsBkDropTarget) (THIS_ IDropTarget *pDropTarget) PURE;
+    STDMETHOD(SetClipboard) (THIS_ BOOL bMove) PURE;
+    STDMETHOD(SetPoints) (THIS_ IDataObject *pDataObject) PURE;
+    STDMETHOD(GetItemSpacing) (THIS_ ITEMSPACING *pSpacing) PURE;
+    STDMETHOD(SetCallback) (THIS_ IShellFolderViewCB* pNewCB, IShellFolderViewCB** ppOldCB) PURE;
+    STDMETHOD(Select) ( THIS_  UINT dwFlags ) PURE;
+    STDMETHOD(QuerySupport) (THIS_ UINT * pdwSupport ) PURE;
+    STDMETHOD(SetAutomationObject)(THIS_ IDispatch* pdisp) PURE;
+};
+#undef INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IShellFolderView_QueryInterface(p,a,b)      (p)->lpVtbl->QueryInterface(p,a,b)
+#define IShellFolderView_AddRef(p)                  (p)->lpVtbl->AddRef(p)
+#define IShellFolderView_Release(p)                 (p)->lpVtbl->Release(p)
+/*** IShellFolderView methods ***/
+#define IShellFolderView_Rearrange(p,a)             (p)->lpVtbl->Rearrange(p,a)
+#define IShellFolderView_GetArrangeParam(p,a)       (p)->lpVtbl->GetArrangeParam(p,a)
+#define IShellFolderView_ArrangeGrid(p)             (p)->lpVtbl->ArrangeGrid(p)
+#define IShellFolderView_AutoArrange(p)             (p)->lpVtbl->AutoArrange(p)
+#define IShellFolderView_GetAutoArrange(p)          (p)->lpVtbl->GetAutoArrange(p)
+#define IShellFolderView_AddObject(p,a,b)           (p)->lpVtbl->AddObject(p,a,b)
+#define IShellFolderView_GetObject(p,a,b)           (p)->lpVtbl->GetObject(p,a,b)
+#define IShellFolderView_RemoveObject(p,a,b)        (p)->lpVtbl->RemoveObject(p,a,b)
+#define IShellFolderView_GetObjectCount(p,a)        (p)->lpVtbl->GetObjectCount(p,a)
+#define IShellFolderView_SetObjectCount(p,a,b)      (p)->lpVtbl->SetObjectCount(p,a,b)
+#define IShellFolderView_UpdateObject(p,a,b,c)      (p)->lpVtbl->UpdateObject(p,a,b,c)
+#define IShellFolderView_RefreshObject(p,a,b)       (p)->lpVtbl->RefreshObject(p,a,b)
+#define IShellFolderView_SetRedraw(p,a)             (p)->lpVtbl->SetRedraw(p,a)
+#define IShellFolderView_GetSelectedCount(p,a)      (p)->lpVtbl->GetSelectedCount(p,a)
+#define IShellFolderView_GetSelectedObjects(p,a,b)  (p)->lpVtbl->GetSelectedObjects(p,a,b)
+#define IShellFolderView_IsDropOnSource(p,a)        (p)->lpVtbl->IsDropOnSource(p,a)
+#define IShellFolderView_GetDragPoint(p,a)          (p)->lpVtbl->GetDragPoint(p,a)
+#define IShellFolderView_GetDropPoint(p,a)          (p)->lpVtbl->GetDropPoint(p,a)
+#define IShellFolderView_MoveIcons(p,a)             (p)->lpVtbl->MoveIcons(p,a)
+#define IShellFolderView_SetItemPos(p,a,b)          (p)->lpVtbl->SetItemPos(p,a,b)
+#define IShellFolderView_DropTarget(p,a)            (p)->lpVtbl->DropTarget(p,a)
+#define IShellFolderView_SetClipboard(p,a)          (p)->lpVtbl->SetClipboard(p,a)
+#define IShellFolderView_SetPoints(p,a)             (p)->lpVtbl->SetPoints(p,a)
+#define IShellFolderView_GetItemSpacing(p,a)        (p)->lpVtbl->GetItemSpacing(p,a)
+#define IShellFolderView_SetCallback(p,a)           (p)->lpVtbl->SetCallback(p,a)
+#define IShellFolderView_Select(p,a)                (p)->lpVtbl->Select(p,a)
+#define IShellFolderView_QuerySupport(p,a)          (p)->lpVtbl->QuerySupport(p,a)
+#define IShellFolderView_SetAutomationObject(p,a)   (p)->lpVtbl->SetAutomationObject(p,a)
+#endif
+
 /* IProgressDialog interface */
 #define PROGDLG_NORMAL           0x00000000
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/shlwapi.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/shlwapi.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/shlwapi.h	(revision 28475)
@@ -94,4 +94,32 @@
 
 HKEY WINAPI  SHRegDuplicateHKey(HKEY);
+
+/* SHRegGetValue flags */
+typedef INT SRRF;
+
+#define SRRF_RT_REG_NONE 0x1
+#define SRRF_RT_REG_SZ 0x2
+#define SRRF_RT_REG_EXPAND_SZ 0x4
+#define SRRF_RT_REG_BINARY 0x8
+#define SRRF_RT_REG_DWORD 0x10
+#define SRRF_RT_REG_MULTI_SZ 0x20
+#define SRRF_RT_REG_QWORD 0x40
+
+#define SRRF_RT_DWORD (SRRF_RT_REG_BINARY|SRRF_RT_REG_DWORD)
+#define SRRF_RT_QWORD (SRRF_RT_REG_BINARY|SRRF_RT_REG_QWORD)
+#define SRRF_RT_ANY 0xffff
+
+#define SRRF_RM_ANY 0
+#define SRRF_RM_NORMAL 0x10000
+#define SRRF_RM_SAFE 0x20000
+#define SRRF_RM_SAFENETWORK 0x40000
+
+#define SRRF_NOEXPAND 0x10000000
+#define SRRF_ZEROONFAILURE 0x20000000
+#define SRRF_NOVIRT 0x40000000
+
+LSTATUS WINAPI SHRegGetValueA(HKEY,LPCSTR,LPCSTR,SRRF,LPDWORD,LPVOID,LPDWORD);
+LSTATUS WINAPI SHRegGetValueW(HKEY,LPCWSTR,LPCWSTR,SRRF,LPDWORD,LPVOID,LPDWORD);
+#define SHRegGetValue WINELIB_NAME_AW(SHRegGetValue)
 
 /* Undocumented registry functions */
@@ -1056,4 +1084,24 @@
 #define TPS_LONGEXECTIME 0x00000008
 
+/* SHFormatDateTimeA/SHFormatDateTimeW flags */
+#define FDTF_SHORTTIME          0x00000001
+#define FDTF_SHORTDATE          0x00000002
+#define FDTF_DEFAULT            (FDTF_SHORTDATE | FDTF_SHORTTIME)
+#define FDTF_LONGDATE           0x00000004
+#define FDTF_LONGTIME           0x00000008
+#define FDTF_RELATIVE           0x00000010
+#define FDTF_LTRDATE            0x00000100
+#define FDTF_RTLDATE            0x00000200
+#define FDTF_NOAUTOREADINGORDER 0x00000400
+
+
+typedef struct
+{
+    const IID *piid;
+    int        dwOffset;
+} QITAB, *LPQITAB;
+
+HRESULT WINAPI QISearch(void* base, const QITAB *pqit, REFIID riid, void **ppv);
+
 #include <poppack.h> 
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/shobjidl.idl
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/shobjidl.idl	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/shobjidl.idl	(revision 28475)
@@ -545,4 +545,50 @@
 }
 
+/*****************************************************************************
+ * IFolderView interface
+ */
+[
+    uuid(cde725b0-ccc9-4519-917e-325d72fab4ce),
+    object,
+    pointer_default(unique)
+]
+interface IFolderView : IUnknown
+{
+    HRESULT GetCurrentViewMode( [out] UINT *mode );
+    HRESULT SetCurrentViewMode( [in] UINT mode );
+    HRESULT GetFolder( [in] REFIID riid, [out, iid_is(riid)] void **ppv );
+    HRESULT Item(
+        [in] int index,
+        [out] PITEMID_CHILD *ppidl
+    );
+    HRESULT ItemCount(
+        [in] UINT flags,
+        [out] int *items
+    );
+    HRESULT Items(
+        [in] UINT flags,
+        [in] REFIID riid,
+        [out, iid_is(riid)] void **ppv
+    );
+    HRESULT GetSelectionMarkedItem( [out] int *item );
+    HRESULT GetFocusedItem( [out] int *item );
+    HRESULT GetItemPosition(
+        [in] PCUITEMID_CHILD pidl,
+        [out] POINT* ppt
+    );
+    HRESULT GetSpacing( [in, out, unique] POINT* pt );
+    HRESULT GetDefaultSpacing( [out] POINT* pt );
+    HRESULT GetAutoArrange();
+    HRESULT SelectItem(
+        [in] int item,
+        [in] DWORD flags
+    );
+    HRESULT SelectAndPositionItems(
+        [in] UINT cidl,
+        [in, size_is(cidl)] PCUITEMID_CHILD_ARRAY apidl,
+        [in, unique, size_is(cidl)] POINT* apt,
+        [in] DWORD flags
+    );
+}
 
 /*****************************************************************************
@@ -1493,2 +1539,17 @@
     HRESULT ResetEnumerator();
 }
+
+[
+    object,
+    uuid(cb728b20-f786-11ce-92ad-00aa00a74cd0),
+    pointer_default(unique)
+]
+interface IProfferService : IUnknown
+{
+    HRESULT ProfferService(
+        [in] REFGUID service,
+        [in] IServiceProvider *pService,
+        [out] DWORD *pCookie);
+
+    HRESULT RevokeService([in] DWORD cookie);
+}
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/shtypes.idl
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/shtypes.idl	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/shtypes.idl	(revision 28475)
@@ -44,4 +44,8 @@
 } ITEMIDLIST,*LPITEMIDLIST;
 typedef const ITEMIDLIST *LPCITEMIDLIST;
+typedef LPITEMIDLIST PITEMID_CHILD;
+typedef const PITEMID_CHILD PCITEMID_CHILD;
+typedef LPCITEMIDLIST PCUITEMID_CHILD;
+typedef LPCITEMIDLIST *PCUITEMID_CHILD_ARRAY;
 cpp_quote("#include <poppack.h>")
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/slerror.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/slerror.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/slerror.h	(revision 28475)
@@ -26,4 +26,5 @@
  * of the LGPL is applied is otherwise unspecified.
  */
+
 #ifndef __WINE_SLERROR_H
 #define __WINE_SLERROR_H
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/slpublic.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/slpublic.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/slpublic.h	(revision 28475)
@@ -26,4 +26,5 @@
  * of the LGPL is applied is otherwise unspecified.
  */
+
 #ifndef __WINE_SLPUBLIC_H
 #define __WINE_SLPUBLIC_H
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/snmp.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/snmp.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/snmp.h	(revision 28475)
@@ -25,4 +25,5 @@
  * of the LGPL is applied is otherwise unspecified.
  */
+
 #ifndef _WINE_SNMP_H
 #define _WINE_SNMP_H
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/sspi.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/sspi.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/sspi.h	(revision 28475)
@@ -141,4 +141,6 @@
 #define SECPKG_FLAG_DELEGATION             0x00020000
 #define SECPKG_FLAG_READONLY_WITH_CHECKSUM 0x00040000
+
+#define SECPKG_ID_NONE  0xffff
 
 typedef struct _SecBuffer
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/t2embapi.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/t2embapi.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/t2embapi.h	(revision 28475)
@@ -49,4 +49,12 @@
                                LPVOID,LPWSTR,LPSTR,TTLOADINFO*);
 
+/* embedding privileges */
+#define EMBED_PREVIEWPRINT  1
+#define EMBED_EDITABLE      2
+#define EMBED_INSTALLABLE   3
+#define EMBED_NOEMBEDDING   4
+
+LONG WINAPI TTGetEmbeddingType(HDC, ULONG*);
+
 #ifdef __cplusplus
 }
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/twain.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/twain.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/twain.h	(revision 28475)
@@ -49,4 +49,13 @@
     version 1.8  January 1999    Removed undocumented duplicate AUTO<cap> JMH
 \* ======================================================================== */
+
+/*
+ * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
+ * other than GPL or LGPL is available it will apply instead, Sun elects to use only
+ * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
+ * a choice of LGPL license versions is made available with the language indicating
+ * that LGPLv2 or any later version may be used, or where a choice of which version
+ * of the LGPL is applied is otherwise unspecified.
+ */
 
 #ifndef TWAIN
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/unknwn.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/unknwn.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/unknwn.h	(revision 28475)
@@ -1,3 +1,3 @@
-/*** Autogenerated by WIDL 1.1.36 from ../../include/unknwn.idl - Do not edit ***/
+/*** Autogenerated by WIDL 1.1.43 from ../../include/unknwn.idl - Do not edit ***/
 
 #include <rpc.h>
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/urlmon.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/urlmon.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/urlmon.h	(revision 28475)
@@ -1,12 +1,3 @@
-/*** Autogenerated by WIDL 1.1.36 from ../../include/urlmon.idl - Do not edit ***/
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
- */
+/*** Autogenerated by WIDL 1.1.43 from ../../include/urlmon.idl - Do not edit ***/
 
 #include <rpc.h>
@@ -184,4 +175,9 @@
 #endif
 
+#ifndef __IUriBuilder_FWD_DEFINED__
+#define __IUriBuilder_FWD_DEFINED__
+typedef interface IUriBuilder IUriBuilder;
+#endif
+
 #ifndef __IInternetProtocolEx_FWD_DEFINED__
 #define __IInternetProtocolEx_FWD_DEFINED__
@@ -192,4 +188,5 @@
 #ifdef WINE_NO_UNICODE_MACROS
 #undef GetUserName
+#undef SetPort
 #endif
 #ifndef __IInternetProtocolSink_FWD_DEFINED__
@@ -5134,4 +5131,54 @@
 #endif  /* __IUri_INTERFACE_DEFINED__ */
 
+HRESULT WINAPI CreateUri(LPCWSTR,DWORD,DWORD_PTR,IUri**);
+HRESULT WINAPI CreateUriWithFragment(LPCWSTR,LPCWSTR,DWORD,DWORD_PTR,IUri**);
+HRESULT WINAPI CreateUriFromMultiByteString(LPCSTR,DWORD,DWORD,DWORD,DWORD_PTR,IUri**);
+#define Uri_HAS_ABSOLUTE_URI    (1 << Uri_PROPERTY_ABSOLUTE_URI)
+#define Uri_HAS_AUTHORITY       (1 << Uri_PROPERTY_AUTHORITY)
+#define Uri_HAS_DISPLAY_URI     (1 << Uri_PROPERTY_DISPLAY_URI)
+#define Uri_HAS_DOMAIN          (1 << Uri_PROPERTY_DOMAIN)
+#define Uri_HAS_EXTENSION       (1 << Uri_PROPERTY_EXTENSION)
+#define Uri_HAS_FRAGMENT        (1 << Uri_PROPERTY_FRAGMENT)
+#define Uri_HAS_HOST            (1 << Uri_PROPERTY_HOST)
+#define Uri_HAS_PASSWORD        (1 << Uri_PROPERTY_PASSWORD)
+#define Uri_HAS_PATH            (1 << Uri_PROPERTY_PATH)
+#define Uri_HAS_QUERY           (1 << Uri_PROPERTY_QUERY)
+#define Uri_HAS_RAW_URI         (1 << Uri_PROPERTY_RAW_URI)
+#define Uri_HAS_SCHEME_NAME     (1 << Uri_PROPERTY_SCHEME_NAME)
+#define Uri_HAS_USER_NAME       (1 << Uri_PROPERTY_USER_NAME)
+#define Uri_HAS_PATH_AND_QUERY  (1 << Uri_PROPERTY_PATH_AND_QUERY)
+#define Uri_HAS_USER_INFO       (1 << Uri_PROPERTY_USER_INFO)
+#define Uri_HAS_HOST_TYPE       (1 << Uri_PROPERTY_HOST_TYPE)
+#define Uri_HAS_PORT            (1 << Uri_PROPERTY_PORT)
+#define Uri_HAS_SCHEME          (1 << Uri_PROPERTY_SCHEME)
+#define Uri_HAS_ZONE            (1 << Uri_PROPERTY_ZONE)
+#define Uri_CREATE_ALLOW_RELATIVE                  0x0001
+#define Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME  0x0002
+#define Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME      0x0004
+#define Uri_CREATE_NOFRAG                          0x0008
+#define Uri_CREATE_NO_CANONICALIZE                 0x0010
+#define Uri_CREATE_CANONICALIZE                    0x0100
+#define Uri_CREATE_FILE_USE_DOS_PATH               0x0020
+#define Uri_CREATE_DECODE_EXTRA_INFO               0x0040
+#define Uri_CREATE_NO_DECODE_EXTRA_INFO            0x0080
+#define Uri_CREATE_CRACK_UNKNOWN_SCHEMES           0x0200
+#define Uri_CREATE_NO_CRACK_UNKNOWN_SCHEMES        0x0400
+#define Uri_CREATE_PRE_PROCESS_HTML_URI            0x0800
+#define Uri_CREATE_NO_PRE_PROCESS_HTML_URI         0x1000
+#define Uri_CREATE_IE_SETTINGS                     0x2000
+#define Uri_CREATE_NO_IE_SETTINGS                  0x4000
+#define Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS  0x8000
+#define Uri_DISPLAY_NO_FRAGMENT  0x00000001
+#define Uri_PUNYCODE_IDN_HOST    0x00000002
+#define Uri_DISPLAY_IDN_HOST     0x00000004
+#define Uri_ENCODING_USER_INFO_AND_PATH_IS_PERCENT_ENCODED_UTF8   0x00000001
+#define Uri_ENCODING_USER_INFO_AND_PATH_IS_CP                     0x00000002
+#define Uri_ENCODING_HOST_IS_IDN                                  0x00000004
+#define Uri_ENCODING_HOST_IS_PERCENT_ENCODED_UTF8                 0x00000008
+#define Uri_ENCODING_HOST_IS_PERCENT_ENCODED_CP                   0x00000010
+#define Uri_ENCODING_QUERY_AND_FRAGMENT_IS_PERCENT_ENCODED_UTF8   0x00000020
+#define Uri_ENCODING_QUERY_AND_FRAGMENT_IS_CP                     0x00000040
+#define Uri_ENCODING_RFC (Uri_ENCODING_USER_INFO_AND_PATH_IS_PERCENT_ENCODED_UTF8|Uri_ENCODING_HOST_IS_PERCENT_ENCODED_UTF8|Uri_ENCODING_QUERY_AND_FRAGMENT_IS_PERCENT_ENCODED_UTF8)
+#define UriBuilder_USE_ORIGINAL_FLAGS  0x00000001
 /*****************************************************************************
  * IUriContainer interface
@@ -5196,4 +5243,473 @@
 
 #endif  /* __IUriContainer_INTERFACE_DEFINED__ */
+
+/*****************************************************************************
+ * IUriBuilder interface
+ */
+#ifndef __IUriBuilder_INTERFACE_DEFINED__
+#define __IUriBuilder_INTERFACE_DEFINED__
+
+DEFINE_GUID(IID_IUriBuilder, 0x4221b2e1, 0x8955, 0x46c0, 0xbd,0x5b, 0xde,0x98,0x97,0x56,0x5d,0xe7);
+#if defined(__cplusplus) && !defined(CINTERFACE)
+interface IUriBuilder : public IUnknown
+{
+    virtual HRESULT STDMETHODCALLTYPE CreateUriSimple(
+        DWORD dwAllowEncodingPropertyMask,
+        DWORD_PTR dwReserved,
+        IUri **ppIUri) = 0;
+
+    virtual HRESULT STDMETHODCALLTYPE CreateUri(
+        DWORD dwCreateFlags,
+        DWORD dwAllowEncodingPropertyMask,
+        DWORD_PTR dwReserved,
+        IUri **ppIUri) = 0;
+
+    virtual HRESULT STDMETHODCALLTYPE CreateUriWithFlags(
+        DWORD dwCreateFlags,
+        DWORD dwUriBuilderFlags,
+        DWORD dwAllowEncodingPropertyMask,
+        DWORD_PTR dwReserved,
+        IUri **ppIUri) = 0;
+
+    virtual HRESULT STDMETHODCALLTYPE GetIUri(
+        IUri **ppIUri) = 0;
+
+    virtual HRESULT STDMETHODCALLTYPE SetIUri(
+        IUri *pIUri) = 0;
+
+    virtual HRESULT STDMETHODCALLTYPE GetFragment(
+        DWORD *pcchFragment,
+        LPCWSTR *ppwzFragment) = 0;
+
+    virtual HRESULT STDMETHODCALLTYPE GetHost(
+        DWORD *pcchHost,
+        LPCWSTR *ppwzHost) = 0;
+
+    virtual HRESULT STDMETHODCALLTYPE GetPassword(
+        DWORD *pcchPassword,
+        LPCWSTR *ppwzPassword) = 0;
+
+    virtual HRESULT STDMETHODCALLTYPE GetPath(
+        DWORD *pcchPath,
+        LPCWSTR *ppwzPath) = 0;
+
+    virtual HRESULT STDMETHODCALLTYPE GetPort(
+        BOOL *pfHasPort,
+        DWORD *pdwPort) = 0;
+
+    virtual HRESULT STDMETHODCALLTYPE GetQuery(
+        DWORD *pcchQuery,
+        LPCWSTR *ppwzQuery) = 0;
+
+    virtual HRESULT STDMETHODCALLTYPE GetSchemeName(
+        DWORD *pcchSchemeName,
+        LPCWSTR *ppwzSchemeName) = 0;
+
+    virtual HRESULT STDMETHODCALLTYPE GetUserName(
+        DWORD *pcchUserName,
+        LPCWSTR *ppwzUserName) = 0;
+
+    virtual HRESULT STDMETHODCALLTYPE SetFragment(
+        LPCWSTR pwzNewValue) = 0;
+
+    virtual HRESULT STDMETHODCALLTYPE SetHost(
+        LPCWSTR pwzNewValue) = 0;
+
+    virtual HRESULT STDMETHODCALLTYPE SetPassword(
+        LPCWSTR pwzNewValue) = 0;
+
+    virtual HRESULT STDMETHODCALLTYPE SetPath(
+        LPCWSTR pwzNewValue) = 0;
+
+    virtual HRESULT STDMETHODCALLTYPE SetPort(
+        BOOL fHasPort,
+        DWORD dwNewValue) = 0;
+
+    virtual HRESULT STDMETHODCALLTYPE SetQuery(
+        LPCWSTR pwzNewValue) = 0;
+
+    virtual HRESULT STDMETHODCALLTYPE SetSchemeName(
+        LPCWSTR pwzNewValue) = 0;
+
+    virtual HRESULT STDMETHODCALLTYPE SetUserName(
+        LPCWSTR pwzNewValue) = 0;
+
+    virtual HRESULT STDMETHODCALLTYPE RemoveProperties(
+        DWORD dwPropertyMask) = 0;
+
+    virtual HRESULT STDMETHODCALLTYPE HasBeenModified(
+        BOOL *pfModified) = 0;
+
+};
+#else
+typedef struct IUriBuilderVtbl {
+    BEGIN_INTERFACE
+
+    /*** IUnknown methods ***/
+    HRESULT (STDMETHODCALLTYPE *QueryInterface)(
+        IUriBuilder* This,
+        REFIID riid,
+        void **ppvObject);
+
+    ULONG (STDMETHODCALLTYPE *AddRef)(
+        IUriBuilder* This);
+
+    ULONG (STDMETHODCALLTYPE *Release)(
+        IUriBuilder* This);
+
+    /*** IUriBuilder methods ***/
+    HRESULT (STDMETHODCALLTYPE *CreateUriSimple)(
+        IUriBuilder* This,
+        DWORD dwAllowEncodingPropertyMask,
+        DWORD_PTR dwReserved,
+        IUri **ppIUri);
+
+    HRESULT (STDMETHODCALLTYPE *CreateUri)(
+        IUriBuilder* This,
+        DWORD dwCreateFlags,
+        DWORD dwAllowEncodingPropertyMask,
+        DWORD_PTR dwReserved,
+        IUri **ppIUri);
+
+    HRESULT (STDMETHODCALLTYPE *CreateUriWithFlags)(
+        IUriBuilder* This,
+        DWORD dwCreateFlags,
+        DWORD dwUriBuilderFlags,
+        DWORD dwAllowEncodingPropertyMask,
+        DWORD_PTR dwReserved,
+        IUri **ppIUri);
+
+    HRESULT (STDMETHODCALLTYPE *GetIUri)(
+        IUriBuilder* This,
+        IUri **ppIUri);
+
+    HRESULT (STDMETHODCALLTYPE *SetIUri)(
+        IUriBuilder* This,
+        IUri *pIUri);
+
+    HRESULT (STDMETHODCALLTYPE *GetFragment)(
+        IUriBuilder* This,
+        DWORD *pcchFragment,
+        LPCWSTR *ppwzFragment);
+
+    HRESULT (STDMETHODCALLTYPE *GetHost)(
+        IUriBuilder* This,
+        DWORD *pcchHost,
+        LPCWSTR *ppwzHost);
+
+    HRESULT (STDMETHODCALLTYPE *GetPassword)(
+        IUriBuilder* This,
+        DWORD *pcchPassword,
+        LPCWSTR *ppwzPassword);
+
+    HRESULT (STDMETHODCALLTYPE *GetPath)(
+        IUriBuilder* This,
+        DWORD *pcchPath,
+        LPCWSTR *ppwzPath);
+
+    HRESULT (STDMETHODCALLTYPE *GetPort)(
+        IUriBuilder* This,
+        BOOL *pfHasPort,
+        DWORD *pdwPort);
+
+    HRESULT (STDMETHODCALLTYPE *GetQuery)(
+        IUriBuilder* This,
+        DWORD *pcchQuery,
+        LPCWSTR *ppwzQuery);
+
+    HRESULT (STDMETHODCALLTYPE *GetSchemeName)(
+        IUriBuilder* This,
+        DWORD *pcchSchemeName,
+        LPCWSTR *ppwzSchemeName);
+
+    HRESULT (STDMETHODCALLTYPE *GetUserName)(
+        IUriBuilder* This,
+        DWORD *pcchUserName,
+        LPCWSTR *ppwzUserName);
+
+    HRESULT (STDMETHODCALLTYPE *SetFragment)(
+        IUriBuilder* This,
+        LPCWSTR pwzNewValue);
+
+    HRESULT (STDMETHODCALLTYPE *SetHost)(
+        IUriBuilder* This,
+        LPCWSTR pwzNewValue);
+
+    HRESULT (STDMETHODCALLTYPE *SetPassword)(
+        IUriBuilder* This,
+        LPCWSTR pwzNewValue);
+
+    HRESULT (STDMETHODCALLTYPE *SetPath)(
+        IUriBuilder* This,
+        LPCWSTR pwzNewValue);
+
+    HRESULT (STDMETHODCALLTYPE *SetPort)(
+        IUriBuilder* This,
+        BOOL fHasPort,
+        DWORD dwNewValue);
+
+    HRESULT (STDMETHODCALLTYPE *SetQuery)(
+        IUriBuilder* This,
+        LPCWSTR pwzNewValue);
+
+    HRESULT (STDMETHODCALLTYPE *SetSchemeName)(
+        IUriBuilder* This,
+        LPCWSTR pwzNewValue);
+
+    HRESULT (STDMETHODCALLTYPE *SetUserName)(
+        IUriBuilder* This,
+        LPCWSTR pwzNewValue);
+
+    HRESULT (STDMETHODCALLTYPE *RemoveProperties)(
+        IUriBuilder* This,
+        DWORD dwPropertyMask);
+
+    HRESULT (STDMETHODCALLTYPE *HasBeenModified)(
+        IUriBuilder* This,
+        BOOL *pfModified);
+
+    END_INTERFACE
+} IUriBuilderVtbl;
+interface IUriBuilder {
+    CONST_VTBL IUriBuilderVtbl* lpVtbl;
+};
+
+#ifdef COBJMACROS
+/*** IUnknown methods ***/
+#define IUriBuilder_QueryInterface(This,riid,ppvObject) (This)->lpVtbl->QueryInterface(This,riid,ppvObject)
+#define IUriBuilder_AddRef(This) (This)->lpVtbl->AddRef(This)
+#define IUriBuilder_Release(This) (This)->lpVtbl->Release(This)
+/*** IUriBuilder methods ***/
+#define IUriBuilder_CreateUriSimple(This,dwAllowEncodingPropertyMask,dwReserved,ppIUri) (This)->lpVtbl->CreateUriSimple(This,dwAllowEncodingPropertyMask,dwReserved,ppIUri)
+#define IUriBuilder_CreateUri(This,dwCreateFlags,dwAllowEncodingPropertyMask,dwReserved,ppIUri) (This)->lpVtbl->CreateUri(This,dwCreateFlags,dwAllowEncodingPropertyMask,dwReserved,ppIUri)
+#define IUriBuilder_CreateUriWithFlags(This,dwCreateFlags,dwUriBuilderFlags,dwAllowEncodingPropertyMask,dwReserved,ppIUri) (This)->lpVtbl->CreateUriWithFlags(This,dwCreateFlags,dwUriBuilderFlags,dwAllowEncodingPropertyMask,dwReserved,ppIUri)
+#define IUriBuilder_GetIUri(This,ppIUri) (This)->lpVtbl->GetIUri(This,ppIUri)
+#define IUriBuilder_SetIUri(This,pIUri) (This)->lpVtbl->SetIUri(This,pIUri)
+#define IUriBuilder_GetFragment(This,pcchFragment,ppwzFragment) (This)->lpVtbl->GetFragment(This,pcchFragment,ppwzFragment)
+#define IUriBuilder_GetHost(This,pcchHost,ppwzHost) (This)->lpVtbl->GetHost(This,pcchHost,ppwzHost)
+#define IUriBuilder_GetPassword(This,pcchPassword,ppwzPassword) (This)->lpVtbl->GetPassword(This,pcchPassword,ppwzPassword)
+#define IUriBuilder_GetPath(This,pcchPath,ppwzPath) (This)->lpVtbl->GetPath(This,pcchPath,ppwzPath)
+#define IUriBuilder_GetPort(This,pfHasPort,pdwPort) (This)->lpVtbl->GetPort(This,pfHasPort,pdwPort)
+#define IUriBuilder_GetQuery(This,pcchQuery,ppwzQuery) (This)->lpVtbl->GetQuery(This,pcchQuery,ppwzQuery)
+#define IUriBuilder_GetSchemeName(This,pcchSchemeName,ppwzSchemeName) (This)->lpVtbl->GetSchemeName(This,pcchSchemeName,ppwzSchemeName)
+#define IUriBuilder_GetUserName(This,pcchUserName,ppwzUserName) (This)->lpVtbl->GetUserName(This,pcchUserName,ppwzUserName)
+#define IUriBuilder_SetFragment(This,pwzNewValue) (This)->lpVtbl->SetFragment(This,pwzNewValue)
+#define IUriBuilder_SetHost(This,pwzNewValue) (This)->lpVtbl->SetHost(This,pwzNewValue)
+#define IUriBuilder_SetPassword(This,pwzNewValue) (This)->lpVtbl->SetPassword(This,pwzNewValue)
+#define IUriBuilder_SetPath(This,pwzNewValue) (This)->lpVtbl->SetPath(This,pwzNewValue)
+#define IUriBuilder_SetPort(This,fHasPort,dwNewValue) (This)->lpVtbl->SetPort(This,fHasPort,dwNewValue)
+#define IUriBuilder_SetQuery(This,pwzNewValue) (This)->lpVtbl->SetQuery(This,pwzNewValue)
+#define IUriBuilder_SetSchemeName(This,pwzNewValue) (This)->lpVtbl->SetSchemeName(This,pwzNewValue)
+#define IUriBuilder_SetUserName(This,pwzNewValue) (This)->lpVtbl->SetUserName(This,pwzNewValue)
+#define IUriBuilder_RemoveProperties(This,dwPropertyMask) (This)->lpVtbl->RemoveProperties(This,dwPropertyMask)
+#define IUriBuilder_HasBeenModified(This,pfModified) (This)->lpVtbl->HasBeenModified(This,pfModified)
+#endif
+
+#endif
+
+HRESULT STDMETHODCALLTYPE IUriBuilder_CreateUriSimple_Proxy(
+    IUriBuilder* This,
+    DWORD dwAllowEncodingPropertyMask,
+    DWORD_PTR dwReserved,
+    IUri **ppIUri);
+void __RPC_STUB IUriBuilder_CreateUriSimple_Stub(
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
+    PRPC_MESSAGE pRpcMessage,
+    DWORD* pdwStubPhase);
+HRESULT STDMETHODCALLTYPE IUriBuilder_CreateUri_Proxy(
+    IUriBuilder* This,
+    DWORD dwCreateFlags,
+    DWORD dwAllowEncodingPropertyMask,
+    DWORD_PTR dwReserved,
+    IUri **ppIUri);
+void __RPC_STUB IUriBuilder_CreateUri_Stub(
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
+    PRPC_MESSAGE pRpcMessage,
+    DWORD* pdwStubPhase);
+HRESULT STDMETHODCALLTYPE IUriBuilder_CreateUriWithFlags_Proxy(
+    IUriBuilder* This,
+    DWORD dwCreateFlags,
+    DWORD dwUriBuilderFlags,
+    DWORD dwAllowEncodingPropertyMask,
+    DWORD_PTR dwReserved,
+    IUri **ppIUri);
+void __RPC_STUB IUriBuilder_CreateUriWithFlags_Stub(
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
+    PRPC_MESSAGE pRpcMessage,
+    DWORD* pdwStubPhase);
+HRESULT STDMETHODCALLTYPE IUriBuilder_GetIUri_Proxy(
+    IUriBuilder* This,
+    IUri **ppIUri);
+void __RPC_STUB IUriBuilder_GetIUri_Stub(
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
+    PRPC_MESSAGE pRpcMessage,
+    DWORD* pdwStubPhase);
+HRESULT STDMETHODCALLTYPE IUriBuilder_SetIUri_Proxy(
+    IUriBuilder* This,
+    IUri *pIUri);
+void __RPC_STUB IUriBuilder_SetIUri_Stub(
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
+    PRPC_MESSAGE pRpcMessage,
+    DWORD* pdwStubPhase);
+HRESULT STDMETHODCALLTYPE IUriBuilder_GetFragment_Proxy(
+    IUriBuilder* This,
+    DWORD *pcchFragment,
+    LPCWSTR *ppwzFragment);
+void __RPC_STUB IUriBuilder_GetFragment_Stub(
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
+    PRPC_MESSAGE pRpcMessage,
+    DWORD* pdwStubPhase);
+HRESULT STDMETHODCALLTYPE IUriBuilder_GetHost_Proxy(
+    IUriBuilder* This,
+    DWORD *pcchHost,
+    LPCWSTR *ppwzHost);
+void __RPC_STUB IUriBuilder_GetHost_Stub(
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
+    PRPC_MESSAGE pRpcMessage,
+    DWORD* pdwStubPhase);
+HRESULT STDMETHODCALLTYPE IUriBuilder_GetPassword_Proxy(
+    IUriBuilder* This,
+    DWORD *pcchPassword,
+    LPCWSTR *ppwzPassword);
+void __RPC_STUB IUriBuilder_GetPassword_Stub(
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
+    PRPC_MESSAGE pRpcMessage,
+    DWORD* pdwStubPhase);
+HRESULT STDMETHODCALLTYPE IUriBuilder_GetPath_Proxy(
+    IUriBuilder* This,
+    DWORD *pcchPath,
+    LPCWSTR *ppwzPath);
+void __RPC_STUB IUriBuilder_GetPath_Stub(
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
+    PRPC_MESSAGE pRpcMessage,
+    DWORD* pdwStubPhase);
+HRESULT STDMETHODCALLTYPE IUriBuilder_GetPort_Proxy(
+    IUriBuilder* This,
+    BOOL *pfHasPort,
+    DWORD *pdwPort);
+void __RPC_STUB IUriBuilder_GetPort_Stub(
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
+    PRPC_MESSAGE pRpcMessage,
+    DWORD* pdwStubPhase);
+HRESULT STDMETHODCALLTYPE IUriBuilder_GetQuery_Proxy(
+    IUriBuilder* This,
+    DWORD *pcchQuery,
+    LPCWSTR *ppwzQuery);
+void __RPC_STUB IUriBuilder_GetQuery_Stub(
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
+    PRPC_MESSAGE pRpcMessage,
+    DWORD* pdwStubPhase);
+HRESULT STDMETHODCALLTYPE IUriBuilder_GetSchemeName_Proxy(
+    IUriBuilder* This,
+    DWORD *pcchSchemeName,
+    LPCWSTR *ppwzSchemeName);
+void __RPC_STUB IUriBuilder_GetSchemeName_Stub(
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
+    PRPC_MESSAGE pRpcMessage,
+    DWORD* pdwStubPhase);
+HRESULT STDMETHODCALLTYPE IUriBuilder_GetUserName_Proxy(
+    IUriBuilder* This,
+    DWORD *pcchUserName,
+    LPCWSTR *ppwzUserName);
+void __RPC_STUB IUriBuilder_GetUserName_Stub(
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
+    PRPC_MESSAGE pRpcMessage,
+    DWORD* pdwStubPhase);
+HRESULT STDMETHODCALLTYPE IUriBuilder_SetFragment_Proxy(
+    IUriBuilder* This,
+    LPCWSTR pwzNewValue);
+void __RPC_STUB IUriBuilder_SetFragment_Stub(
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
+    PRPC_MESSAGE pRpcMessage,
+    DWORD* pdwStubPhase);
+HRESULT STDMETHODCALLTYPE IUriBuilder_SetHost_Proxy(
+    IUriBuilder* This,
+    LPCWSTR pwzNewValue);
+void __RPC_STUB IUriBuilder_SetHost_Stub(
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
+    PRPC_MESSAGE pRpcMessage,
+    DWORD* pdwStubPhase);
+HRESULT STDMETHODCALLTYPE IUriBuilder_SetPassword_Proxy(
+    IUriBuilder* This,
+    LPCWSTR pwzNewValue);
+void __RPC_STUB IUriBuilder_SetPassword_Stub(
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
+    PRPC_MESSAGE pRpcMessage,
+    DWORD* pdwStubPhase);
+HRESULT STDMETHODCALLTYPE IUriBuilder_SetPath_Proxy(
+    IUriBuilder* This,
+    LPCWSTR pwzNewValue);
+void __RPC_STUB IUriBuilder_SetPath_Stub(
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
+    PRPC_MESSAGE pRpcMessage,
+    DWORD* pdwStubPhase);
+HRESULT STDMETHODCALLTYPE IUriBuilder_SetPort_Proxy(
+    IUriBuilder* This,
+    BOOL fHasPort,
+    DWORD dwNewValue);
+void __RPC_STUB IUriBuilder_SetPort_Stub(
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
+    PRPC_MESSAGE pRpcMessage,
+    DWORD* pdwStubPhase);
+HRESULT STDMETHODCALLTYPE IUriBuilder_SetQuery_Proxy(
+    IUriBuilder* This,
+    LPCWSTR pwzNewValue);
+void __RPC_STUB IUriBuilder_SetQuery_Stub(
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
+    PRPC_MESSAGE pRpcMessage,
+    DWORD* pdwStubPhase);
+HRESULT STDMETHODCALLTYPE IUriBuilder_SetSchemeName_Proxy(
+    IUriBuilder* This,
+    LPCWSTR pwzNewValue);
+void __RPC_STUB IUriBuilder_SetSchemeName_Stub(
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
+    PRPC_MESSAGE pRpcMessage,
+    DWORD* pdwStubPhase);
+HRESULT STDMETHODCALLTYPE IUriBuilder_SetUserName_Proxy(
+    IUriBuilder* This,
+    LPCWSTR pwzNewValue);
+void __RPC_STUB IUriBuilder_SetUserName_Stub(
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
+    PRPC_MESSAGE pRpcMessage,
+    DWORD* pdwStubPhase);
+HRESULT STDMETHODCALLTYPE IUriBuilder_RemoveProperties_Proxy(
+    IUriBuilder* This,
+    DWORD dwPropertyMask);
+void __RPC_STUB IUriBuilder_RemoveProperties_Stub(
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
+    PRPC_MESSAGE pRpcMessage,
+    DWORD* pdwStubPhase);
+HRESULT STDMETHODCALLTYPE IUriBuilder_HasBeenModified_Proxy(
+    IUriBuilder* This,
+    BOOL *pfModified);
+void __RPC_STUB IUriBuilder_HasBeenModified_Stub(
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
+    PRPC_MESSAGE pRpcMessage,
+    DWORD* pdwStubPhase);
+
+#endif  /* __IUriBuilder_INTERFACE_DEFINED__ */
 
 /*****************************************************************************
@@ -5385,4 +5901,6 @@
 HRESULT WINAPI CoGetClassObjectFromURL(REFCLSID, LPCWSTR, DWORD, DWORD, LPCWSTR, LPBINDCTX, DWORD, LPVOID, REFIID, LPVOID*);
 HRESULT WINAPI CreateURLMoniker(IMoniker *pmkContext, LPCWSTR szURL, IMoniker **ppmk);
+HRESULT WINAPI CreateURLMonikerEx(IMoniker*,LPCWSTR,IMoniker**,DWORD);
+HRESULT WINAPI CreateURLMonikerEx2(IMoniker*,IUri*,IMoniker**,DWORD);
 HRESULT WINAPI RegisterBindStatusCallback(IBindCtx *pbc, IBindStatusCallback *pbsc, IBindStatusCallback **ppbsc, DWORD dwReserved);
 HRESULT WINAPI CompareSecurityIds(BYTE*,DWORD,BYTE*,DWORD,DWORD);
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/urlmon.idl
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/urlmon.idl	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/urlmon.idl	(revision 28475)
@@ -34,4 +34,5 @@
 cpp_quote("#ifdef WINE_NO_UNICODE_MACROS")
 cpp_quote("#undef GetUserName")
+cpp_quote("#undef SetPort")
 cpp_quote("#endif")
 
@@ -1656,4 +1657,60 @@
 }
 
+cpp_quote("HRESULT WINAPI CreateUri(LPCWSTR,DWORD,DWORD_PTR,IUri**);")
+cpp_quote("HRESULT WINAPI CreateUriWithFragment(LPCWSTR,LPCWSTR,DWORD,DWORD_PTR,IUri**);")
+cpp_quote("HRESULT WINAPI CreateUriFromMultiByteString(LPCSTR,DWORD,DWORD,DWORD,DWORD_PTR,IUri**);")
+
+cpp_quote("#define Uri_HAS_ABSOLUTE_URI    (1 << Uri_PROPERTY_ABSOLUTE_URI)")
+cpp_quote("#define Uri_HAS_AUTHORITY       (1 << Uri_PROPERTY_AUTHORITY)")
+cpp_quote("#define Uri_HAS_DISPLAY_URI     (1 << Uri_PROPERTY_DISPLAY_URI)")
+cpp_quote("#define Uri_HAS_DOMAIN          (1 << Uri_PROPERTY_DOMAIN)")
+cpp_quote("#define Uri_HAS_EXTENSION       (1 << Uri_PROPERTY_EXTENSION)")
+cpp_quote("#define Uri_HAS_FRAGMENT        (1 << Uri_PROPERTY_FRAGMENT)")
+cpp_quote("#define Uri_HAS_HOST            (1 << Uri_PROPERTY_HOST)")
+cpp_quote("#define Uri_HAS_PASSWORD        (1 << Uri_PROPERTY_PASSWORD)")
+cpp_quote("#define Uri_HAS_PATH            (1 << Uri_PROPERTY_PATH)")
+cpp_quote("#define Uri_HAS_QUERY           (1 << Uri_PROPERTY_QUERY)")
+cpp_quote("#define Uri_HAS_RAW_URI         (1 << Uri_PROPERTY_RAW_URI)")
+cpp_quote("#define Uri_HAS_SCHEME_NAME     (1 << Uri_PROPERTY_SCHEME_NAME)")
+cpp_quote("#define Uri_HAS_USER_NAME       (1 << Uri_PROPERTY_USER_NAME)")
+cpp_quote("#define Uri_HAS_PATH_AND_QUERY  (1 << Uri_PROPERTY_PATH_AND_QUERY)")
+cpp_quote("#define Uri_HAS_USER_INFO       (1 << Uri_PROPERTY_USER_INFO)")
+cpp_quote("#define Uri_HAS_HOST_TYPE       (1 << Uri_PROPERTY_HOST_TYPE)")
+cpp_quote("#define Uri_HAS_PORT            (1 << Uri_PROPERTY_PORT)")
+cpp_quote("#define Uri_HAS_SCHEME          (1 << Uri_PROPERTY_SCHEME)")
+cpp_quote("#define Uri_HAS_ZONE            (1 << Uri_PROPERTY_ZONE)")
+
+cpp_quote("#define Uri_CREATE_ALLOW_RELATIVE                  0x0001")
+cpp_quote("#define Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME  0x0002")
+cpp_quote("#define Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME      0x0004")
+cpp_quote("#define Uri_CREATE_NOFRAG                          0x0008")
+cpp_quote("#define Uri_CREATE_NO_CANONICALIZE                 0x0010")
+cpp_quote("#define Uri_CREATE_CANONICALIZE                    0x0100")
+cpp_quote("#define Uri_CREATE_FILE_USE_DOS_PATH               0x0020")
+cpp_quote("#define Uri_CREATE_DECODE_EXTRA_INFO               0x0040")
+cpp_quote("#define Uri_CREATE_NO_DECODE_EXTRA_INFO            0x0080")
+cpp_quote("#define Uri_CREATE_CRACK_UNKNOWN_SCHEMES           0x0200")
+cpp_quote("#define Uri_CREATE_NO_CRACK_UNKNOWN_SCHEMES        0x0400")
+cpp_quote("#define Uri_CREATE_PRE_PROCESS_HTML_URI            0x0800")
+cpp_quote("#define Uri_CREATE_NO_PRE_PROCESS_HTML_URI         0x1000")
+cpp_quote("#define Uri_CREATE_IE_SETTINGS                     0x2000")
+cpp_quote("#define Uri_CREATE_NO_IE_SETTINGS                  0x4000")
+cpp_quote("#define Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS  0x8000")
+
+cpp_quote("#define Uri_DISPLAY_NO_FRAGMENT  0x00000001")
+cpp_quote("#define Uri_PUNYCODE_IDN_HOST    0x00000002")
+cpp_quote("#define Uri_DISPLAY_IDN_HOST     0x00000004")
+
+cpp_quote("#define Uri_ENCODING_USER_INFO_AND_PATH_IS_PERCENT_ENCODED_UTF8   0x00000001")
+cpp_quote("#define Uri_ENCODING_USER_INFO_AND_PATH_IS_CP                     0x00000002")
+cpp_quote("#define Uri_ENCODING_HOST_IS_IDN                                  0x00000004")
+cpp_quote("#define Uri_ENCODING_HOST_IS_PERCENT_ENCODED_UTF8                 0x00000008")
+cpp_quote("#define Uri_ENCODING_HOST_IS_PERCENT_ENCODED_CP                   0x00000010")
+cpp_quote("#define Uri_ENCODING_QUERY_AND_FRAGMENT_IS_PERCENT_ENCODED_UTF8   0x00000020")
+cpp_quote("#define Uri_ENCODING_QUERY_AND_FRAGMENT_IS_CP                     0x00000040")
+cpp_quote("#define Uri_ENCODING_RFC (Uri_ENCODING_USER_INFO_AND_PATH_IS_PERCENT_ENCODED_UTF8|Uri_ENCODING_HOST_IS_PERCENT_ENCODED_UTF8|Uri_ENCODING_QUERY_AND_FRAGMENT_IS_PERCENT_ENCODED_UTF8)")
+
+cpp_quote("#define UriBuilder_USE_ORIGINAL_FLAGS  0x00000001")
+
 /*****************************************************************************
  * IUriContainer interface
@@ -1669,4 +1726,103 @@
     HRESULT GetIUri([out] IUri **ppIUri);
 }
+
+/*****************************************************************************
+ * IUriBuilder interface
+ */
+[
+    local,
+    object,
+    uuid(4221b2e1-8955-46c0-bd5b-de9897565de7),
+    pointer_default(unique)
+]
+interface IUriBuilder: IUnknown
+{
+    HRESULT CreateUriSimple(
+        [in]  DWORD       dwAllowEncodingPropertyMask,
+        [in]  DWORD_PTR   dwReserved,
+        [out] IUri      **ppIUri);
+
+    HRESULT CreateUri(
+        [in]  DWORD       dwCreateFlags,
+        [in]  DWORD       dwAllowEncodingPropertyMask,
+        [in]  DWORD_PTR   dwReserved,
+        [out] IUri      **ppIUri);
+
+    HRESULT CreateUriWithFlags(
+        [in]  DWORD       dwCreateFlags,
+        [in]  DWORD       dwUriBuilderFlags,
+        [in]  DWORD       dwAllowEncodingPropertyMask,
+        [in]  DWORD_PTR   dwReserved,
+        [out] IUri      **ppIUri);
+
+    HRESULT GetIUri(
+        [out] IUri **ppIUri);
+
+    HRESULT SetIUri(
+        [in, unique] IUri *pIUri);
+
+    HRESULT GetFragment(
+        [out] DWORD   *pcchFragment,
+        [out] LPCWSTR *ppwzFragment);
+
+    HRESULT GetHost(
+        [out] DWORD   *pcchHost,
+        [out] LPCWSTR *ppwzHost);
+
+    HRESULT GetPassword(
+        [out] DWORD   *pcchPassword,
+        [out] LPCWSTR *ppwzPassword);
+
+    HRESULT GetPath(
+        [out] DWORD   *pcchPath,
+        [out] LPCWSTR *ppwzPath);
+
+    HRESULT GetPort(
+        [out] BOOL  *pfHasPort,
+        [out] DWORD *pdwPort);
+
+    HRESULT GetQuery(
+        [out] DWORD   *pcchQuery,
+        [out] LPCWSTR *ppwzQuery);
+
+    HRESULT GetSchemeName(
+        [out] DWORD   *pcchSchemeName,
+        [out] LPCWSTR *ppwzSchemeName);
+
+    HRESULT GetUserName(
+        [out] DWORD   *pcchUserName,
+        [out] LPCWSTR *ppwzUserName);
+
+    HRESULT SetFragment(
+        [in] LPCWSTR pwzNewValue);
+
+    HRESULT SetHost(
+        [in] LPCWSTR pwzNewValue);
+
+    HRESULT SetPassword(
+        [in] LPCWSTR pwzNewValue);
+
+    HRESULT SetPath(
+        [in] LPCWSTR pwzNewValue);
+
+    HRESULT SetPort(
+        [in] BOOL  fHasPort,
+        [in] DWORD dwNewValue);
+
+    HRESULT SetQuery(
+        [in] LPCWSTR pwzNewValue);
+
+    HRESULT SetSchemeName(
+        [in] LPCWSTR pwzNewValue);
+
+    HRESULT SetUserName(
+        [in] LPCWSTR pwzNewValue);
+
+    HRESULT RemoveProperties(
+        [in] DWORD dwPropertyMask);
+
+    HRESULT HasBeenModified(
+        [out] BOOL *pfModified);
+};
 
 /*****************************************************************************
@@ -1750,4 +1906,6 @@
 cpp_quote("HRESULT WINAPI CoGetClassObjectFromURL(REFCLSID, LPCWSTR, DWORD, DWORD, LPCWSTR, LPBINDCTX, DWORD, LPVOID, REFIID, LPVOID*);")
 cpp_quote("HRESULT WINAPI CreateURLMoniker(IMoniker *pmkContext, LPCWSTR szURL, IMoniker **ppmk);")
+cpp_quote("HRESULT WINAPI CreateURLMonikerEx(IMoniker*,LPCWSTR,IMoniker**,DWORD);")
+cpp_quote("HRESULT WINAPI CreateURLMonikerEx2(IMoniker*,IUri*,IMoniker**,DWORD);")
 cpp_quote("HRESULT WINAPI RegisterBindStatusCallback(IBindCtx *pbc, IBindStatusCallback *pbsc, IBindStatusCallback **ppbsc, DWORD dwReserved);")
 cpp_quote("HRESULT WINAPI CompareSecurityIds(BYTE*,DWORD,BYTE*,DWORD,DWORD);")
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/userenv.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/userenv.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/userenv.h	(revision 28475)
@@ -41,4 +41,5 @@
 
 BOOL WINAPI CreateEnvironmentBlock(LPVOID*,HANDLE,BOOL);
+BOOL WINAPI DestroyEnvironmentBlock(LPVOID);
 BOOL WINAPI ExpandEnvironmentStringsForUserA(HANDLE,LPCSTR,LPSTR,DWORD);
 BOOL WINAPI ExpandEnvironmentStringsForUserW(HANDLE,LPCWSTR,LPWSTR,DWORD);
@@ -50,4 +51,7 @@
 BOOL WINAPI GetProfilesDirectoryW(LPWSTR,LPDWORD);
 #define     GetProfilesDirectory WINELIB_NAME_AW(GetProfilesDirectory)
+BOOL WINAPI GetAllUsersProfileDirectoryA(LPSTR,LPDWORD);
+BOOL WINAPI GetAllUsersProfileDirectoryW(LPWSTR,LPDWORD);
+#define     GetAllUsersProfileDirectory WINELIB_NAME_AW(GetAllUsersProfileDirectory)
 BOOL WINAPI GetProfileType(DWORD*);
 BOOL WINAPI LoadUserProfileA(HANDLE,LPPROFILEINFOA);
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/usp10.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/usp10.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/usp10.h	(revision 28475)
@@ -109,5 +109,6 @@
   DWORD fNumericOverride	:1;
   DWORD fLegacyBidiClass	:1;
-  DWORD fReserved		:8;
+  DWORD fMergeNeutralItems	:1;
+  DWORD fReserved		:7;
 } SCRIPT_CONTROL;
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/uuids.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/uuids.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/uuids.h	(revision 28475)
@@ -145,4 +145,5 @@
 OUR_GUID_ENTRY(CLSID_AVIDoc,                         0xd3588ab0, 0x0781, 0x11ce, 0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70)
 OUR_GUID_ENTRY(CLSID_AVIDocWriter,                   0xd3588ab1, 0x0781, 0x11ce, 0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70)
+OUR_GUID_ENTRY(CLSID_SampleGrabber,                  0xc1f400a0, 0x3f08, 0x11d3, 0x9f, 0x0b, 0x00, 0x60, 0x08, 0x03, 0x9e, 0x37)
 OUR_GUID_ENTRY(CLSID_NullRenderer,                   0xc1f400a4, 0x3f08, 0x11d3, 0x9f, 0x0b, 0x00, 0x60, 0x08, 0x03, 0x9e, 0x37)
 OUR_GUID_ENTRY(CLSID_VideoRenderer,                  0x70e102b0, 0x5556, 0x11ce, 0x97, 0xc0, 0x00, 0xaa, 0x00, 0x55, 0x59, 0x5a)
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/ver.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/ver.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/ver.h	(revision 28475)
@@ -29,4 +29,5 @@
  * of the LGPL is applied is otherwise unspecified.
  */
+
 #ifndef __WINE_VER_H
 #define __WINE_VER_H
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wfext.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wfext.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wfext.h	(revision 28475)
@@ -25,4 +25,5 @@
  * of the LGPL is applied is otherwise unspecified.
  */
+
 #ifndef __WINE_WFEXT_H
 #define __WINE_WFEXT_H
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/winbase.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/winbase.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/winbase.h	(revision 28475)
@@ -1772,4 +1772,5 @@
 WINBASEAPI DWORD       WINAPI GetTimeZoneInformation(LPTIME_ZONE_INFORMATION);
 WINBASEAPI BOOL        WINAPI GetThreadContext(HANDLE,CONTEXT *);
+WINBASEAPI DWORD       WINAPI GetThreadErrorMode(void);
 WINBASEAPI INT         WINAPI GetThreadPriority(HANDLE);
 WINBASEAPI BOOL        WINAPI GetThreadPriorityBoost(HANDLE,PBOOL);
@@ -2106,4 +2107,5 @@
 WINBASEAPI DWORD_PTR   WINAPI SetThreadAffinityMask(HANDLE,DWORD_PTR);
 WINBASEAPI BOOL        WINAPI SetThreadContext(HANDLE,const CONTEXT *);
+WINBASEAPI BOOL        WINAPI SetThreadErrorMode(DWORD,LPDWORD);
 WINBASEAPI DWORD       WINAPI SetThreadExecutionState(EXECUTION_STATE);
 WINBASEAPI DWORD       WINAPI SetThreadIdealProcessor(HANDLE,DWORD);
@@ -2384,4 +2386,6 @@
 }
 
+WINBASEAPI LONGLONG WINAPI InterlockedCompareExchange64(LONGLONG volatile*,LONGLONG,LONGLONG);
+
 #else  /* __i386__ */
 
@@ -2412,4 +2416,17 @@
 }
 
+static inline LONGLONG WINAPI InterlockedCompareExchange64( LONGLONG volatile *dest, LONGLONG xchg, LONGLONG compare )
+{
+#if defined(__x86_64__) && defined(__GNUC__)
+    LONGLONG ret;
+    __asm__ __volatile__( "lock; cmpxchgq %2,(%1)"
+                          : "=a" (ret) : "r" (dest), "r" (xchg), "0" (compare) : "memory" );
+    return ret;
+#else
+    extern __int64 interlocked_cmpxchg64( __int64 *dest, __int64 xchg, __int64 compare );
+    return interlocked_cmpxchg64( (__int64 *)dest, xchg, compare );
+#endif
+}
+
 static inline LONG WINAPI InterlockedExchange( LONG volatile *dest, LONG val )
 {
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wincodec.idl
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wincodec.idl	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wincodec.idl	(revision 28475)
@@ -82,4 +82,12 @@
 } WICBitmapEncoderCacheOption;
 
+typedef enum WICBitmapInterpolationMode {
+    WICBitmapInterpolationModeNearestNeighbor = 0x00000000,
+    WICBitmapInterpolationModeLinear = 0x00000001,
+    WICBitmapInterpolationModeCubic = 0x00000002,
+    WICBitmapInterpolationModeFaint = 0x00000003,
+    WICBITMAPINTERPOLATIONMODE_FORCE_DWORD = CODEC_FORCE_DWORD
+} WICBitmapInterpolationMode;
+
 typedef enum WICBitmapPaletteType {
     WICBitmapPaletteTypeCustom = 0x00000000,
@@ -179,8 +187,5 @@
 cpp_quote("#define WINCODEC_ERR_INSUFFICIENTBUFFER 0x88982f8c")
 
-interface IWICBitmap;
 interface IWICPalette;
-interface IWICBitmapScaler;
-interface IWICBitmapClipper;
 interface IWICBitmapFlipRotator;
 interface IWICColorContext;
@@ -215,4 +220,44 @@
         [in] UINT cbBufferSize,
         [out, size_is(cbBufferSize)] BYTE *pbBuffer);
+}
+
+[
+    object,
+    uuid(00000123-a8f2-4877-ba0a-fd2b6645fb94)
+]
+interface IWICBitmapLock : IUnknown
+{
+    HRESULT GetSize(
+        [out] UINT *pWidth,
+        [out] UINT *pHeight);
+
+    HRESULT GetStride(
+        [out] UINT *pcbStride);
+
+    HRESULT GetDataPointer(
+        [out] UINT *pcbBufferSize,
+        [out, size_is(,*pcbBufferSize)] BYTE **ppbData);
+
+    HRESULT GetPixelFormat(
+        [out] WICPixelFormatGUID *pPixelFormat);
+}
+
+[
+    object,
+    uuid(00000121-a8f2-4877-ba0a-fd2b6645fb94)
+]
+interface IWICBitmap : IWICBitmapSource
+{
+    HRESULT Lock(
+        [in] const WICRect *prcLock,
+        [in] DWORD flags,
+        [out] IWICBitmapLock **ppILock);
+
+    HRESULT SetPalette(
+        [in] IWICPalette *pIPalette);
+
+    HRESULT SetResolution(
+        [in] double dpiX,
+        [in] double dpiY);
 }
 
@@ -594,4 +639,28 @@
         [in] ULARGE_INTEGER ulOffset,
         [in] ULARGE_INTEGER ulMaxSize);
+}
+
+[
+    object,
+    uuid(00000302-a8f2-4877-ba0a-fd2b6645fb94)
+]
+interface IWICBitmapScaler : IWICBitmapSource
+{
+    HRESULT Initialize(
+        [in] IWICBitmapSource *pISource,
+        [in] UINT uiWidth,
+        [in] UINT uiHeight,
+        [in] WICBitmapInterpolationMode mode);
+}
+
+[
+    object,
+    uuid(e4fbcf03-223d-4e81-9333-d635556dd1b5)
+]
+interface IWICBitmapClipper : IWICBitmapSource
+{
+    HRESULT Initialize(
+        [in] IWICBitmapSource *pISource,
+        [in] const WICRect *prc);
 }
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wincrypt.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wincrypt.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wincrypt.h	(revision 28475)
@@ -2792,4 +2792,7 @@
 #define szOID_RSA_SHA1RSA                   "1.2.840.113549.1.1.5"
 #define szOID_RSA_SET0AEP_RSA               "1.2.840.113549.1.1.6"
+#define szOID_RSA_SHA256RSA                 "1.2.840.113549.1.1.11"
+#define szOID_RSA_SHA384RSA                 "1.2.840.113549.1.1.12"
+#define szOID_RSA_SHA512RSA                 "1.2.840.113549.1.1.13"
 #define szOID_RSA_DH                        "1.2.840.113549.1.3.1"
 #define szOID_RSA_data                      "1.2.840.113549.1.7.1"
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/dcetypes.idl
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/dcetypes.idl	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/dcetypes.idl	(revision 28475)
@@ -17,13 +17,4 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
  */
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/epm.idl
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/epm.idl	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/epm.idl	(revision 28475)
@@ -17,13 +17,4 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
  */
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/exception.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/exception.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/exception.h	(revision 28475)
@@ -103,4 +103,23 @@
 #define siglongjmp(buf,val) longjmp(buf,val)
 #endif
+
+extern void __wine_rtl_unwind( EXCEPTION_REGISTRATION_RECORD* frame, EXCEPTION_RECORD *record,
+                               void (*target)(void) ) DECLSPEC_HIDDEN DECLSPEC_NORETURN;
+extern DWORD __wine_exception_handler( EXCEPTION_RECORD *record,
+                                       EXCEPTION_REGISTRATION_RECORD *frame,
+                                       CONTEXT *context,
+                                       EXCEPTION_REGISTRATION_RECORD **pdispatcher ) DECLSPEC_HIDDEN;
+extern DWORD __wine_exception_handler_page_fault( EXCEPTION_RECORD *record,
+                                                  EXCEPTION_REGISTRATION_RECORD *frame,
+                                                  CONTEXT *context,
+                                                  EXCEPTION_REGISTRATION_RECORD **pdispatcher ) DECLSPEC_HIDDEN;
+extern DWORD __wine_exception_handler_all( EXCEPTION_RECORD *record,
+                                           EXCEPTION_REGISTRATION_RECORD *frame,
+                                           CONTEXT *context,
+                                           EXCEPTION_REGISTRATION_RECORD **pdispatcher ) DECLSPEC_HIDDEN;
+extern DWORD __wine_finally_handler( EXCEPTION_RECORD *record,
+                                     EXCEPTION_REGISTRATION_RECORD *frame,
+                                     CONTEXT *context,
+                                     EXCEPTION_REGISTRATION_RECORD **pdispatcher ) DECLSPEC_HIDDEN;
 
 #define __TRY \
@@ -256,114 +275,4 @@
 extern void __wine_enter_vm86( CONTEXT *context );
 
-#ifndef USE_COMPILER_EXCEPTIONS
-
-NTSYSAPI void WINAPI RtlUnwind(PVOID,PVOID,PEXCEPTION_RECORD,PVOID);
-
-static inline void DECLSPEC_NORETURN __wine_unwind_target(void)
-{
-    __WINE_FRAME *wine_frame = (__WINE_FRAME *)__wine_get_frame();
-    __wine_pop_frame( &wine_frame->frame );
-    siglongjmp( wine_frame->jmp, 1 );
-}
-
-/* wrapper for RtlUnwind since it clobbers registers on Windows */
-static inline void DECLSPEC_NORETURN __wine_rtl_unwind( EXCEPTION_REGISTRATION_RECORD* frame,
-                                                        EXCEPTION_RECORD *record,
-                                                        void (*target)(void) )
-{
-#if defined(__GNUC__) && defined(__i386__)
-    int dummy1, dummy2, dummy3, dummy4;
-    __asm__ __volatile__("pushl %%ebp\n\t"
-                         "pushl %%ebx\n\t"
-                         "pushl $0\n\t"
-                         "pushl %3\n\t"
-                         "pushl %2\n\t"
-                         "pushl %1\n\t"
-                         "call *%0\n\t"
-                         "popl %%ebx\n\t"
-                         "popl %%ebp"
-                         : "=a" (dummy1), "=S" (dummy2), "=D" (dummy3), "=c" (dummy4)
-                         : "0" (RtlUnwind), "1" (frame), "2" (target), "3" (record)
-                         : "edx", "memory" );
-#else
-    RtlUnwind( frame, target, record, 0 );
-#endif
-    for (;;) target();
-}
-
-static inline void DECLSPEC_NORETURN __wine_unwind_frame( EXCEPTION_RECORD *record,
-                                                          EXCEPTION_REGISTRATION_RECORD *frame )
-{
-    __WINE_FRAME *wine_frame = (__WINE_FRAME *)frame;
-
-    /* hack to make GetExceptionCode() work in handler */
-    wine_frame->ExceptionCode   = record->ExceptionCode;
-    wine_frame->ExceptionRecord = wine_frame;
-
-    __wine_rtl_unwind( frame, record, __wine_unwind_target );
-}
-
-static inline DWORD __wine_exception_handler( EXCEPTION_RECORD *record,
-                                              EXCEPTION_REGISTRATION_RECORD *frame,
-                                              CONTEXT *context,
-                                              EXCEPTION_REGISTRATION_RECORD **pdispatcher )
-{
-    __WINE_FRAME *wine_frame = (__WINE_FRAME *)frame;
-    EXCEPTION_POINTERS ptrs;
-
-    if (record->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND | EH_NESTED_CALL))
-        return ExceptionContinueSearch;
-
-    ptrs.ExceptionRecord = record;
-    ptrs.ContextRecord = context;
-    switch(wine_frame->u.filter( &ptrs ))
-    {
-    case EXCEPTION_CONTINUE_SEARCH:
-        return ExceptionContinueSearch;
-    case EXCEPTION_CONTINUE_EXECUTION:
-        return ExceptionContinueExecution;
-    case EXCEPTION_EXECUTE_HANDLER:
-        break;
-    }
-    __wine_unwind_frame( record, frame );
-}
-
-static inline DWORD __wine_exception_handler_page_fault( EXCEPTION_RECORD *record,
-                                                         EXCEPTION_REGISTRATION_RECORD *frame,
-                                                         CONTEXT *context,
-                                                         EXCEPTION_REGISTRATION_RECORD **pdispatcher )
-{
-    if (record->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND | EH_NESTED_CALL))
-        return ExceptionContinueSearch;
-    if (record->ExceptionCode != STATUS_ACCESS_VIOLATION)
-        return ExceptionContinueSearch;
-    __wine_unwind_frame( record, frame );
-}
-
-static inline DWORD __wine_exception_handler_all( EXCEPTION_RECORD *record,
-                                                  EXCEPTION_REGISTRATION_RECORD *frame,
-                                                  CONTEXT *context,
-                                                  EXCEPTION_REGISTRATION_RECORD **pdispatcher )
-{
-    if (record->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND | EH_NESTED_CALL))
-        return ExceptionContinueSearch;
-    __wine_unwind_frame( record, frame );
-}
-
-static inline DWORD __wine_finally_handler( EXCEPTION_RECORD *record,
-                                            EXCEPTION_REGISTRATION_RECORD *frame,
-                                            CONTEXT *context,
-                                            EXCEPTION_REGISTRATION_RECORD **pdispatcher )
-{
-    if (record->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND))
-    {
-        __WINE_FRAME *wine_frame = (__WINE_FRAME *)frame;
-        wine_frame->u.finally_func( FALSE );
-    }
-    return ExceptionContinueSearch;
-}
-
-#endif /* USE_COMPILER_EXCEPTIONS */
-
 #ifdef __cplusplus
 }
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/irot.idl
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/irot.idl	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/irot.idl	(revision 28475)
@@ -15,13 +15,4 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
  */
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/itss.idl
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/itss.idl	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/itss.idl	(revision 28475)
@@ -15,13 +15,4 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
  */
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/library.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/library.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/library.h	(revision 28475)
@@ -17,13 +17,4 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
  */
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/pthread.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/pthread.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/pthread.h	(revision 28475)
@@ -17,40 +17,4 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
  */
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/server_protocol.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/server_protocol.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/server_protocol.h	(revision 28475)
@@ -152,8 +152,8 @@
         struct { unsigned int eip, ebp, esp, eflags, cs, ss; } i386_regs;
         struct { unsigned __int64 rip, rbp, rsp;
-                 unsigned int cs, ss, flags; } x86_64_regs;
+                 unsigned int cs, ss, flags, __pad; } x86_64_regs;
         struct { unsigned __int64 fir;
-                 unsigned int psr; } alpha_regs;
-        struct { unsigned int iar, msr, ctr, lr, dar, dsisr, trap; } powerpc_regs;
+                 unsigned int psr, __pad; } alpha_regs;
+        struct { unsigned int iar, msr, ctr, lr, dar, dsisr, trap, __pad; } powerpc_regs;
         struct { unsigned int psr, pc, npc, y, wim, tbr; } sparc_regs;
     } ctl;
@@ -735,5 +735,5 @@
     int          priority;
     cpu_type_t   cpu;
-    char __pad_60[4];
+    int          debugger_present;
 };
 
@@ -4666,4 +4666,22 @@
     struct reply_header __header;
 };
+
+
+
+struct set_cursor_request
+{
+    struct request_header __header;
+    unsigned int   flags;
+    user_handle_t  handle;
+    int            show_count;
+};
+struct set_cursor_reply
+{
+    struct reply_header __header;
+    user_handle_t  prev_handle;
+    int            prev_count;
+};
+#define SET_CURSOR_HANDLE 0x01
+#define SET_CURSOR_COUNT  0x02
 
 
@@ -4911,4 +4929,5 @@
     REQ_alloc_user_handle,
     REQ_free_user_handle,
+    REQ_set_cursor,
     REQ_NB_REQUESTS
 };
@@ -5159,4 +5178,5 @@
     struct alloc_user_handle_request alloc_user_handle_request;
     struct free_user_handle_request free_user_handle_request;
+    struct set_cursor_request set_cursor_request;
 };
 union generic_reply
@@ -5405,7 +5425,8 @@
     struct alloc_user_handle_reply alloc_user_handle_reply;
     struct free_user_handle_reply free_user_handle_reply;
-};
-
-#define SERVER_PROTOCOL_VERSION 395
+    struct set_cursor_reply set_cursor_reply;
+};
+
+#define SERVER_PROTOCOL_VERSION 398
 
 #endif /* __WINE_WINE_SERVER_PROTOCOL_H */
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/svcctl.idl
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/svcctl.idl	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/svcctl.idl	(revision 28475)
@@ -29,13 +29,4 @@
  */
 
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
- */
-
 import "wtypes.idl";
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/test.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/test.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/test.h	(revision 28475)
@@ -75,4 +75,12 @@
 static inline const char *wine_dbgstr_w( const WCHAR *s ) { return wine_dbgstr_wn( s, -1 ); }
 
+/* strcmpW is avaiable for tests compiled under Wine, but not in standalone
+ * builds under Windows, so we reimplement it under a different name. */
+static inline int winetest_strcmpW( const WCHAR *str1, const WCHAR *str2 )
+{
+    while (*str1 && (*str1 == *str2)) { str1++; str2++; }
+    return *str1 - *str2;
+}
+
 #ifdef STANDALONE
 #define START_TEST(name) \
@@ -84,25 +92,33 @@
 #endif
 
+#if defined(__x86_64__) && defined(__GNUC__) && defined(__WINE_USE_MSVCRT)
+#define __winetest_cdecl __cdecl
+#define __winetest_va_list __builtin_ms_va_list
+#else
+#define __winetest_cdecl
+#define __winetest_va_list va_list
+#endif
+
 extern int broken( int condition );
-extern int winetest_vok( int condition, const char *msg, va_list ap );
-extern void winetest_vskip( const char *msg, va_list ap );
+extern int winetest_vok( int condition, const char *msg, __winetest_va_list ap );
+extern void winetest_vskip( const char *msg, __winetest_va_list ap );
 
 #ifdef __GNUC__
 
-extern int winetest_ok( int condition, const char *msg, ... ) __attribute__((format (printf,2,3) ));
-extern void winetest_skip( const char *msg, ... ) __attribute__((format (printf,1,2)));
-extern void winetest_win_skip( const char *msg, ... ) __attribute__((format (printf,1,2)));
-extern void winetest_trace( const char *msg, ... ) __attribute__((format (printf,1,2)));
+extern void __winetest_cdecl winetest_ok( int condition, const char *msg, ... ) __attribute__((format (printf,2,3) ));
+extern void __winetest_cdecl winetest_skip( const char *msg, ... ) __attribute__((format (printf,1,2)));
+extern void __winetest_cdecl winetest_win_skip( const char *msg, ... ) __attribute__((format (printf,1,2)));
+extern void __winetest_cdecl winetest_trace( const char *msg, ... ) __attribute__((format (printf,1,2)));
 
 #else /* __GNUC__ */
 
-extern int winetest_ok( int condition, const char *msg, ... );
-extern void winetest_skip( const char *msg, ... );
-extern void winetest_win_skip( const char *msg, ... );
-extern void winetest_trace( const char *msg, ... );
+extern void __winetest_cdecl winetest_ok( int condition, const char *msg, ... );
+extern void __winetest_cdecl winetest_skip( const char *msg, ... );
+extern void __winetest_cdecl winetest_win_skip( const char *msg, ... );
+extern void __winetest_cdecl winetest_trace( const char *msg, ... );
 
 #endif /* __GNUC__ */
 
-#define ok_(file, line)       (winetest_set_location(file, line), 0) ? 0 : winetest_ok
+#define ok_(file, line)       (winetest_set_location(file, line), 0) ? (void)0 : winetest_ok
 #define skip_(file, line)     (winetest_set_location(file, line), 0) ? (void)0 : winetest_skip
 #define win_skip_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_win_skip
@@ -170,4 +186,12 @@
 #include <stdio.h>
 
+#if defined(__x86_64__) && defined(__GNUC__) && defined(__WINE_USE_MSVCRT)
+# define __winetest_va_start(list,arg) __builtin_ms_va_start(list,arg)
+# define __winetest_va_end(list) __builtin_ms_va_end(list)
+#else
+# define __winetest_va_start(list,arg) va_start(list,arg)
+# define __winetest_va_end(list) va_end(list)
+#endif
+
 struct test
 {
@@ -285,5 +309,5 @@
  *   0 if condition does not have the expected value, 1 otherwise
  */
-int winetest_vok( int condition, const char *msg, va_list args )
+int winetest_vok( int condition, const char *msg, __winetest_va_list args )
 {
     tls_data* data=get_tls_data();
@@ -332,18 +356,16 @@
 }
 
-int winetest_ok( int condition, const char *msg, ... )
-{
-    va_list valist;
-    int rc;
-
-    va_start(valist, msg);
-    rc=winetest_vok(condition, msg, valist);
-    va_end(valist);
-    return rc;
-}
-
-void winetest_trace( const char *msg, ... )
-{
-    va_list valist;
+void __winetest_cdecl winetest_ok( int condition, const char *msg, ... )
+{
+    __winetest_va_list valist;
+
+    __winetest_va_start(valist, msg);
+    winetest_vok(condition, msg, valist);
+    __winetest_va_end(valist);
+}
+
+void __winetest_cdecl winetest_trace( const char *msg, ... )
+{
+    __winetest_va_list valist;
     tls_data* data=get_tls_data();
 
@@ -351,11 +373,11 @@
     {
         fprintf( stdout, "%s:%d: ", data->current_file, data->current_line );
-        va_start(valist, msg);
+        __winetest_va_start(valist, msg);
         vfprintf(stdout, msg, valist);
-        va_end(valist);
-    }
-}
-
-void winetest_vskip( const char *msg, va_list args )
+        __winetest_va_end(valist);
+    }
+}
+
+void winetest_vskip( const char *msg, __winetest_va_list args )
 {
     tls_data* data=get_tls_data();
@@ -366,21 +388,21 @@
 }
 
-void winetest_skip( const char *msg, ... )
-{
-    va_list valist;
-    va_start(valist, msg);
+void __winetest_cdecl winetest_skip( const char *msg, ... )
+{
+    __winetest_va_list valist;
+    __winetest_va_start(valist, msg);
     winetest_vskip(msg, valist);
-    va_end(valist);
-}
-
-void winetest_win_skip( const char *msg, ... )
-{
-    va_list valist;
-    va_start(valist, msg);
+    __winetest_va_end(valist);
+}
+
+void __winetest_cdecl winetest_win_skip( const char *msg, ... )
+{
+    __winetest_va_list valist;
+    __winetest_va_start(valist, msg);
     if (strcmp(winetest_platform, "windows") == 0)
         winetest_vskip(msg, valist);
     else
         winetest_vok(0, msg, valist);
-    va_end(valist);
+    __winetest_va_end(valist);
 }
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/wine_common_ver.rc
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/wine_common_ver.rc	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/wine_common_ver.rc	(revision 28475)
@@ -16,13 +16,4 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
  */
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/wined3d.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/wined3d.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/wined3d.h	(revision 28475)
@@ -1,3 +1,3 @@
-/*** Autogenerated by WIDL 1.1.36 from ../../include/wine/wined3d.idl - Do not edit ***/
+/*** Autogenerated by WIDL 1.1.43 from ../../include/wine/wined3d.idl - Do not edit ***/
 
 #include <rpc.h>
@@ -343,25 +343,23 @@
     WINED3DFMT_B8G8R8A8_UNORM = 114,
     WINED3DFMT_B8G8R8X8_UNORM = 115,
-    WINED3DFMT_UYVY = 0x59565955,
-    WINED3DFMT_YUY2 = 0x32595559,
-    WINED3DFMT_YV12 = 0x32315659,
-    WINED3DFMT_DXT1 = 0x31545844,
-    WINED3DFMT_DXT2 = 0x32545844,
-    WINED3DFMT_DXT3 = 0x33545844,
-    WINED3DFMT_DXT4 = 0x34545844,
-    WINED3DFMT_DXT5 = 0x35545844,
-    WINED3DFMT_MULTI2_ARGB8 = 0x3154454d,
-    WINED3DFMT_G8R8_G8B8 = 0x42475247,
-    WINED3DFMT_R8G8_B8G8 = 0x47424752,
-    WINED3DFMT_ATI2N = 0x32495441,
-    WINED3DFMT_INST = 0x54534e49,
-    WINED3DFMT_NVHU = 0x5548564e,
-    WINED3DFMT_NVHS = 0x5348564e,
+    WINED3DFMT_UYVY = (((ULONG)(unsigned char)'U' | ((ULONG)(unsigned char)'Y' << 8)) | ((ULONG)(unsigned char)'V' << 16)) | ((ULONG)(unsigned char)'Y' << 24),
+    WINED3DFMT_YUY2 = (((ULONG)(unsigned char)'Y' | ((ULONG)(unsigned char)'U' << 8)) | ((ULONG)(unsigned char)'Y' << 16)) | ((ULONG)(unsigned char)'2' << 24),
+    WINED3DFMT_YV12 = (((ULONG)(unsigned char)'Y' | ((ULONG)(unsigned char)'V' << 8)) | ((ULONG)(unsigned char)'1' << 16)) | ((ULONG)(unsigned char)'2' << 24),
+    WINED3DFMT_DXT1 = (((ULONG)(unsigned char)'D' | ((ULONG)(unsigned char)'X' << 8)) | ((ULONG)(unsigned char)'T' << 16)) | ((ULONG)(unsigned char)'1' << 24),
+    WINED3DFMT_DXT2 = (((ULONG)(unsigned char)'D' | ((ULONG)(unsigned char)'X' << 8)) | ((ULONG)(unsigned char)'T' << 16)) | ((ULONG)(unsigned char)'2' << 24),
+    WINED3DFMT_DXT3 = (((ULONG)(unsigned char)'D' | ((ULONG)(unsigned char)'X' << 8)) | ((ULONG)(unsigned char)'T' << 16)) | ((ULONG)(unsigned char)'3' << 24),
+    WINED3DFMT_DXT4 = (((ULONG)(unsigned char)'D' | ((ULONG)(unsigned char)'X' << 8)) | ((ULONG)(unsigned char)'T' << 16)) | ((ULONG)(unsigned char)'4' << 24),
+    WINED3DFMT_DXT5 = (((ULONG)(unsigned char)'D' | ((ULONG)(unsigned char)'X' << 8)) | ((ULONG)(unsigned char)'T' << 16)) | ((ULONG)(unsigned char)'5' << 24),
+    WINED3DFMT_MULTI2_ARGB8 = (((ULONG)(unsigned char)'M' | ((ULONG)(unsigned char)'E' << 8)) | ((ULONG)(unsigned char)'T' << 16)) | ((ULONG)(unsigned char)'1' << 24),
+    WINED3DFMT_G8R8_G8B8 = (((ULONG)(unsigned char)'G' | ((ULONG)(unsigned char)'R' << 8)) | ((ULONG)(unsigned char)'G' << 16)) | ((ULONG)(unsigned char)'B' << 24),
+    WINED3DFMT_R8G8_B8G8 = (((ULONG)(unsigned char)'R' | ((ULONG)(unsigned char)'G' << 8)) | ((ULONG)(unsigned char)'B' << 16)) | ((ULONG)(unsigned char)'G' << 24),
+    WINED3DFMT_ATI2N = (((ULONG)(unsigned char)'A' | ((ULONG)(unsigned char)'T' << 8)) | ((ULONG)(unsigned char)'I' << 16)) | ((ULONG)(unsigned char)'2' << 24),
+    WINED3DFMT_INST = (((ULONG)(unsigned char)'I' | ((ULONG)(unsigned char)'N' << 8)) | ((ULONG)(unsigned char)'S' << 16)) | ((ULONG)(unsigned char)'T' << 24),
+    WINED3DFMT_NVHU = (((ULONG)(unsigned char)'N' | ((ULONG)(unsigned char)'V' << 8)) | ((ULONG)(unsigned char)'H' << 16)) | ((ULONG)(unsigned char)'U' << 24),
+    WINED3DFMT_NVHS = (((ULONG)(unsigned char)'N' | ((ULONG)(unsigned char)'V' << 8)) | ((ULONG)(unsigned char)'H' << 16)) | ((ULONG)(unsigned char)'S' << 24),
     WINED3DFMT_FORCE_DWORD = 0xffffffff
 } WINED3DFORMAT;
 typedef enum _WINED3DRENDERSTATETYPE {
-    WINED3DRS_TEXTUREHANDLE = 1,
     WINED3DRS_ANTIALIAS = 2,
-    WINED3DRS_TEXTUREADDRESS = 3,
     WINED3DRS_TEXTUREPERSPECTIVE = 4,
     WINED3DRS_WRAPU = 5,
@@ -377,9 +375,6 @@
     WINED3DRS_ALPHATESTENABLE = 15,
     WINED3DRS_LASTPIXEL = 16,
-    WINED3DRS_TEXTUREMAG = 17,
-    WINED3DRS_TEXTUREMIN = 18,
     WINED3DRS_SRCBLEND = 19,
     WINED3DRS_DESTBLEND = 20,
-    WINED3DRS_TEXTUREMAPBLEND = 21,
     WINED3DRS_CULLMODE = 22,
     WINED3DRS_ZFUNC = 23,
@@ -402,7 +397,4 @@
     WINED3DRS_EDGEANTIALIAS = 40,
     WINED3DRS_COLORKEYENABLE = 41,
-    WINED3DRS_BORDERCOLOR = 43,
-    WINED3DRS_TEXTUREADDRESSU = 44,
-    WINED3DRS_TEXTUREADDRESSV = 45,
     WINED3DRS_MIPMAPLODBIAS = 46,
     WINED3DRS_ZBIAS = 47,
@@ -420,36 +412,4 @@
     WINED3DRS_STENCILWRITEMASK = 59,
     WINED3DRS_TEXTUREFACTOR = 60,
-    WINED3DRS_STIPPLEPATTERN00 = 64,
-    WINED3DRS_STIPPLEPATTERN01 = 65,
-    WINED3DRS_STIPPLEPATTERN02 = 66,
-    WINED3DRS_STIPPLEPATTERN03 = 67,
-    WINED3DRS_STIPPLEPATTERN04 = 68,
-    WINED3DRS_STIPPLEPATTERN05 = 69,
-    WINED3DRS_STIPPLEPATTERN06 = 70,
-    WINED3DRS_STIPPLEPATTERN07 = 71,
-    WINED3DRS_STIPPLEPATTERN08 = 72,
-    WINED3DRS_STIPPLEPATTERN09 = 73,
-    WINED3DRS_STIPPLEPATTERN10 = 74,
-    WINED3DRS_STIPPLEPATTERN11 = 75,
-    WINED3DRS_STIPPLEPATTERN12 = 76,
-    WINED3DRS_STIPPLEPATTERN13 = 77,
-    WINED3DRS_STIPPLEPATTERN14 = 78,
-    WINED3DRS_STIPPLEPATTERN15 = 79,
-    WINED3DRS_STIPPLEPATTERN16 = 80,
-    WINED3DRS_STIPPLEPATTERN17 = 81,
-    WINED3DRS_STIPPLEPATTERN18 = 82,
-    WINED3DRS_STIPPLEPATTERN19 = 83,
-    WINED3DRS_STIPPLEPATTERN20 = 84,
-    WINED3DRS_STIPPLEPATTERN21 = 85,
-    WINED3DRS_STIPPLEPATTERN22 = 86,
-    WINED3DRS_STIPPLEPATTERN23 = 87,
-    WINED3DRS_STIPPLEPATTERN24 = 88,
-    WINED3DRS_STIPPLEPATTERN25 = 89,
-    WINED3DRS_STIPPLEPATTERN26 = 90,
-    WINED3DRS_STIPPLEPATTERN27 = 91,
-    WINED3DRS_STIPPLEPATTERN28 = 92,
-    WINED3DRS_STIPPLEPATTERN29 = 93,
-    WINED3DRS_STIPPLEPATTERN30 = 94,
-    WINED3DRS_STIPPLEPATTERN31 = 95,
     WINED3DRS_WRAP0 = 128,
     WINED3DRS_WRAP1 = 129,
@@ -493,6 +453,4 @@
     WINED3DRS_TWEENFACTOR = 170,
     WINED3DRS_BLENDOP = 171,
-    WINED3DRS_POSITIONORDER = 172,
-    WINED3DRS_NORMALORDER = 173,
     WINED3DRS_POSITIONDEGREE = 172,
     WINED3DRS_NORMALDEGREE = 173,
@@ -7318,4 +7276,14 @@
         void *data) = 0;
 
+    virtual HRESULT STDMETHODCALLTYPE GetSurfaceFromDC(
+        HDC dc,
+        IWineD3DSurface **surface) = 0;
+
+    virtual HRESULT STDMETHODCALLTYPE AcquireFocusWindow(
+        HWND window) = 0;
+
+    virtual void STDMETHODCALLTYPE ReleaseFocusWindow(
+        ) = 0;
+
 };
 #else
@@ -8055,4 +8023,16 @@
         HRESULT (STDMETHODCALLTYPE * callback)(IWineD3DResource *resource,void *pData),
         void *data);
+
+    HRESULT (STDMETHODCALLTYPE *GetSurfaceFromDC)(
+        IWineD3DDevice* This,
+        HDC dc,
+        IWineD3DSurface **surface);
+
+    HRESULT (STDMETHODCALLTYPE *AcquireFocusWindow)(
+        IWineD3DDevice* This,
+        HWND window);
+
+    void (STDMETHODCALLTYPE *ReleaseFocusWindow)(
+        IWineD3DDevice* This);
 
     END_INTERFACE
@@ -8200,4 +8180,7 @@
 #define IWineD3DDevice_GetFrontBufferData(This,swapchain_idx,dst_surface) (This)->lpVtbl->GetFrontBufferData(This,swapchain_idx,dst_surface)
 #define IWineD3DDevice_EnumResources(This,callback,data) (This)->lpVtbl->EnumResources(This,callback,data)
+#define IWineD3DDevice_GetSurfaceFromDC(This,dc,surface) (This)->lpVtbl->GetSurfaceFromDC(This,dc,surface)
+#define IWineD3DDevice_AcquireFocusWindow(This,window) (This)->lpVtbl->AcquireFocusWindow(This,window)
+#define IWineD3DDevice_ReleaseFocusWindow(This) (This)->lpVtbl->ReleaseFocusWindow(This)
 #endif
 
@@ -9439,4 +9422,28 @@
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
+HRESULT STDMETHODCALLTYPE IWineD3DDevice_GetSurfaceFromDC_Proxy(
+    IWineD3DDevice* This,
+    HDC dc,
+    IWineD3DSurface **surface);
+void __RPC_STUB IWineD3DDevice_GetSurfaceFromDC_Stub(
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
+    PRPC_MESSAGE pRpcMessage,
+    DWORD* pdwStubPhase);
+HRESULT STDMETHODCALLTYPE IWineD3DDevice_AcquireFocusWindow_Proxy(
+    IWineD3DDevice* This,
+    HWND window);
+void __RPC_STUB IWineD3DDevice_AcquireFocusWindow_Stub(
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
+    PRPC_MESSAGE pRpcMessage,
+    DWORD* pdwStubPhase);
+void STDMETHODCALLTYPE IWineD3DDevice_ReleaseFocusWindow_Proxy(
+    IWineD3DDevice* This);
+void __RPC_STUB IWineD3DDevice_ReleaseFocusWindow_Stub(
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
+    PRPC_MESSAGE pRpcMessage,
+    DWORD* pdwStubPhase);
 
 #endif  /* __IWineD3DDevice_INTERFACE_DEFINED__ */
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/wined3d.idl
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/wined3d.idl	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/wined3d.idl	(revision 28475)
@@ -22,13 +22,4 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
  */
 
@@ -153,4 +144,8 @@
     WINED3DDEGREE_FORCE_DWORD               = 0x7fffffff
 } WINED3DDEGREETYPE;
+
+#define WINEMAKEFOURCC(ch0, ch1, ch2, ch3) \
+        ((unsigned long)(unsigned char)(ch0) | ((unsigned long)(unsigned char)(ch1) << 8) | \
+        ((unsigned long)(unsigned char)(ch2) << 16) | ((unsigned long)(unsigned char)(ch3) << 24))
 
 typedef enum _WINED3DFORMAT
@@ -273,19 +268,19 @@
     WINED3DFMT_B8G8R8X8_UNORM,
     /* FOURCC formats. */
-    WINED3DFMT_UYVY                         = 0x59565955, /* UYVY */
-    WINED3DFMT_YUY2                         = 0x32595559, /* YUY2 */
-    WINED3DFMT_YV12                         = 0x32315659, /* YV12 */
-    WINED3DFMT_DXT1                         = 0x31545844, /* DXT1 */
-    WINED3DFMT_DXT2                         = 0x32545844, /* DXT2 */
-    WINED3DFMT_DXT3                         = 0x33545844, /* DXT3 */
-    WINED3DFMT_DXT4                         = 0x34545844, /* DXT4 */
-    WINED3DFMT_DXT5                         = 0x35545844, /* DXT5 */
-    WINED3DFMT_MULTI2_ARGB8                 = 0x3154454d, /* MET1 */
-    WINED3DFMT_G8R8_G8B8                    = 0x42475247, /* GRGB */
-    WINED3DFMT_R8G8_B8G8                    = 0x47424752, /* RGBG */
-    WINED3DFMT_ATI2N                        = 0x32495441, /* ATI2 */
-    WINED3DFMT_INST                         = 0x54534e49, /* INST */
-    WINED3DFMT_NVHU                         = 0x5548564e, /* NVHU */
-    WINED3DFMT_NVHS                         = 0x5348564e, /* NVHS */
+    WINED3DFMT_UYVY                         = WINEMAKEFOURCC('U','Y','V','Y'),
+    WINED3DFMT_YUY2                         = WINEMAKEFOURCC('Y','U','Y','2'),
+    WINED3DFMT_YV12                         = WINEMAKEFOURCC('Y','V','1','2'),
+    WINED3DFMT_DXT1                         = WINEMAKEFOURCC('D','X','T','1'),
+    WINED3DFMT_DXT2                         = WINEMAKEFOURCC('D','X','T','2'),
+    WINED3DFMT_DXT3                         = WINEMAKEFOURCC('D','X','T','3'),
+    WINED3DFMT_DXT4                         = WINEMAKEFOURCC('D','X','T','4'),
+    WINED3DFMT_DXT5                         = WINEMAKEFOURCC('D','X','T','5'),
+    WINED3DFMT_MULTI2_ARGB8                 = WINEMAKEFOURCC('M','E','T','1'),
+    WINED3DFMT_G8R8_G8B8                    = WINEMAKEFOURCC('G','R','G','B'),
+    WINED3DFMT_R8G8_B8G8                    = WINEMAKEFOURCC('R','G','B','G'),
+    WINED3DFMT_ATI2N                        = WINEMAKEFOURCC('A','T','I','2'),
+    WINED3DFMT_INST                         = WINEMAKEFOURCC('I','N','S','T'),
+    WINED3DFMT_NVHU                         = WINEMAKEFOURCC('N','V','H','U'),
+    WINED3DFMT_NVHS                         = WINEMAKEFOURCC('N','V','H','S'),
 
     WINED3DFMT_FORCE_DWORD = 0xffffffff
@@ -294,7 +289,5 @@
 typedef enum _WINED3DRENDERSTATETYPE
 {
-    WINED3DRS_TEXTUREHANDLE                 = 1, /* d3d7 */
     WINED3DRS_ANTIALIAS                     = 2, /* d3d7 */
-    WINED3DRS_TEXTUREADDRESS                = 3, /* d3d7 */
     WINED3DRS_TEXTUREPERSPECTIVE            = 4, /* d3d7 */
     WINED3DRS_WRAPU                         = 5, /* d3d7 */
@@ -310,9 +303,6 @@
     WINED3DRS_ALPHATESTENABLE               = 15,
     WINED3DRS_LASTPIXEL                     = 16,
-    WINED3DRS_TEXTUREMAG                    = 17, /* d3d7 */
-    WINED3DRS_TEXTUREMIN                    = 18, /* d3d7 */
     WINED3DRS_SRCBLEND                      = 19,
     WINED3DRS_DESTBLEND                     = 20,
-    WINED3DRS_TEXTUREMAPBLEND               = 21, /* d3d7 */
     WINED3DRS_CULLMODE                      = 22,
     WINED3DRS_ZFUNC                         = 23,
@@ -335,7 +325,4 @@
     WINED3DRS_EDGEANTIALIAS                 = 40, /* d3d7, d3d8 */
     WINED3DRS_COLORKEYENABLE                = 41, /* d3d7 */
-    WINED3DRS_BORDERCOLOR                   = 43, /* d3d7 */
-    WINED3DRS_TEXTUREADDRESSU               = 44, /* d3d7 */
-    WINED3DRS_TEXTUREADDRESSV               = 45, /* d3d7 */
     WINED3DRS_MIPMAPLODBIAS                 = 46, /* d3d7 */
     WINED3DRS_ZBIAS                         = 47, /* d3d7, d3d8 */
@@ -353,36 +340,4 @@
     WINED3DRS_STENCILWRITEMASK              = 59,
     WINED3DRS_TEXTUREFACTOR                 = 60,
-    WINED3DRS_STIPPLEPATTERN00              = 64,
-    WINED3DRS_STIPPLEPATTERN01              = 65,
-    WINED3DRS_STIPPLEPATTERN02              = 66,
-    WINED3DRS_STIPPLEPATTERN03              = 67,
-    WINED3DRS_STIPPLEPATTERN04              = 68,
-    WINED3DRS_STIPPLEPATTERN05              = 69,
-    WINED3DRS_STIPPLEPATTERN06              = 70,
-    WINED3DRS_STIPPLEPATTERN07              = 71,
-    WINED3DRS_STIPPLEPATTERN08              = 72,
-    WINED3DRS_STIPPLEPATTERN09              = 73,
-    WINED3DRS_STIPPLEPATTERN10              = 74,
-    WINED3DRS_STIPPLEPATTERN11              = 75,
-    WINED3DRS_STIPPLEPATTERN12              = 76,
-    WINED3DRS_STIPPLEPATTERN13              = 77,
-    WINED3DRS_STIPPLEPATTERN14              = 78,
-    WINED3DRS_STIPPLEPATTERN15              = 79,
-    WINED3DRS_STIPPLEPATTERN16              = 80,
-    WINED3DRS_STIPPLEPATTERN17              = 81,
-    WINED3DRS_STIPPLEPATTERN18              = 82,
-    WINED3DRS_STIPPLEPATTERN19              = 83,
-    WINED3DRS_STIPPLEPATTERN20              = 84,
-    WINED3DRS_STIPPLEPATTERN21              = 85,
-    WINED3DRS_STIPPLEPATTERN22              = 86,
-    WINED3DRS_STIPPLEPATTERN23              = 87,
-    WINED3DRS_STIPPLEPATTERN24              = 88,
-    WINED3DRS_STIPPLEPATTERN25              = 89,
-    WINED3DRS_STIPPLEPATTERN26              = 90,
-    WINED3DRS_STIPPLEPATTERN27              = 91,
-    WINED3DRS_STIPPLEPATTERN28              = 92,
-    WINED3DRS_STIPPLEPATTERN29              = 93,
-    WINED3DRS_STIPPLEPATTERN30              = 94,
-    WINED3DRS_STIPPLEPATTERN31              = 95,
     WINED3DRS_WRAP0                         = 128,
     WINED3DRS_WRAP1                         = 129,
@@ -426,6 +381,4 @@
     WINED3DRS_TWEENFACTOR                   = 170,
     WINED3DRS_BLENDOP                       = 171,
-    WINED3DRS_POSITIONORDER                 = 172,
-    WINED3DRS_NORMALORDER                   = 173,
     WINED3DRS_POSITIONDEGREE                = 172,
     WINED3DRS_NORMALDEGREE                  = 173,
@@ -3471,4 +3424,13 @@
         [in] void *data
     );
+    HRESULT GetSurfaceFromDC(
+        [in] HDC dc,
+        [out] IWineD3DSurface **surface
+    );
+    HRESULT AcquireFocusWindow(
+        [in] HWND window
+    );
+    void ReleaseFocusWindow(
+    );
 }
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/winedxgi.idl
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/winedxgi.idl	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/winedxgi.idl	(revision 28475)
@@ -15,13 +15,4 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
  */
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/winnet16.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/winnet16.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/winnet16.h	(revision 28475)
@@ -209,5 +209,5 @@
  */
 
-WORD WINAPI WNetGetUser16(LPCSTR,LPSTR,LPINT16);
+WORD WINAPI WNetGetUser16(LPSTR,LPINT16);
 
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/wpp.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/wpp.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/wpp.h	(revision 28475)
@@ -67,5 +67,4 @@
 extern char *wpp_find_include( const char *name, const char *parent_name );
 extern int wpp_parse( const char *input, FILE *output );
-extern int wpp_parse_temp( const char *input, const char *output_base, char **output_name );
 extern void wpp_set_callbacks( const struct wpp_callbacks *callbacks );
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/winerror.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/winerror.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/winerror.h	(revision 28475)
@@ -316,4 +316,5 @@
 #define ERROR_PIPE_CONNECTED                               535
 #define ERROR_PIPE_LISTENING                               536
+#define ERROR_HANDLES_CLOSED                               676
 #define ERROR_EA_ACCESS_DENIED                             994
 #define ERROR_OPERATION_ABORTED                            995
@@ -720,5 +721,15 @@
 #define ERROR_INSTALL_REMOTE_DISALLOWED                    1640
 #define ERROR_SUCCESS_REBOOT_INITIATED                     1641
+#define ERROR_PATCH_TARGET_NOT_FOUND                       1642
+#define ERROR_PATCH_PACKAGE_REJECTED                       1643
+#define ERROR_INSTALL_TRANSFORM_REJECTED                   1644
+#define ERROR_INSTALL_REMOTE_PROHIBITED                    1645
+#define ERROR_PATCH_REMOVAL_UNSUPPORTED                    1646
 #define ERROR_UNKNOWN_PATCH                                1647
+#define ERROR_PATCH_NO_SEQUENCE                            1648
+#define ERROR_PATCH_REMOVAL_DISALLOWED                     1649
+#define ERROR_INVALID_PATCH_XML                            1650
+#define ERROR_PATCH_MANAGED_ADVERTISED_PRODUCT             1651
+#define ERROR_INSTALL_SERVICE_SAFEBOOT                     1652
 #define RPC_S_INVALID_STRING_BINDING                       1700
 #define RPC_S_WRONG_KIND_OF_BINDING                        1701
@@ -1560,4 +1571,83 @@
 #define DNS_ERROR_NO_TCPIP                                 9851
 #define DNS_ERROR_NO_DNS_SERVERS                           9852
+
+/*
+ * Also defined in winsock.h.
+ *
+ * All Windows Sockets error constants are biased by WSABASEERR from
+ * the "normal"
+ */
+#define WSABASEERR                 10000
+/*
+ * Windows Sockets definitions of regular Microsoft C error constants
+ */
+#define WSAEINTR                   (WSABASEERR+4)
+#define WSAEBADF                   (WSABASEERR+9)
+#define WSAEACCES                  (WSABASEERR+13)
+#define WSAEFAULT                  (WSABASEERR+14)
+#define WSAEINVAL                  (WSABASEERR+22)
+#define WSAEMFILE                  (WSABASEERR+24)
+
+/*
+ * Windows Sockets definitions of regular Berkeley error constants
+ */
+#define WSAEWOULDBLOCK             (WSABASEERR+35)
+#define WSAEINPROGRESS             (WSABASEERR+36)
+#define WSAEALREADY                (WSABASEERR+37)
+#define WSAENOTSOCK                (WSABASEERR+38)
+#define WSAEDESTADDRREQ            (WSABASEERR+39)
+#define WSAEMSGSIZE                (WSABASEERR+40)
+#define WSAEPROTOTYPE              (WSABASEERR+41)
+#define WSAENOPROTOOPT             (WSABASEERR+42)
+#define WSAEPROTONOSUPPORT         (WSABASEERR+43)
+#define WSAESOCKTNOSUPPORT         (WSABASEERR+44)
+#define WSAEOPNOTSUPP              (WSABASEERR+45)
+#define WSAEPFNOSUPPORT            (WSABASEERR+46)
+#define WSAEAFNOSUPPORT            (WSABASEERR+47)
+#define WSAEADDRINUSE              (WSABASEERR+48)
+#define WSAEADDRNOTAVAIL           (WSABASEERR+49)
+#define WSAENETDOWN                (WSABASEERR+50)
+#define WSAENETUNREACH             (WSABASEERR+51)
+#define WSAENETRESET               (WSABASEERR+52)
+#define WSAECONNABORTED            (WSABASEERR+53)
+#define WSAECONNRESET              (WSABASEERR+54)
+#define WSAENOBUFS                 (WSABASEERR+55)
+#define WSAEISCONN                 (WSABASEERR+56)
+#define WSAENOTCONN                (WSABASEERR+57)
+#define WSAESHUTDOWN               (WSABASEERR+58)
+#define WSAETOOMANYREFS            (WSABASEERR+59)
+#define WSAETIMEDOUT               (WSABASEERR+60)
+#define WSAECONNREFUSED            (WSABASEERR+61)
+#define WSAELOOP                   (WSABASEERR+62)
+#define WSAENAMETOOLONG            (WSABASEERR+63)
+#define WSAEHOSTDOWN               (WSABASEERR+64)
+#define WSAEHOSTUNREACH            (WSABASEERR+65)
+#define WSAENOTEMPTY               (WSABASEERR+66)
+#define WSAEPROCLIM                (WSABASEERR+67)
+#define WSAEUSERS                  (WSABASEERR+68)
+#define WSAEDQUOT                  (WSABASEERR+69)
+#define WSAESTALE                  (WSABASEERR+70)
+#define WSAEREMOTE                 (WSABASEERR+71)
+
+/*
+ * Extended Windows Sockets error constant definitions
+ */
+#define WSASYSNOTREADY             (WSABASEERR+91)
+#define WSAVERNOTSUPPORTED         (WSABASEERR+92)
+#define WSANOTINITIALISED          (WSABASEERR+93)
+#define WSAEDISCON                 (WSABASEERR+101)
+#define WSAENOMORE                 (WSABASEERR+102)
+#define WSAECANCELLED              (WSABASEERR+103)
+#define WSAEINVALIDPROCTABLE       (WSABASEERR+104)
+#define WSAEINVALIDPROVIDER        (WSABASEERR+105)
+#define WSAEPROVIDERFAILEDINIT     (WSABASEERR+106)
+#define WSASYSCALLFAILURE          (WSABASEERR+107)
+#define WSASERVICE_NOT_FOUND       (WSABASEERR+108)
+#define WSATYPE_NOT_FOUND          (WSABASEERR+109)
+#define WSA_E_NO_MORE              (WSABASEERR+110)
+#define WSA_E_CANCELLED            (WSABASEERR+111)
+#define WSAEREFUSED                (WSABASEERR+112)
+
+
 #define ERROR_SXS_SECTION_NOT_FOUND                        14000
 #define ERROR_SXS_CANT_GEN_ACTCTX                          14001
@@ -2162,4 +2252,5 @@
 #define SEC_I_COMPLETE_NEEDED                              _HRESULT_TYPEDEF_(0x00090313L)
 #define SEC_I_COMPLETE_AND_CONTINUE                        _HRESULT_TYPEDEF_(0x00090314L) 
+#define SEC_I_CONTEXT_EXPIRED                              _HRESULT_TYPEDEF_(0x00090317L)
 #define SEC_E_BAD_PKGID                                    _HRESULT_TYPEDEF_(0x80090316L)
 #define SEC_E_CONTEXT_EXPIRED                              _HRESULT_TYPEDEF_(0x80090317L)
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/winnetwk.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/winnetwk.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/winnetwk.h	(revision 28475)
@@ -25,5 +25,4 @@
  * of the LGPL is applied is otherwise unspecified.
  */
-
 
 #ifndef _WINNETWK_H_
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/winreg.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/winreg.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/winreg.h	(revision 28475)
@@ -114,4 +114,7 @@
 WINADVAPI LSTATUS   WINAPI RegDeleteKeyW(HKEY,LPCWSTR);
 #define                    RegDeleteKey WINELIB_NAME_AW(RegDeleteKey)
+WINADVAPI LSTATUS   WINAPI RegDeleteKeyExA(HKEY,LPCSTR,REGSAM,DWORD);
+WINADVAPI LSTATUS   WINAPI RegDeleteKeyExW(HKEY,LPCWSTR,REGSAM,DWORD);
+#define                    RegDeleteKeyEx WINELIB_NAME_AW(RegDeleteKeyEx)
 WINADVAPI LSTATUS   WINAPI RegDeleteKeyValueA(HKEY,LPCSTR,LPCSTR);
 WINADVAPI LSTATUS   WINAPI RegDeleteKeyValueW(HKEY,LPCWSTR,LPCWSTR);
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/winsock.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/winsock.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/winsock.h	(revision 28475)
@@ -90,4 +90,5 @@
 #  define select unix_select
 #  define socklen_t unix_socklen_t
+#  define u_long unix_u_long
 #  include <sys/types.h>
 #  include <time.h>
@@ -97,4 +98,5 @@
 #  undef select
 #  undef socklen_t
+#  undef u_long
 #  undef FD_SETSIZE
 #  undef FD_CLR
@@ -128,9 +130,5 @@
 typedef unsigned short WS_u_short;
 typedef unsigned int   WS_u_int;
-#ifdef _MSC_VER
-typedef unsigned long  WS_u_long;
-#else
-typedef unsigned int   WS_u_long;
-#endif
+typedef ULONG          WS_u_long;
 #elif (defined(_MSC_VER) || defined(__MINGW32__) || defined(__WATCOMC__)) && !defined(_BSDTYPES_DEFINED)
 /* MinGW doesn't define the u_xxx types */
@@ -138,10 +136,8 @@
 typedef unsigned short u_short;
 typedef unsigned int   u_int;
-#ifdef _MSC_VER
-typedef unsigned long  u_long;
-#else
-typedef unsigned int   u_long;
-#endif
+typedef ULONG          u_long;
 #define _BSDTYPES_DEFINED
+#else
+#define u_long ULONG  /* make sure we don't use the system u_long */
 #endif
 
@@ -311,5 +307,5 @@
     char** n_aliases;              /* alias list */
     short n_addrtype;              /* net address type */
-    WS(u_long) n_net;              /* network # */
+    ULONG n_net;                   /* network # */
 };
 
@@ -533,7 +529,7 @@
 #ifdef WORDS_BIGENDIAN
 
-#define htonl(l) ((u_long)(l))
+#define htonl(l) ((ULONG)(l))
 #define htons(s) ((u_short)(s))
-#define ntohl(l) ((u_long)(l))
+#define ntohl(l) ((ULONG)(l))
 #define ntohs(s) ((u_short)(s))
 
@@ -544,7 +540,7 @@
     return (s >> 8) | (s << 8);
 }
-static inline u_long __wine_ulong_swap(u_long l)
-{
-    return ((u_long)__wine_ushort_swap((u_short)l) << 16) | __wine_ushort_swap((u_short)(l >> 16));
+static inline ULONG __wine_ulong_swap(ULONG l)
+{
+    return ((ULONG)__wine_ushort_swap((u_short)l) << 16) | __wine_ushort_swap((u_short)(l >> 16));
 }
 #define htonl(l) __wine_ulong_swap(l)
@@ -594,12 +590,12 @@
 
 #ifndef USE_WS_PREFIX
-#define INADDR_ANY                 ((u_long)0x00000000)
+#define INADDR_ANY                 ((ULONG)0x00000000)
 #define INADDR_LOOPBACK            0x7f000001
-#define INADDR_BROADCAST           ((u_long)0xffffffff)
+#define INADDR_BROADCAST           ((ULONG)0xffffffff)
 #define INADDR_NONE                0xffffffff
 #else
-#define WS_INADDR_ANY              ((WS_u_long)0x00000000)
+#define WS_INADDR_ANY              ((ULONG)0x00000000)
 #define WS_INADDR_LOOPBACK         0x7f000001
-#define WS_INADDR_BROADCAST        ((WS_u_long)0xffffffff)
+#define WS_INADDR_BROADCAST        ((ULONG)0xffffffff)
 #define WS_INADDR_NONE             0xffffffff
 #endif /* USE_WS_PREFIX */
@@ -614,5 +610,5 @@
             WS(u_short) s_w1,s_w2;
         } S_un_w;
-        WS(u_long) S_addr;
+        ULONG S_addr;
     } S_un;
 #ifndef USE_WS_PREFIX
@@ -788,21 +784,21 @@
  */
 #ifndef USE_WS_PREFIX
-#define FIONREAD                   _IOR('f', 127, u_long)
-#define FIONBIO                    _IOW('f', 126, u_long)
-#define FIOASYNC                   _IOW('f', 125, u_long)
-#define SIOCSHIWAT                 _IOW('s',  0, u_long)
-#define SIOCGHIWAT                 _IOR('s',  1, u_long)
-#define SIOCSLOWAT                 _IOW('s',  2, u_long)
-#define SIOCGLOWAT                 _IOR('s',  3, u_long)
-#define SIOCATMARK                 _IOR('s',  7, u_long)
-#else
-#define WS_FIONREAD                WS__IOR('f', 127, WS_u_long)
-#define WS_FIONBIO                 WS__IOW('f', 126, WS_u_long)
-#define WS_FIOASYNC                WS__IOW('f', 125, WS_u_long)
-#define WS_SIOCSHIWAT              WS__IOW('s',  0, WS_u_long)
-#define WS_SIOCGHIWAT              WS__IOR('s',  1, WS_u_long)
-#define WS_SIOCSLOWAT              WS__IOW('s',  2, WS_u_long)
-#define WS_SIOCGLOWAT              WS__IOR('s',  3, WS_u_long)
-#define WS_SIOCATMARK              WS__IOR('s',  7, WS_u_long)
+#define FIONREAD                   _IOR('f', 127, ULONG)
+#define FIONBIO                    _IOW('f', 126, ULONG)
+#define FIOASYNC                   _IOW('f', 125, ULONG)
+#define SIOCSHIWAT                 _IOW('s',  0, ULONG)
+#define SIOCGHIWAT                 _IOR('s',  1, ULONG)
+#define SIOCSLOWAT                 _IOW('s',  2, ULONG)
+#define SIOCGLOWAT                 _IOR('s',  3, ULONG)
+#define SIOCATMARK                 _IOR('s',  7, ULONG)
+#else
+#define WS_FIONREAD                WS__IOR('f', 127, ULONG)
+#define WS_FIONBIO                 WS__IOW('f', 126, ULONG)
+#define WS_FIOASYNC                WS__IOW('f', 125, ULONG)
+#define WS_SIOCSHIWAT              WS__IOW('s',  0, ULONG)
+#define WS_SIOCGHIWAT              WS__IOR('s',  1, ULONG)
+#define WS_SIOCSLOWAT              WS__IOW('s',  2, ULONG)
+#define WS_SIOCGLOWAT              WS__IOR('s',  3, ULONG)
+#define WS_SIOCATMARK              WS__IOR('s',  7, ULONG)
 #endif
 
@@ -863,5 +859,5 @@
 /*
  * All Windows Sockets error constants are biased by WSABASEERR from
- * the "normal"
+ * the "normal". They are also defined in winerror.h.
  */
 #define WSABASEERR                 10000
@@ -1061,7 +1057,7 @@
 int WINAPI WS(getsockname)(SOCKET,struct WS(sockaddr)*,int*);
 int WINAPI WS(getsockopt)(SOCKET,int,int,char*,int*);
-WS(u_long) WINAPI WS(inet_addr)(const char*);
+ULONG WINAPI WS(inet_addr)(const char*);
 char* WINAPI WS(inet_ntoa)(struct WS(in_addr));
-int WINAPI WS(ioctlsocket)(SOCKET,LONG,WS(u_long)*);
+int WINAPI WS(ioctlsocket)(SOCKET,LONG,ULONG*);
 int WINAPI WS(listen)(SOCKET,int);
 int WINAPI WS(recv)(SOCKET,char*,int,int);
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/winsock2.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/winsock2.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/winsock2.h	(revision 28475)
@@ -154,5 +154,5 @@
 #define WS_SIO_ADDRESS_LIST_CHANGE            _WSAIO(WS_IOC_WS2,23)
 #define WS_SIO_QUERY_TARGET_PNP_HANDLE        _WSAIOR(WS_IOC_WS2,24)
-#define WS_SIO_GET_INTERFACE_LIST             WS__IOR('t', 127, WS_u_long)
+#define WS_SIO_GET_INTERFACE_LIST             WS__IOR('t', 127, ULONG)
 #else /* USE_WS_PREFIX */
 #undef IOC_VOID
@@ -190,5 +190,5 @@
 #define SIO_ADDRESS_LIST_CHANGE    _WSAIO(IOC_WS2,23)
 #define SIO_QUERY_TARGET_PNP_HANDLE _WSAIOR(IOC_WS2,24)
-#define SIO_GET_INTERFACE_LIST     _IOR ('t', 127, u_long)
+#define SIO_GET_INTERFACE_LIST     _IOR ('t', 127, ULONG)
 #endif /* USE_WS_PREFIX */
 
@@ -557,11 +557,11 @@
 typedef int (WINAPI *LPFN_GETSOCKNAME)(SOCKET,struct WS(sockaddr)*,int*);
 typedef int (WINAPI *LPFN_GETSOCKOPT)(SOCKET,int,int,char*,int*);
-typedef WS(u_long) (WINAPI *LPFN_HTONL)(WS(u_long));
+typedef ULONG (WINAPI *LPFN_HTONL)(ULONG);
 typedef WS(u_short) (WINAPI *LPFN_HTONS)(WS(u_short));
 typedef ULONG (WINAPI *LPFN_INET_ADDR)(const char*);
 typedef char* (WINAPI *LPFN_INET_NTOA)(struct WS(in_addr);
-typedef int (WINAPI *LPFN_IOCTLSOCKET)(SOCKET,LONG,WS(u_long)*);
+typedef int (WINAPI *LPFN_IOCTLSOCKET)(SOCKET,LONG,ULONG*);
 typedef int (WINAPI *LPFN_LISTEN)(SOCKET,int);
-typedef WS(u_long) (WINAPI *LPFN_NTOHL)(WS(u_long));
+typedef ULONG (WINAPI *LPFN_NTOHL)(ULONG);
 typedef WS(u_short) (WINAPI *LPFN_NTOHS)(WS(u_short));
 typedef int (WINAPI *LPFN_RECV)(SOCKET,char*,int,int);
@@ -609,5 +609,5 @@
 INT WINAPI WSAGetServiceClassNameByClassIdW(LPGUID,LPWSTR,LPDWORD);
 #define WSAGetServiceClassNameByClassId WINELIB_NAME_AW(WSAGetServiceClassNameByClassId)
-int WINAPI WSAHtonl(SOCKET,WS(u_long),WS(u_long)*);
+int WINAPI WSAHtonl(SOCKET,ULONG,ULONG*);
 int WINAPI WSAHtons(SOCKET,WS(u_short),WS(u_short)*);
 int WINAPI WSAInstallServiceClassA(LPWSASERVICECLASSINFOA);
@@ -623,5 +623,5 @@
 INT WINAPI WSALookupServiceNextW(HANDLE,DWORD,LPDWORD,LPWSAQUERYSETW);
 #define WSALookupServiceNext       WINELIB_NAME_AW(WSALookupServiceNext) 
-int WINAPI WSANtohl(SOCKET,WS(u_long),WS(u_long)*);
+int WINAPI WSANtohl(SOCKET,ULONG,ULONG*);
 int WINAPI WSANtohs(SOCKET,WS(u_short),WS(u_short)*);
 INT WINAPI WSAProviderConfigChange(LPHANDLE,LPWSAOVERLAPPED,LPWSAOVERLAPPED_COMPLETION_ROUTINE);
@@ -682,5 +682,5 @@
 typedef INT (WINAPI *LPFN_WSAGETSERVICECLASSNAMEBYCLASSIDW)(LPGUID,LPWSTR,LPDWORD);
 #define LPFN_WSAGETSERVICECLASSNAMEBYCLASSID WINELIB_NAME_AW(LPFN_WSAGETSERVICECLASSNAMEBYCLASSID)
-typedef int (WINAPI *LPFN_WSAHTONL)(SOCKET,WS(u_long),WS(u_long)*);
+typedef int (WINAPI *LPFN_WSAHTONL)(SOCKET,ULONG,ULONG*);
 typedef int (WINAPI *LPFN_WSAHTONS)(SOCKET,WS(u_short),WS(u_short)*);
 typedef int (WINAPI LPFN_WSAINSTALLSERVICECLASSA)(LPWSASERVICECLASSINFOA);
@@ -695,5 +695,5 @@
 typedef INT (WINAPI *LPFN_WSALOOKUPSERVICENEXTW)(HANDLE,DWORD,LPDWORD,LPWSAQUERYSETW);
 #define LPFN_WSALOOKUPSERVICENEXT WINELIB_NAME_AW(LPFN_WSALOOKUPSERVICENEXT)
-typedef int (WINAPI *LPFN_WSANTOHL)(SOCKET,WS(u_long),WS(u_long)*);
+typedef int (WINAPI *LPFN_WSANTOHL)(SOCKET,ULONG,ULONG*);
 typedef int (WINAPI *LPFN_WSANTOHS)(SOCKET,WS(u_short),WS(u_short)*);
 typedef INT (WINAPI *LPFN_WSAPROVIDERCONFIGCHANGE)(LPHANDLE,LPWSAOVERLAPPED,LPWSAOVERLAPPED_COMPLETION_ROUTINE);
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/winspool.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/winspool.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/winspool.h	(revision 28475)
@@ -29,4 +29,5 @@
  * of the LGPL is applied is otherwise unspecified.
  */
+
 #ifndef __WINE_WINSPOOL_H
 #define __WINE_WINSPOOL_H
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/winternl.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/winternl.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/winternl.h	(revision 28475)
@@ -1134,6 +1134,79 @@
 /* System Information Class 0x02 */
 
+/* Documented in "Windows NT/2000 Native API Reference" by Gary Nebbett. */
 typedef struct _SYSTEM_PERFORMANCE_INFORMATION {
-    BYTE Reserved1[312];
+    LARGE_INTEGER IdleTime;
+    LARGE_INTEGER ReadTransferCount;
+    LARGE_INTEGER WriteTransferCount;
+    LARGE_INTEGER OtherTransferCount;
+    ULONG ReadOperationCount;
+    ULONG WriteOperationCount;
+    ULONG OtherOperationCount;
+    ULONG AvailablePages;
+    ULONG TotalCommittedPages;
+    ULONG TotalCommitLimit;
+    ULONG PeakCommitment;
+    ULONG PageFaults;
+    ULONG WriteCopyFaults;
+    ULONG TransitionFaults;
+    ULONG Reserved1;
+    ULONG DemandZeroFaults;
+    ULONG PagesRead;
+    ULONG PageReadIos;
+    ULONG Reserved2[2];
+    ULONG PagefilePagesWritten;
+    ULONG PagefilePageWriteIos;
+    ULONG MappedFilePagesWritten;
+    ULONG MappedFilePageWriteIos;
+    ULONG PagedPoolUsage;
+    ULONG NonPagedPoolUsage;
+    ULONG PagedPoolAllocs;
+    ULONG PagedPoolFrees;
+    ULONG NonPagedPoolAllocs;
+    ULONG NonPagedPoolFrees;
+    ULONG TotalFreeSystemPtes;
+    ULONG SystemCodePage;
+    ULONG TotalSystemDriverPages;
+    ULONG TotalSystemCodePages;
+    ULONG SmallNonPagedLookasideListAllocateHits;
+    ULONG SmallPagedLookasideListAllocateHits;
+    ULONG Reserved3;
+    ULONG MmSystemCachePage;
+    ULONG PagedPoolPage;
+    ULONG SystemDriverPage;
+    ULONG FastReadNoWait;
+    ULONG FastReadWait;
+    ULONG FastReadResourceMiss;
+    ULONG FastReadNotPossible;
+    ULONG FastMdlReadNoWait;
+    ULONG FastMdlReadWait;
+    ULONG FastMdlReadResourceMiss;
+    ULONG FastMdlReadNotPossible;
+    ULONG MapDataNoWait;
+    ULONG MapDataWait;
+    ULONG MapDataNoWaitMiss;
+    ULONG MapDataWaitMiss;
+    ULONG PinMappedDataCount;
+    ULONG PinReadNoWait;
+    ULONG PinReadWait;
+    ULONG PinReadNoWaitMiss;
+    ULONG PinReadWaitMiss;
+    ULONG CopyReadNoWait;
+    ULONG CopyReadWait;
+    ULONG CopyReadNoWaitMiss;
+    ULONG CopyReadWaitMiss;
+    ULONG MdlReadNoWait;
+    ULONG MdlReadWait;
+    ULONG MdlReadNoWaitMiss;
+    ULONG MdlReadWaitMiss;
+    ULONG ReadAheadIos;
+    ULONG LazyWriteIos;
+    ULONG LazyWritePages;
+    ULONG DataFlushes;
+    ULONG DataPages;
+    ULONG ContextSwitches;
+    ULONG FirstLevelTbFills;
+    ULONG SecondLevelTbFills;
+    ULONG SystemCalls;
 } SYSTEM_PERFORMANCE_INFORMATION, *PSYSTEM_PERFORMANCE_INFORMATION;
 
@@ -1575,7 +1648,35 @@
 
 /* NtGlobalFlag bits */
+#define FLG_STOP_ON_EXCEPTION            0x00000001
+#define FLG_SHOW_LDR_SNAPS               0x00000002
+#define FLG_DEBUG_INITIAL_COMMAND        0x00000004
+#define FLG_STOP_ON_HUNG_GUI             0x00000008
 #define FLG_HEAP_ENABLE_TAIL_CHECK       0x00000010
 #define FLG_HEAP_ENABLE_FREE_CHECK       0x00000020
+#define FLG_HEAP_VALIDATE_PARAMETERS     0x00000040
+#define FLG_HEAP_VALIDATE_ALL            0x00000080
+#define FLG_APPLICATION_VERIFIER         0x00000100
+#define FLG_POOL_ENABLE_TAGGING          0x00000400
+#define FLG_HEAP_ENABLE_TAGGING          0x00000800
+#define FLG_USER_STACK_TRACE_DB          0x00001000
+#define FLG_KERNEL_STACK_TRACE_DB        0x00002000
+#define FLG_MAINTAIN_OBJECT_TYPELIST     0x00004000
+#define FLG_HEAP_ENABLE_TAG_BY_DLL       0x00008000
+#define FLG_DISABLE_STACK_EXTENSION      0x00010000
+#define FLG_ENABLE_CSRDEBUG              0x00020000
+#define FLG_ENABLE_KDEBUG_SYMBOL_LOAD    0x00040000
+#define FLG_DISABLE_PAGE_KERNEL_STACKS   0x00080000
+#define FLG_ENABLE_SYSTEM_CRIT_BREAKS    0x00100000
 #define FLG_HEAP_DISABLE_COALESCING      0x00200000
+#define FLG_ENABLE_CLOSE_EXCEPTIONS      0x00400000
+#define FLG_ENABLE_EXCEPTION_LOGGING     0x00800000
+#define FLG_ENABLE_HANDLE_TYPE_TAGGING   0x01000000
+#define FLG_HEAP_PAGE_ALLOCS             0x02000000
+#define FLG_DEBUG_INITIAL_COMMAND_EX     0x04000000
+#define FLG_DISABLE_DBGPRINT             0x08000000
+#define FLG_CRITSEC_EVENT_CREATION       0x10000000
+#define FLG_LDR_TOP_DOWN                 0x20000000
+#define FLG_ENABLE_HANDLE_EXCEPTIONS     0x40000000
+#define FLG_DISABLE_PROTDLLS             0x80000000
 
 /* Rtl*Registry* functions structs and defines */
@@ -1883,4 +1984,5 @@
 NTSYSAPI NTSTATUS  WINAPI LdrLockLoaderLock(ULONG,ULONG*,ULONG*);
 IMAGE_BASE_RELOCATION * WINAPI LdrProcessRelocationBlock(void*,UINT,USHORT*,INT_PTR);
+NTSYSAPI NTSTATUS  WINAPI LdrQueryImageFileExecutionOptions(const UNICODE_STRING*,LPCWSTR,ULONG,void*,ULONG,ULONG*);
 NTSYSAPI NTSTATUS  WINAPI LdrQueryProcessModuleInformation(SYSTEM_MODULE_INFORMATION*, ULONG, ULONG*);
 NTSYSAPI void      WINAPI LdrShutdownProcess(void);
@@ -1912,5 +2014,5 @@
 NTSYSAPI NTSTATUS  WINAPI NtContinue(PCONTEXT,BOOLEAN);
 NTSYSAPI NTSTATUS  WINAPI NtCreateDirectoryObject(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES);
-NTSYSAPI NTSTATUS  WINAPI NtCreateEvent(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES *,BOOLEAN,BOOLEAN);
+NTSYSAPI NTSTATUS  WINAPI NtCreateEvent(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES *,EVENT_TYPE,BOOLEAN);
 NTSYSAPI NTSTATUS  WINAPI NtCreateEventPair(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES);
 NTSYSAPI NTSTATUS  WINAPI NtCreateFile(PHANDLE,ACCESS_MASK,POBJECT_ATTRIBUTES,PIO_STATUS_BLOCK,PLARGE_INTEGER,ULONG,ULONG,ULONG,ULONG,PVOID,ULONG);
@@ -2254,4 +2356,5 @@
 NTSYSAPI NTSTATUS  WINAPI RtlGetOwnerSecurityDescriptor(PSECURITY_DESCRIPTOR,PSID *,PBOOLEAN);
 NTSYSAPI ULONG     WINAPI RtlGetProcessHeaps(ULONG,HANDLE*);
+NTSYSAPI DWORD     WINAPI RtlGetThreadErrorMode(void);
 NTSYSAPI NTSTATUS  WINAPI RtlGetSaclSecurityDescriptor(PSECURITY_DESCRIPTOR,PBOOLEAN,PACL *,PBOOLEAN);
 NTSYSAPI NTSTATUS  WINAPI RtlGetVersion(RTL_OSVERSIONINFOEXW*);
@@ -2345,4 +2448,5 @@
 NTSYSAPI void      WINAPI RtlSetLastWin32ErrorAndNtStatusFromNtStatus(NTSTATUS);
 NTSYSAPI NTSTATUS  WINAPI RtlSetSaclSecurityDescriptor(PSECURITY_DESCRIPTOR,BOOLEAN,PACL,BOOLEAN);
+NTSYSAPI NTSTATUS  WINAPI RtlSetThreadErrorMode(DWORD,LPDWORD);
 NTSYSAPI NTSTATUS  WINAPI RtlSetTimeZoneInformation(const RTL_TIME_ZONE_INFORMATION*);
 NTSYSAPI SIZE_T    WINAPI RtlSizeHeap(HANDLE,ULONG,const void*);
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/winuser.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/winuser.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/winuser.h	(revision 28475)
@@ -979,4 +979,12 @@
 /* a name change since win95 */
 #define EM_SETLIMITTEXT          EM_LIMITTEXT
+
+/* IMESTATUS type */
+#define EMSIS_COMPOSITIONSTRING 1
+
+/* IMESTATUS type specific data */
+#define EIMES_GETCOMPSTRATONCE         0x0001
+#define EIMES_CANCELCOMPSTRINFOCUS     0x0002
+#define EIMES_COMPLETECOMPSTRKILLFOCUS 0x0004
 
 /* EDITWORDBREAKPROC code values */
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/ws2ipdef.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/ws2ipdef.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/ws2ipdef.h	(revision 28475)
@@ -55,5 +55,5 @@
 typedef struct _INTERFACE_INFO
 {
-    WS(u_long)        iiFlags;             /* Interface flags */
+    ULONG             iiFlags;             /* Interface flags */
     WS(sockaddr_gen)  iiAddress;           /* Interface address */
     WS(sockaddr_gen)  iiBroadcastAddress;  /* Broadcast address */
@@ -158,6 +158,6 @@
     struct WS(in_addr) imsf_multiaddr;
     struct WS(in_addr) imsf_interface;
-    WS(u_long)         imsf_fmode;
-    WS(u_long)         imsf_numsrc;
+    ULONG              imsf_fmode;
+    ULONG              imsf_numsrc;
     struct WS(in_addr) imsf_slist[1];
 } WS(IP_MSFILTER), *WS(PIP_MSFILTER);
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wtypes.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wtypes.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wtypes.h	(revision 28475)
@@ -1,3 +1,3 @@
-/*** Autogenerated by WIDL 1.1.36 from ../../include/wtypes.idl - Do not edit ***/
+/*** Autogenerated by WIDL 1.1.43 from ../../include/wtypes.idl - Do not edit ***/
 
 #include <rpc.h>
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/libWine/cpmap.pl
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/libWine/cpmap.pl	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/libWine/cpmap.pl	(revision 28475)
@@ -177,11 +177,11 @@
 (
     "L"   => 1,    # Left-to-Right
-    "LRE" => 11,   # Left-to-Right Embedding
-    "LRO" => 11,   # Left-to-Right Override
+    "LRE" => 15,   # Left-to-Right Embedding
+    "LRO" => 15,   # Left-to-Right Override
     "R"   => 2,    # Right-to-Left
-    "AL"  => 2,    # Right-to-Left Arabic
-    "RLE" => 11,   # Right-to-Left Embedding
-    "RLO" => 11,   # Right-to-Left Override
-    "PDF" => 11,   # Pop Directional Format
+    "AL"  => 12,   # Right-to-Left Arabic
+    "RLE" => 15,   # Right-to-Left Embedding
+    "RLO" => 15,   # Right-to-Left Override
+    "PDF" => 15,   # Pop Directional Format
     "EN"  => 3,    # European Number
     "ES"  => 4,    # European Number Separator
@@ -189,6 +189,6 @@
     "AN"  => 6,    # Arabic Number
     "CS"  => 7,    # Common Number Separator
-    "NSM" => 0,    # Non-Spacing Mark
-    "BN"  => 0,    # Boundary Neutral
+    "NSM" => 13,   # Non-Spacing Mark
+    "BN"  => 14,   # Boundary Neutral
     "B"   => 8,    # Paragraph Separator
     "S"   => 9,    # Segment Separator
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/libWine/port.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/libWine/port.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/libWine/port.c	(revision 28475)
@@ -149,8 +149,8 @@
 __ASM_GLOBAL_FUNC( wine_call_on_stack,
                    "pushq %rbp\n\t"
-                   ".cfi_adjust_cfa_offset 8\n\t"
-                   ".cfi_rel_offset %rbp,0\n\t"
+                   __ASM_CFI(".cfi_adjust_cfa_offset 8\n\t")
+                   __ASM_CFI(".cfi_rel_offset %rbp,0\n\t")
                    "movq %rsp,%rbp\n\t"
-                   ".cfi_def_cfa_register %rbp\n\t"
+                   __ASM_CFI(".cfi_def_cfa_register %rbp\n\t")
                    "movq %rdi,%rax\n\t" /* func */
                    "movq %rsi,%rdi\n\t" /* arg */
@@ -159,8 +159,8 @@
                    "callq *%rax\n\t"    /* call func */
                    "movq %rbp,%rsp\n\t"
-                   ".cfi_def_cfa_register %rsp\n\t"
+                   __ASM_CFI(".cfi_def_cfa_register %rsp\n\t")
                    "popq %rbp\n\t"
-                   ".cfi_adjust_cfa_offset -8\n\t"
-                   ".cfi_same_value %rbp\n\t"
+                   __ASM_CFI(".cfi_adjust_cfa_offset -8\n\t")
+                   __ASM_CFI(".cfi_same_value %rbp\n\t")
                    "ret")
 #elif defined(__powerpc__) && defined(__GNUC__)
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/libWine/version.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/libWine/version.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/libWine/version.c	(revision 28475)
@@ -1,1 +1,1 @@
-const char wine_build[] = "wine-1.1.36";
+const char wine_build[] = "wine-1.1.43";
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/libWine/wctype.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/libWine/wctype.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/libWine/wctype.c	(revision 28475)
@@ -40,8 +40,8 @@
     0x3900, 0x1600, 0x3a00, 0x3b00, 0x3c00, 0x3d00, 0x3e00, 0x3f00,
     /* values */
-    0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
-    0x0020, 0x9068, 0x8028, 0x9028, 0xa028, 0x8028, 0x0020, 0x0020,
-    0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
-    0x0020, 0x0020, 0x0020, 0x0020, 0x8020, 0x8020, 0x8020, 0x9020,
+    0xe020, 0xe020, 0xe020, 0xe020, 0xe020, 0xe020, 0xe020, 0xe020,
+    0xe020, 0x9068, 0x8028, 0x9028, 0xa028, 0x8028, 0xe020, 0xe020,
+    0xe020, 0xe020, 0xe020, 0xe020, 0xe020, 0xe020, 0xe020, 0xe020,
+    0xe020, 0xe020, 0xe020, 0xe020, 0x8020, 0x8020, 0x8020, 0x9020,
     0xa048, 0xb010, 0xb010, 0x5010, 0x5010, 0x5010, 0xb010, 0xb010,
     0xb010, 0xb010, 0xb010, 0x4010, 0x7010, 0x4010, 0x7010, 0x7010,
@@ -55,11 +55,11 @@
     0x1102, 0x1102, 0x1102, 0x1102, 0x1102, 0x1102, 0x1102, 0x1102,
     0x1102, 0x1102, 0x1102, 0x1102, 0x1102, 0x1102, 0x1102, 0x1102,
-    0x1102, 0x1102, 0x1102, 0xb010, 0xb010, 0xb010, 0xb010, 0x0020,
-    0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x8028, 0x0020, 0x0020,
-    0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
-    0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
-    0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
+    0x1102, 0x1102, 0x1102, 0xb010, 0xb010, 0xb010, 0xb010, 0xe020,
+    0xe020, 0xe020, 0xe020, 0xe020, 0xe020, 0x8028, 0xe020, 0xe020,
+    0xe020, 0xe020, 0xe020, 0xe020, 0xe020, 0xe020, 0xe020, 0xe020,
+    0xe020, 0xe020, 0xe020, 0xe020, 0xe020, 0xe020, 0xe020, 0xe020,
+    0xe020, 0xe020, 0xe020, 0xe020, 0xe020, 0xe020, 0xe020, 0xe020,
     0x7048, 0xb010, 0x5010, 0x5010, 0x5010, 0x5010, 0xb010, 0xb010,
-    0xb010, 0xb010, 0x1102, 0xb010, 0xb010, 0x0000, 0xb010, 0xb010,
+    0xb010, 0xb010, 0x1102, 0xb010, 0xb010, 0xe000, 0xb010, 0xb010,
     0x5010, 0x5010, 0x3010, 0x3010, 0xb010, 0x1102, 0xb010, 0xb010,
     0xb010, 0x3010, 0x1102, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010,
@@ -136,18 +136,18 @@
     0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010,
     0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0112, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd112, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
     0x0000, 0x0000, 0x0000, 0x0000, 0xb010, 0xb010, 0x0000, 0x0000,
     0x0000, 0x0000, 0x1010, 0x1102, 0x1102, 0x1102, 0xb010, 0x0000,
@@ -184,6 +184,6 @@
     0x1101, 0x1102, 0x1101, 0x1102, 0x1101, 0x1102, 0x1101, 0x1102,
     0x1101, 0x1102, 0x1101, 0x1102, 0x1101, 0x1102, 0x1101, 0x1102,
-    0x1101, 0x1102, 0x1010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0000,
-    0x0010, 0x0010, 0x1101, 0x1102, 0x1101, 0x1102, 0x1101, 0x1102,
+    0x1101, 0x1102, 0x1010, 0xd010, 0xd010, 0xd010, 0xd010, 0x0000,
+    0xd010, 0xd010, 0x1101, 0x1102, 0x1101, 0x1102, 0x1101, 0x1102,
     0x1101, 0x1102, 0x1101, 0x1102, 0x1101, 0x1102, 0x1101, 0x1102,
     0x1101, 0x1102, 0x1101, 0x1102, 0x1101, 0x1102, 0x1101, 0x1102,
@@ -218,11 +218,11 @@
     0x1102, 0x1102, 0x1102, 0x1102, 0x1102, 0x1102, 0x1102, 0x1102,
     0x0000, 0x1010, 0xb010, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x2010, 0x0010,
-    0x2010, 0x0010, 0x0010, 0x2010, 0x0010, 0x0010, 0x2010, 0x0010,
+    0x0000, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0x2010, 0xd010,
+    0x2010, 0xd010, 0xd010, 0x2010, 0xd010, 0xd010, 0x2010, 0xd010,
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
     0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
@@ -233,58 +233,58 @@
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
     0x6000, 0x6000, 0x6000, 0x6000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x2010, 0x7010, 0x2010, 0xb010, 0xb010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x2010, 0x0000, 0x0000, 0x2010, 0x2010,
-    0x0000, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x2010, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0000,
+    0x0000, 0x0000, 0x0000, 0xc010, 0x7010, 0xc010, 0xb010, 0xb010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0xc010, 0x0000, 0x0000, 0xc010, 0xc010,
+    0x0000, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0xc010, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0x0000,
     0x6004, 0x6004, 0x6004, 0x6004, 0x6004, 0x6004, 0x6004, 0x6004,
-    0x6004, 0x6004, 0x5010, 0x6010, 0x6010, 0x2010, 0x2100, 0x2100,
-    0x0010, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2010, 0x2100, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x6000, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x2010, 0x2010, 0x0010,
-    0x0010, 0xb010, 0x0010, 0x0010, 0x0010, 0x0010, 0x2100, 0x2100,
+    0x6004, 0x6004, 0x5010, 0x6010, 0x6010, 0xc010, 0xc100, 0xc100,
+    0xd010, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc010, 0xc100, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0x6000, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xc010, 0xc010, 0xd010,
+    0xd010, 0xb010, 0xd010, 0xd010, 0xd010, 0xd010, 0xc100, 0xc100,
     0x3004, 0x3004, 0x3004, 0x3004, 0x3004, 0x3004, 0x3004, 0x3004,
-    0x3004, 0x3004, 0x2100, 0x2100, 0x2100, 0x2010, 0x2010, 0x2100,
-    0x2010, 0x2010, 0x2010, 0x2010, 0x2010, 0x2010, 0x2010, 0x2010,
-    0x2010, 0x2010, 0x2010, 0x2010, 0x2010, 0x2010, 0x0000, 0x0020,
-    0x2100, 0x0010, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0000, 0x0000, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x2100, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x3004, 0x3004, 0xc100, 0xc100, 0xc100, 0xc010, 0xc010, 0xc100,
+    0xc010, 0xc010, 0xc010, 0xc010, 0xc010, 0xc010, 0xc010, 0xc010,
+    0xc010, 0xc010, 0xc010, 0xc010, 0xc010, 0xc010, 0x0000, 0xe020,
+    0xc100, 0xd010, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0x0000, 0x0000, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xc100, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
     0x2004, 0x2004, 0x2004, 0x2004, 0x2004, 0x2004, 0x2004, 0x2004,
@@ -293,6 +293,6 @@
     0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
     0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x2010, 0x2010, 0xb010, 0xb010,
+    0x2100, 0x2100, 0x2100, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0x2010, 0x2010, 0xb010, 0xb010,
     0xb010, 0xb010, 0x2010, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
@@ -328,21 +328,21 @@
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0010, 0x0010, 0x1010, 0x1100, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x1100, 0x0000, 0x0000, 0x0010, 0x1100, 0x1010, 0x1010,
-    0x1010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x1010, 0x1010, 0x1010, 0x1010, 0x0010, 0x0000, 0x0000,
-    0x1100, 0x0010, 0x0010, 0x0010, 0x0010, 0x0000, 0x0000, 0x0000,
-    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x1100, 0x0010, 0x0010, 0x1010, 0x1010, 0x1004, 0x1004,
+    0x0000, 0xd010, 0xd010, 0x1010, 0x1100, 0x1100, 0x1100, 0x1100,
+    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
+    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
+    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
+    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
+    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
+    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
+    0x1100, 0x1100, 0x0000, 0x0000, 0xd010, 0x1100, 0x1010, 0x1010,
+    0x1010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0x1010, 0x1010, 0x1010, 0x1010, 0xd010, 0x0000, 0x0000,
+    0x1100, 0xd010, 0xd010, 0xd010, 0xd010, 0x0000, 0x0000, 0x0000,
+    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
+    0x1100, 0x1100, 0xd010, 0xd010, 0x1010, 0x1010, 0x1004, 0x1004,
     0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004,
     0x1010, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
     0x0000, 0x0000, 0x0000, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
-    0x0000, 0x0010, 0x1010, 0x1010, 0x0000, 0x1100, 0x1100, 0x1100,
+    0x0000, 0xd010, 0x1010, 0x1010, 0x0000, 0x1100, 0x1100, 0x1100,
     0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x0000, 0x0000, 0x1100,
     0x1100, 0x0000, 0x0000, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
@@ -351,14 +351,14 @@
     0x1100, 0x0000, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
     0x1100, 0x0000, 0x1100, 0x0000, 0x0000, 0x0000, 0x1100, 0x1100,
-    0x1100, 0x1100, 0x0000, 0x0000, 0x0010, 0x1100, 0x1010, 0x1010,
-    0x1010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0000, 0x0000, 0x1010,
-    0x1010, 0x0000, 0x0000, 0x1010, 0x1010, 0x0010, 0x1100, 0x0000,
+    0x1100, 0x1100, 0x0000, 0x0000, 0xd010, 0x1100, 0x1010, 0x1010,
+    0x1010, 0xd010, 0xd010, 0xd010, 0xd010, 0x0000, 0x0000, 0x1010,
+    0x1010, 0x0000, 0x0000, 0x1010, 0x1010, 0xd010, 0x1100, 0x0000,
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1010,
     0x0000, 0x0000, 0x0000, 0x0000, 0x1100, 0x1100, 0x0000, 0x1100,
-    0x1100, 0x1100, 0x0010, 0x0010, 0x0000, 0x0000, 0x1004, 0x1004,
+    0x1100, 0x1100, 0xd010, 0xd010, 0x0000, 0x0000, 0x1004, 0x1004,
     0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004,
     0x1100, 0x1100, 0x5010, 0x5010, 0x1010, 0x1010, 0x1010, 0x1010,
     0x1010, 0x1010, 0x1010, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0010, 0x0010, 0x1010, 0x0000, 0x1100, 0x1100, 0x1100,
+    0x0000, 0xd010, 0xd010, 0x1010, 0x0000, 0x1100, 0x1100, 0x1100,
     0x1100, 0x1100, 0x1100, 0x0000, 0x0000, 0x0000, 0x0000, 0x1100,
     0x1100, 0x0000, 0x0000, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
@@ -367,14 +367,14 @@
     0x1100, 0x0000, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
     0x1100, 0x0000, 0x1100, 0x1100, 0x0000, 0x1100, 0x1100, 0x0000,
-    0x1100, 0x1100, 0x0000, 0x0000, 0x0010, 0x0000, 0x1010, 0x1010,
-    0x1010, 0x0010, 0x0010, 0x0000, 0x0000, 0x0000, 0x0000, 0x0010,
-    0x0010, 0x0000, 0x0000, 0x0010, 0x0010, 0x0010, 0x0000, 0x0000,
+    0x1100, 0x1100, 0x0000, 0x0000, 0xd010, 0x0000, 0x1010, 0x1010,
+    0x1010, 0xd010, 0xd010, 0x0000, 0x0000, 0x0000, 0x0000, 0xd010,
+    0xd010, 0x0000, 0x0000, 0xd010, 0xd010, 0xd010, 0x0000, 0x0000,
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
     0x0000, 0x1100, 0x1100, 0x1100, 0x1100, 0x0000, 0x1100, 0x0000,
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1004, 0x1004,
     0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004,
-    0x0010, 0x0010, 0x1100, 0x1100, 0x1100, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0010, 0x0010, 0x1010, 0x0000, 0x1100, 0x1100, 0x1100,
+    0xd010, 0xd010, 0x1100, 0x1100, 0x1100, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0xd010, 0xd010, 0x1010, 0x0000, 0x1100, 0x1100, 0x1100,
     0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x0000, 0x1100,
     0x1100, 0x1100, 0x0000, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
@@ -383,14 +383,14 @@
     0x1100, 0x0000, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
     0x1100, 0x0000, 0x1100, 0x1100, 0x0000, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x1100, 0x0000, 0x0000, 0x0010, 0x1100, 0x1010, 0x1010,
-    0x1010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0000, 0x0010,
-    0x0010, 0x1010, 0x0000, 0x1010, 0x1010, 0x0010, 0x0000, 0x0000,
+    0x1100, 0x1100, 0x0000, 0x0000, 0xd010, 0x1100, 0x1010, 0x1010,
+    0x1010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0x0000, 0xd010,
+    0xd010, 0x1010, 0x0000, 0x1010, 0x1010, 0xd010, 0x0000, 0x0000,
     0x1100, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x1100, 0x1100, 0x0010, 0x0010, 0x0000, 0x0000, 0x1004, 0x1004,
+    0x1100, 0x1100, 0xd010, 0xd010, 0x0000, 0x0000, 0x1004, 0x1004,
     0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004,
     0x0000, 0x5010, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0010, 0x1010, 0x1010, 0x0000, 0x1100, 0x1100, 0x1100,
+    0x0000, 0xd010, 0x1010, 0x1010, 0x0000, 0x1100, 0x1100, 0x1100,
     0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x0000, 0x0000, 0x1100,
     0x1100, 0x0000, 0x0000, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
@@ -399,8 +399,8 @@
     0x1100, 0x0000, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
     0x1100, 0x0000, 0x1100, 0x1100, 0x0000, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x1100, 0x0000, 0x0000, 0x0010, 0x1100, 0x1010, 0x0010,
-    0x1010, 0x0010, 0x0010, 0x0010, 0x0000, 0x0000, 0x0000, 0x1010,
-    0x1010, 0x0000, 0x0000, 0x1010, 0x1010, 0x0010, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0010, 0x1010,
+    0x1100, 0x1100, 0x0000, 0x0000, 0xd010, 0x1100, 0x1010, 0xd010,
+    0x1010, 0xd010, 0xd010, 0xd010, 0x0000, 0x0000, 0x0000, 0x1010,
+    0x1010, 0x0000, 0x0000, 0x1010, 0x1010, 0xd010, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xd010, 0x1010,
     0x0000, 0x0000, 0x0000, 0x0000, 0x1100, 0x1100, 0x0000, 0x1100,
     0x1100, 0x1100, 0x0000, 0x0000, 0x0000, 0x0000, 0x1004, 0x1004,
@@ -408,5 +408,5 @@
     0x1010, 0x1100, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0010, 0x1100, 0x0000, 0x1100, 0x1100, 0x1100,
+    0x0000, 0x0000, 0xd010, 0x1100, 0x0000, 0x1100, 0x1100, 0x1100,
     0x1100, 0x1100, 0x1100, 0x0000, 0x0000, 0x0000, 0x1100, 0x1100,
     0x1100, 0x0000, 0x1100, 0x1100, 0x1100, 0x1100, 0x0000, 0x0000,
@@ -416,6 +416,6 @@
     0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
     0x1100, 0x1100, 0x0000, 0x0000, 0x0000, 0x0000, 0x1010, 0x1010,
-    0x0010, 0x1010, 0x1010, 0x0000, 0x0000, 0x0000, 0x1010, 0x1010,
-    0x1010, 0x0000, 0x1010, 0x1010, 0x1010, 0x0010, 0x0000, 0x0000,
+    0xd010, 0x1010, 0x1010, 0x0000, 0x0000, 0x0000, 0x1010, 0x1010,
+    0x1010, 0x0000, 0x1010, 0x1010, 0x1010, 0xd010, 0x0000, 0x0000,
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1010,
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
@@ -431,8 +431,8 @@
     0x1100, 0x0000, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
     0x1100, 0x1100, 0x1100, 0x1100, 0x0000, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x1100, 0x0000, 0x0000, 0x0000, 0x0000, 0x0010, 0x0010,
-    0x0010, 0x1010, 0x1010, 0x1010, 0x1010, 0x0000, 0x0010, 0x0010,
-    0x0010, 0x0000, 0x0010, 0x0010, 0x0010, 0x0010, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0010, 0x0010, 0x0000,
+    0x1100, 0x1100, 0x0000, 0x0000, 0x0000, 0x0000, 0xd010, 0xd010,
+    0xd010, 0x1010, 0x1010, 0x1010, 0x1010, 0x0000, 0xd010, 0xd010,
+    0xd010, 0x0000, 0xd010, 0xd010, 0xd010, 0xd010, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xd010, 0xd010, 0x0000,
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
     0x1100, 0x1100, 0x0000, 0x0000, 0x0000, 0x0000, 0x1004, 0x1004,
@@ -447,10 +447,10 @@
     0x1100, 0x0000, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
     0x1100, 0x1100, 0x1100, 0x1100, 0x0000, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x1100, 0x0000, 0x0000, 0x0010, 0x1100, 0x1010, 0x1010,
+    0x1100, 0x1100, 0x0000, 0x0000, 0xd010, 0x1100, 0x1010, 0x1010,
     0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x0000, 0x1010, 0x1010,
-    0x1010, 0x0000, 0x1010, 0x1010, 0x0010, 0x0010, 0x0000, 0x0000,
+    0x1010, 0x0000, 0x1010, 0x1010, 0xd010, 0xd010, 0x0000, 0x0000,
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1010, 0x1010, 0x0000,
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1100, 0x0000,
-    0x1100, 0x1100, 0x0010, 0x0010, 0x0000, 0x0000, 0x1004, 0x1004,
+    0x1100, 0x1100, 0xd010, 0xd010, 0x0000, 0x0000, 0x1004, 0x1004,
     0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004,
     0x0000, 0xb010, 0xb010, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
@@ -464,6 +464,6 @@
     0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
     0x1100, 0x1100, 0x0000, 0x0000, 0x0000, 0x0000, 0x1010, 0x1010,
-    0x1010, 0x0010, 0x0010, 0x0010, 0x0000, 0x0000, 0x1010, 0x1010,
-    0x1010, 0x0000, 0x1010, 0x1010, 0x1010, 0x0010, 0x0000, 0x0000,
+    0x1010, 0xd010, 0xd010, 0xd010, 0x0000, 0x0000, 0x1010, 0x1010,
+    0x1010, 0x0000, 0x1010, 0x1010, 0x1010, 0xd010, 0x0000, 0x0000,
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1010,
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
@@ -481,6 +481,6 @@
     0x1100, 0x1100, 0x1100, 0x1100, 0x0000, 0x1100, 0x0000, 0x0000,
     0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x0000,
-    0x0000, 0x0000, 0x0010, 0x0000, 0x0000, 0x0000, 0x0000, 0x1010,
-    0x1010, 0x1010, 0x0010, 0x0010, 0x0010, 0x0000, 0x0010, 0x0000,
+    0x0000, 0x0000, 0xd010, 0x0000, 0x0000, 0x0000, 0x0000, 0x1010,
+    0x1010, 0x1010, 0xd010, 0xd010, 0xd010, 0x0000, 0xd010, 0x0000,
     0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010,
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
@@ -494,8 +494,8 @@
     0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
     0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x0010, 0x1100, 0x1100, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0000, 0x0000, 0x0000, 0x0000, 0x5010,
-    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x1010,
+    0x1100, 0xd010, 0x1100, 0x1100, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0x0000, 0x0000, 0x0000, 0x0000, 0x5010,
+    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0x1010,
     0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004,
     0x1004, 0x1004, 0x1010, 0x1010, 0x0000, 0x0000, 0x0000, 0x0000,
@@ -510,8 +510,8 @@
     0x0000, 0x1100, 0x1100, 0x1100, 0x0000, 0x1100, 0x0000, 0x1100,
     0x0000, 0x0000, 0x1100, 0x1100, 0x0000, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x0010, 0x1100, 0x1100, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0000, 0x0010, 0x0010, 0x1100, 0x0000, 0x0000,
+    0x1100, 0xd010, 0x1100, 0x1100, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0x0000, 0xd010, 0xd010, 0x1100, 0x0000, 0x0000,
     0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x0000, 0x1010, 0x0000,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0000, 0x0000,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0x0000, 0x0000,
     0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004,
     0x1004, 0x1004, 0x0000, 0x0000, 0x1100, 0x1100, 0x0000, 0x0000,
@@ -523,9 +523,9 @@
     0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010,
     0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010,
-    0x0010, 0x0010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010,
+    0xd010, 0xd010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010,
     0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004,
     0x1004, 0x1004, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010,
-    0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x0010, 0x1010, 0x0010,
-    0x1010, 0x0010, 0xb010, 0xb010, 0xb010, 0xb010, 0x1010, 0x1010,
+    0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0xd010, 0x1010, 0xd010,
+    0x1010, 0xd010, 0xb010, 0xb010, 0xb010, 0xb010, 0x1010, 0x1010,
     0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
     0x0000, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
@@ -534,15 +534,15 @@
     0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
     0x1100, 0x1100, 0x1100, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x1010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x1010, 0x0010, 0x0010,
+    0x0000, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0x1010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0x1010, 0xd010, 0xd010,
     0x1100, 0x1100, 0x1100, 0x1100, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0000, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0000, 0x1010, 0x1010,
-    0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x0010, 0x1010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0x0000, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0x0000, 0x1010, 0x1010,
+    0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0xd010, 0x1010,
     0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x0000, 0x0000, 0x1010,
     0x1010, 0x1010, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
@@ -557,11 +557,11 @@
     0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
     0x1100, 0x1100, 0x0000, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
-    0x0000, 0x1100, 0x1100, 0x0000, 0x1010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x1010, 0x0010, 0x0000, 0x0000, 0x0000, 0x0010, 0x0010,
-    0x1010, 0x0010, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x1100, 0x1100, 0x0000, 0x1010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0x1010, 0xd010, 0x0000, 0x0000, 0x0000, 0xd010, 0xd010,
+    0x1010, 0xd010, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
     0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004,
     0x1004, 0x1004, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010,
     0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1010, 0x1010,
-    0x0010, 0x0010, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0xd010, 0xd010, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
@@ -659,5 +659,5 @@
     0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
     0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x1100, 0x1100, 0x0000, 0x0000, 0x0000, 0x0000, 0x0010,
+    0x1100, 0x1100, 0x1100, 0x0000, 0x0000, 0x0000, 0x0000, 0xd010,
     0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010,
     0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010,
@@ -778,30 +778,30 @@
     0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
     0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x0000, 0x1100, 0x1100,
-    0x1100, 0x1100, 0x0010, 0x0010, 0x0010, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x1100, 0x0010, 0x0010, 0x0010, 0x1010, 0x1010, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x1100, 0x0010, 0x0010, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x1100, 0x1100, 0xd010, 0xd010, 0xd010, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
+    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
+    0x1100, 0x1100, 0xd010, 0xd010, 0xd010, 0x1010, 0x1010, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
+    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
+    0x1100, 0x1100, 0xd010, 0xd010, 0x0000, 0x0000, 0x0000, 0x0000,
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
     0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
     0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x0000, 0x1100, 0x1100,
-    0x1100, 0x0000, 0x0010, 0x0010, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x1100, 0x1100, 0x1100, 0x1000, 0x1000, 0x1010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x1010, 0x1010,
-    0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x0010, 0x1010,
-    0x1010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x1010, 0x1010, 0x1010, 0x1010,
-    0x1010, 0x1010, 0x1010, 0x5010, 0x1100, 0x0010, 0x0000, 0x0000,
+    0x1100, 0x0000, 0xd010, 0xd010, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
+    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
+    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
+    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
+    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
+    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
+    0x1100, 0x1100, 0x1100, 0x1100, 0x1000, 0x1000, 0x1010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0x1010, 0x1010,
+    0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0xd010, 0x1010,
+    0x1010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0x1010, 0x1010, 0x1010, 0x1010,
+    0x1010, 0x1010, 0x1010, 0x5010, 0x1100, 0xd010, 0x0000, 0x0000,
     0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004,
     0x1004, 0x1004, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
@@ -809,5 +809,5 @@
     0xb010, 0xb010, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
     0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010,
-    0xb010, 0xb010, 0xb010, 0x0030, 0x0030, 0x0030, 0xa028, 0x0000,
+    0xb010, 0xb010, 0xb010, 0xd030, 0xd030, 0xd030, 0xa028, 0x0000,
     0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004,
     0x1004, 0x1004, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
@@ -829,5 +829,5 @@
     0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
     0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x0010, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x1100, 0xd010, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
@@ -844,8 +844,8 @@
     0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
     0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x0000, 0x0000, 0x0000,
-    0x0010, 0x0010, 0x0010, 0x1010, 0x1010, 0x1010, 0x1010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x1010, 0x1010, 0x0010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010,
-    0x1010, 0x0010, 0x0010, 0x0010, 0x0000, 0x0000, 0x0000, 0x0000,
+    0xd010, 0xd010, 0xd010, 0x1010, 0x1010, 0x1010, 0x1010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x1010, 0x1010, 0xd010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010,
+    0x1010, 0xd010, 0xd010, 0xd010, 0x0000, 0x0000, 0x0000, 0x0000,
     0xb010, 0x0000, 0x0000, 0x0000, 0xb010, 0xb010, 0x1004, 0x1004,
     0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004,
@@ -874,49 +874,49 @@
     0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
     0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x0010,
-    0x0010, 0x1010, 0x1010, 0x1010, 0x0000, 0x0000, 0x1010, 0x1010,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x1010, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x1100, 0x1100, 0x1100, 0x0010, 0x1010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x1010, 0x0010, 0x1010, 0x1010, 0x1010,
-    0x1010, 0x1010, 0x0010, 0x1010, 0x1010, 0x1100, 0x1100, 0x1100,
+    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0xd010,
+    0xd010, 0x1010, 0x1010, 0x1010, 0x0000, 0x0000, 0x1010, 0x1010,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0xd010, 0xd010, 0xd010, 0xd010, 0x1010, 0x1100, 0x1100, 0x1100,
+    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
+    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
+    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
+    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
+    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
+    0x1100, 0x1100, 0x1100, 0x1100, 0xd010, 0x1010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0x1010, 0xd010, 0x1010, 0x1010, 0x1010,
+    0x1010, 0x1010, 0xd010, 0x1010, 0x1010, 0x1100, 0x1100, 0x1100,
     0x1100, 0x1100, 0x1100, 0x1100, 0x0000, 0x0000, 0x0000, 0x0000,
     0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004, 0x1004,
     0x1004, 0x1004, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010,
     0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010,
-    0x1010, 0x1010, 0x1010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x1010, 0x1010, 0x1010, 0x1010,
+    0x1010, 0x1010, 0x1010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0x1010, 0x1010, 0x1010, 0x1010,
     0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x0000, 0x0000, 0x0000,
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
@@ -960,12 +960,12 @@
     0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010,
     0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0010, 0x0010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xd010, 0xd010,
     0x1101, 0x1102, 0x1101, 0x1102, 0x1101, 0x1102, 0x1101, 0x1102,
     0x1101, 0x1102, 0x1101, 0x1102, 0x1101, 0x1102, 0x1101, 0x1102,
@@ -1033,9 +1033,9 @@
     0x1101, 0x1101, 0x1101, 0x1101, 0x1101, 0xb010, 0xb010, 0x0000,
     0xa008, 0xa008, 0xa008, 0xa008, 0xa008, 0xa008, 0xa008, 0xa008,
-    0xa008, 0xa008, 0xa008, 0x0000, 0x0020, 0x0020, 0x1020, 0x2020,
-    0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010,
-    0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010,
-    0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010,
-    0xa008, 0x8008, 0xb020, 0xb020, 0xb020, 0xb020, 0xb020, 0x7008,
+    0xa008, 0xa008, 0xa008, 0xe000, 0xe020, 0xe020, 0x1020, 0x2020,
+    0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010,
+    0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010,
+    0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010,
+    0xa008, 0x8008, 0xf020, 0xf020, 0xf020, 0xf020, 0xf020, 0x7008,
     0x5010, 0x5010, 0x5010, 0x5010, 0x5010, 0xb010, 0xb010, 0xb010,
     0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010,
@@ -1044,6 +1044,6 @@
     0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010,
     0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xa008,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
+    0xe000, 0xe000, 0xe000, 0xe000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0xe020, 0xe020, 0xe020, 0xe020, 0xe020, 0xe020,
     0x3010, 0x1102, 0x0000, 0x0000, 0x3010, 0x3010, 0x3010, 0x3010,
     0x3010, 0x3010, 0x4010, 0x4010, 0xb010, 0xb010, 0xb010, 0x1102,
@@ -1058,8 +1058,8 @@
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
@@ -1485,5 +1485,5 @@
     0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010,
     0xb010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010,
-    0x1010, 0x1010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
+    0x1010, 0x1010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
     0xb010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0xb010, 0xb010,
     0x1010, 0x1010, 0x1010, 0x1010, 0x1100, 0xb010, 0xb010, 0xb010,
@@ -1499,5 +1499,5 @@
     0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
     0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x0000,
-    0x0000, 0x0010, 0x0010, 0xb010, 0xb010, 0x1010, 0x1010, 0x1100,
+    0x0000, 0xd010, 0xd010, 0xb010, 0xb010, 0x1010, 0x1010, 0x1100,
     0xb010, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
     0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
@@ -1768,9 +1768,9 @@
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x1100, 0x1100, 0x0010, 0x1100, 0x1100, 0x1100, 0x0010, 0x1100,
-    0x1100, 0x1100, 0x1100, 0x0010, 0x1100, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
-    0x1100, 0x1100, 0x1100, 0x1010, 0x1010, 0x0010, 0x0010, 0x1010,
+    0x1100, 0x1100, 0xd010, 0x1100, 0x1100, 0x1100, 0xd010, 0x1100,
+    0x1100, 0x1100, 0x1100, 0xd010, 0x1100, 0x1100, 0x1100, 0x1100,
+    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
+    0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100, 0x1100,
+    0x1100, 0x1100, 0x1100, 0x1010, 0x1010, 0xd010, 0xd010, 0x1010,
     0xb010, 0xb010, 0xb010, 0xb010, 0x0000, 0x0000, 0x0000, 0x0000,
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
@@ -1899,5 +1899,5 @@
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
     0x0000, 0x0000, 0x0000, 0x1102, 0x1102, 0x1102, 0x1102, 0x1102,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2100, 0x0010, 0x2100,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2100, 0xd010, 0x2100,
     0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
     0x2100, 0x4010, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
@@ -1906,95 +1906,95 @@
     0x2100, 0x2100, 0x0000, 0x2100, 0x2100, 0x0000, 0x2100, 0x2100,
     0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0xb010, 0xb010,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x0000, 0x0000, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2010, 0xb010, 0x0000, 0x0000,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xb010, 0xb010,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0x0000, 0x0000, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc010, 0xb010, 0x0000, 0x0000,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
+    0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010, 0xd010,
     0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010,
     0xb010, 0xb010, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0010, 0x0010, 0x0010, 0x0010, 0x0000, 0x0000, 0x0000, 0x0000,
+    0xd010, 0xd010, 0xd010, 0xd010, 0x0000, 0x0000, 0x0000, 0x0000,
     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
     0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010, 0xb010,
@@ -2006,22 +2006,22 @@
     0xb010, 0xb010, 0x4010, 0x4010, 0xb010, 0xb010, 0xb010, 0x0000,
     0xb010, 0x5010, 0x5010, 0xb010, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x0000, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x2100,
-    0x2100, 0x2100, 0x2100, 0x2100, 0x2100, 0x0000, 0x0000, 0x0060,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0x0000, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0xc100,
+    0xc100, 0xc100, 0xc100, 0xc100, 0xc100, 0x0000, 0x0000, 0xe060,
     0x0000, 0xb010, 0xb010, 0x5010, 0x5010, 0x5010, 0xb010, 0xb010,
     0xb010, 0xb010, 0xb010, 0x4010, 0x7010, 0x4010, 0x7010, 0x7010,
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/arb_program_shader.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/arb_program_shader.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/arb_program_shader.c	(revision 28475)
@@ -51,4 +51,43 @@
 #define GLINFO_LOCATION      (*gl_info)
 
+/* Extract a line. Note that this modifies the source string. */
+static char *get_line(char **ptr)
+{
+    char *p, *q;
+
+    p = *ptr;
+    if (!(q = strstr(p, "\n")))
+    {
+        if (!*p) return NULL;
+        *ptr += strlen(p);
+        return p;
+    }
+    *q = '\0';
+    *ptr = q + 1;
+
+    return p;
+}
+
+static void shader_arb_dump_program_source(const char *source)
+{
+    unsigned long source_size;
+    char *ptr, *line, *tmp;
+
+    source_size = strlen(source) + 1;
+    tmp = HeapAlloc(GetProcessHeap(), 0, source_size);
+    if (!tmp)
+    {
+        ERR("Failed to allocate %lu bytes for shader source.\n", source_size);
+        return;
+    }
+    memcpy(tmp, source, source_size);
+
+    ptr = tmp;
+    while ((line = get_line(&ptr))) FIXME("    %s\n", line);
+    FIXME("\n");
+
+    HeapFree(GetProcessHeap(), 0, tmp);
+}
+
 /* GL locking for state handlers is done by the caller. */
 static BOOL need_mova_const(IWineD3DBaseShader *shader, const struct wined3d_gl_info *gl_info)
@@ -547,5 +586,5 @@
 static void shader_arb_load_constants(const struct wined3d_context *context, char usePixelShader, char useVertexShader)
 {
-    IWineD3DDeviceImpl *device = ((IWineD3DSurfaceImpl *)context->surface)->resource.device;
+    IWineD3DDeviceImpl *device = context->swapchain->device;
     IWineD3DStateBlockImpl* stateBlock = device->stateBlock;
     const struct wined3d_gl_info *gl_info = context->gl_info;
@@ -577,5 +616,5 @@
     /* We don't want shader constant dirtification to be an O(contexts), so just dirtify the active
      * context. On a context switch the old context will be fully dirtified */
-    if (!context || ((IWineD3DSurfaceImpl *)context->surface)->resource.device != This) return;
+    if (!context || context->swapchain->device != This) return;
 
     memset(context->vshader_const_dirty + start, 1, sizeof(*context->vshader_const_dirty) * count);
@@ -590,5 +629,5 @@
     /* We don't want shader constant dirtification to be an O(contexts), so just dirtify the active
      * context. On a context switch the old context will be fully dirtified */
-    if (!context || ((IWineD3DSurfaceImpl *)context->surface)->resource.device != This) return;
+    if (!context || context->swapchain->device != This) return;
 
     memset(context->pshader_const_dirty + start, 1, sizeof(*context->pshader_const_dirty) * count);
@@ -1132,8 +1171,8 @@
     DWORD mask;
 
-    if (is_yuv_fixup(fixup))
-    {
-        enum yuv_fixup yuv_fixup = get_yuv_fixup(fixup);
-        FIXME("YUV fixup (%#x) not supported\n", yuv_fixup);
+    if (is_complex_fixup(fixup))
+    {
+        enum complex_fixup complex_fixup = get_complex_fixup(fixup);
+        FIXME("Complex fixup (%#x) not supported\n", complex_fixup);
         return;
     }
@@ -1771,6 +1810,6 @@
 static void pshader_hw_tex(const struct wined3d_shader_instruction *ins)
 {
-    IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader;
-    IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
+    IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
+    IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device;
     const struct wined3d_shader_dst_param *dst = &ins->dst[0];
     DWORD shader_version = WINED3D_SHADER_VERSION(ins->ctx->reg_maps->shader_version.major,
@@ -1866,6 +1905,6 @@
 {
      struct wined3d_shader_buffer *buffer = ins->ctx->buffer;
-     IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader;
-     IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
+     IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
+     IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device;
      DWORD flags;
 
@@ -1914,5 +1953,6 @@
 static void pshader_hw_texbem(const struct wined3d_shader_instruction *ins)
 {
-    IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader;
+    IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
+    IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)shader->baseShader.device;
     const struct wined3d_shader_dst_param *dst = &ins->dst[0];
     struct wined3d_shader_buffer *buffer = ins->ctx->buffer;
@@ -1946,6 +1986,6 @@
      * so we can't let the GL handle this.
      */
-    if (((IWineD3DDeviceImpl*) This->baseShader.device)->stateBlock->textureState[reg_dest_code][WINED3DTSS_TEXTURETRANSFORMFLAGS]
-            & WINED3DTTFF_PROJECTED) {
+    if (device->stateBlock->textureState[reg_dest_code][WINED3DTSS_TEXTURETRANSFORMFLAGS] & WINED3DTTFF_PROJECTED)
+    {
         shader_addline(buffer, "RCP TB.w, %s.w;\n", reg_coord);
         shader_addline(buffer, "MUL TB.xy, %s, TB.w;\n", reg_coord);
@@ -1985,6 +2025,6 @@
 static void pshader_hw_texm3x2tex(const struct wined3d_shader_instruction *ins)
 {
-    IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader;
-    IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
+    IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
+    IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device;
     DWORD flags;
     DWORD reg = ins->dst[0].reg.idx;
@@ -2007,8 +2047,8 @@
 static void pshader_hw_texm3x3pad(const struct wined3d_shader_instruction *ins)
 {
-    IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader;
+    IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
+    SHADER_PARSE_STATE *current_state = &shader->baseShader.parse_state;
     DWORD reg = ins->dst[0].reg.idx;
     struct wined3d_shader_buffer *buffer = ins->ctx->buffer;
-    SHADER_PARSE_STATE* current_state = &This->baseShader.parse_state;
     char src0_name[50], dst_name[50];
     struct wined3d_shader_register tmp_reg = ins->dst[0].reg;
@@ -2030,10 +2070,10 @@
 static void pshader_hw_texm3x3tex(const struct wined3d_shader_instruction *ins)
 {
-    IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader;
-    IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
+    IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
+    IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device;
+    SHADER_PARSE_STATE *current_state = &shader->baseShader.parse_state;
     DWORD flags;
     DWORD reg = ins->dst[0].reg.idx;
     struct wined3d_shader_buffer *buffer = ins->ctx->buffer;
-    SHADER_PARSE_STATE* current_state = &This->baseShader.parse_state;
     char dst_str[50];
     char src0_name[50], dst_name[50];
@@ -2053,10 +2093,10 @@
 static void pshader_hw_texm3x3vspec(const struct wined3d_shader_instruction *ins)
 {
-    IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader;
-    IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
+    IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
+    IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device;
+    SHADER_PARSE_STATE *current_state = &shader->baseShader.parse_state;
     DWORD flags;
     DWORD reg = ins->dst[0].reg.idx;
     struct wined3d_shader_buffer *buffer = ins->ctx->buffer;
-    SHADER_PARSE_STATE* current_state = &This->baseShader.parse_state;
     char dst_str[50];
     char src0_name[50];
@@ -2095,9 +2135,9 @@
 static void pshader_hw_texm3x3spec(const struct wined3d_shader_instruction *ins)
 {
-    IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader;
-    IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
+    IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
+    IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device;
+    SHADER_PARSE_STATE *current_state = &shader->baseShader.parse_state;
     DWORD flags;
     DWORD reg = ins->dst[0].reg.idx;
-    SHADER_PARSE_STATE* current_state = &This->baseShader.parse_state;
     struct wined3d_shader_buffer *buffer = ins->ctx->buffer;
     char dst_str[50];
@@ -3056,6 +3096,7 @@
     if (pos != -1)
     {
-        FIXME("Vertex program error at position %d: %s\n", pos,
+        FIXME("Vertex program error at position %d: %s\n\n", pos,
             debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
+        shader_arb_dump_program_source(blt_vprogram);
     }
     else
@@ -3118,6 +3159,7 @@
     if (pos != -1)
     {
-        FIXME("Fragment program error at position %d: %s\n", pos,
+        FIXME("Fragment program error at position %d: %s\n\n", pos,
             debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
+        shader_arb_dump_program_source(blt_fprograms[tex_type]);
     }
     else
@@ -3574,6 +3616,7 @@
     if (errPos != -1)
     {
-        FIXME("HW PixelShader Error at position %d: %s\n",
+        FIXME("HW PixelShader Error at position %d: %s\n\n",
               errPos, debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
+        shader_arb_dump_program_source(buffer->buffer);
         retval = 0;
     }
@@ -3984,6 +4027,7 @@
     if (errPos != -1)
     {
-        FIXME("HW VertexShader Error at position %d: %s\n",
+        FIXME("HW VertexShader Error at position %d: %s\n\n",
               errPos, debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
+        shader_arb_dump_program_source(buffer->buffer);
         ret = -1;
     }
@@ -4305,5 +4349,5 @@
 static void shader_arb_select(const struct wined3d_context *context, BOOL usePS, BOOL useVS)
 {
-    IWineD3DDeviceImpl *This = ((IWineD3DSurfaceImpl *)context->surface)->resource.device;
+    IWineD3DDeviceImpl *This = context->swapchain->device;
     struct shader_arb_priv *priv = This->shader_priv;
     const struct wined3d_gl_info *gl_info = context->gl_info;
@@ -4458,6 +4502,5 @@
     if (shader_is_pshader_version(baseShader->baseShader.reg_maps.shader_version.type))
     {
-        IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *) iface;
-        struct arb_pshader_private *shader_data = This->baseShader.backend_data;
+        struct arb_pshader_private *shader_data = baseShader->baseShader.backend_data;
         UINT i;
 
@@ -4481,8 +4524,9 @@
         HeapFree(GetProcessHeap(), 0, shader_data->gl_shaders);
         HeapFree(GetProcessHeap(), 0, shader_data);
-        This->baseShader.backend_data = NULL;
-    } else {
-        IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *) iface;
-        struct arb_vshader_private *shader_data = This->baseShader.backend_data;
+        baseShader->baseShader.backend_data = NULL;
+    }
+    else
+    {
+        struct arb_vshader_private *shader_data = baseShader->baseShader.backend_data;
         UINT i;
 
@@ -4506,5 +4550,5 @@
         HeapFree(GetProcessHeap(), 0, shader_data->gl_shaders);
         HeapFree(GetProcessHeap(), 0, shader_data);
-        This->baseShader.backend_data = NULL;
+        baseShader->baseShader.backend_data = NULL;
     }
 }
@@ -4575,6 +4619,5 @@
 }
 
-static void shader_arb_get_caps(WINED3DDEVTYPE devtype, const struct wined3d_gl_info *gl_info,
-        struct shader_caps *pCaps)
+static void shader_arb_get_caps(const struct wined3d_gl_info *gl_info, struct shader_caps *pCaps)
 {
     DWORD vs_consts = min(gl_info->limits.arb_vs_float_constants, gl_info->limits.arb_vs_native_constants);
@@ -4584,5 +4627,5 @@
      * then overwrite the shader specific ones
      */
-    none_shader_backend.shader_get_caps(devtype, gl_info, pCaps);
+    none_shader_backend.shader_get_caps(gl_info, pCaps);
 
     if (gl_info->supported[ARB_VERTEX_PROGRAM])
@@ -4640,6 +4683,6 @@
     }
 
-    /* We support everything except YUV conversions. */
-    if (!is_yuv_fixup(fixup))
+    /* We support everything except complex conversions. */
+    if (!is_complex_fixup(fixup))
     {
         TRACE("[OK]\n");
@@ -5244,5 +5287,5 @@
 }
 
-static void arbfp_get_caps(WINED3DDEVTYPE devtype, const struct wined3d_gl_info *gl_info, struct fragment_caps *caps)
+static void arbfp_get_caps(const struct wined3d_gl_info *gl_info, struct fragment_caps *caps)
 {
     caps->TextureOpCaps =  WINED3DTEXOPCAPS_DISABLE                     |
@@ -5344,7 +5387,6 @@
              * anyway
              */
-            if(!isStateDirty(context, STATE_PIXELSHADERCONSTANT)) {
-                device->StateTable[STATE_PIXELSHADERCONSTANT].apply(STATE_PIXELSHADERCONSTANT, stateblock, context);
-            }
+            if (!isStateDirty(context, STATE_PIXELSHADERCONSTANT))
+                stateblock_apply_state(STATE_PIXELSHADERCONSTANT, stateblock, context);
         }
 
@@ -5381,7 +5423,6 @@
              * isn't scheduled anyway
              */
-            if(!isStateDirty(context, STATE_PIXELSHADERCONSTANT)) {
-                device->StateTable[STATE_PIXELSHADERCONSTANT].apply(STATE_PIXELSHADERCONSTANT, stateblock, context);
-            }
+            if (!isStateDirty(context, STATE_PIXELSHADERCONSTANT))
+                stateblock_apply_state(STATE_PIXELSHADERCONSTANT, stateblock, context);
         }
 
@@ -5873,6 +5914,7 @@
     if (pos != -1)
     {
-        FIXME("Fragment program error at position %d: %s\n", pos,
+        FIXME("Fragment program error at position %d: %s\n\n", pos,
               debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
+        shader_arb_dump_program_source(buffer.buffer);
     }
     else
@@ -5973,11 +6015,8 @@
         device->shader_backend->shader_select(context, use_pshader, use_vshader);
 
-        if (!isStateDirty(context, STATE_VERTEXSHADERCONSTANT) && (use_vshader || use_pshader)) {
-            device->StateTable[STATE_VERTEXSHADERCONSTANT].apply(STATE_VERTEXSHADERCONSTANT, stateblock, context);
-        }
-    }
-    if(use_pshader) {
-        device->StateTable[STATE_PIXELSHADERCONSTANT].apply(STATE_PIXELSHADERCONSTANT, stateblock, context);
-    }
+        if (!isStateDirty(context, STATE_VERTEXSHADERCONSTANT) && (use_vshader || use_pshader))
+            stateblock_apply_state(STATE_VERTEXSHADERCONSTANT, stateblock, context);
+    }
+    if (use_pshader) stateblock_apply_state(STATE_PIXELSHADERCONSTANT, stateblock, context);
 }
 
@@ -6030,124 +6069,124 @@
 static const struct StateEntryTemplate arbfp_fragmentstate_template[] = {
     {STATE_RENDER(WINED3DRS_TEXTUREFACTOR),               { STATE_RENDER(WINED3DRS_TEXTUREFACTOR),              state_texfactor_arbfp   }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),           { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG1),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG2),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG0),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP),           { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG1),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG2),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG0),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(0, WINED3DTSS_RESULTARG),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),           { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG1),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG2),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG0),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP),           { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG1),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG2),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG0),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(0, WINED3DTSS_RESULTARG),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
     {STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),      { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),     set_bumpmat_arbfp       }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT01),      { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),     set_bumpmat_arbfp       }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT10),      { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),     set_bumpmat_arbfp       }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT11),      { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),     set_bumpmat_arbfp       }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT01),      { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT10),      { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT11),      { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
     {STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLSCALE),     { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLSCALE),    tex_bumpenvlum_arbfp    }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLOFFSET),    { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLSCALE),    tex_bumpenvlum_arbfp    }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP),           { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG1),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG2),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG0),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP),           { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG1),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG2),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG0),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(1, WINED3DTSS_RESULTARG),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLOFFSET),    { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLSCALE),    NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP),           { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG1),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG2),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG0),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP),           { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG1),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG2),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG0),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(1, WINED3DTSS_RESULTARG),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
     {STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),      { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),     set_bumpmat_arbfp       }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT01),      { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),     set_bumpmat_arbfp       }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT10),      { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),     set_bumpmat_arbfp       }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT11),      { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),     set_bumpmat_arbfp       }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT01),      { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT10),      { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT11),      { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
     {STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLSCALE),     { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLSCALE),    tex_bumpenvlum_arbfp    }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLOFFSET),    { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLSCALE),    tex_bumpenvlum_arbfp    }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP),           { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG1),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG2),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG0),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP),           { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG1),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG2),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG0),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(2, WINED3DTSS_RESULTARG),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLOFFSET),    { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLSCALE),    NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP),           { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG1),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG2),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG0),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP),           { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG1),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG2),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG0),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(2, WINED3DTSS_RESULTARG),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
     {STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),      { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),     set_bumpmat_arbfp       }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT01),      { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),     set_bumpmat_arbfp       }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT10),      { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),     set_bumpmat_arbfp       }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT11),      { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),     set_bumpmat_arbfp       }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT01),      { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT10),      { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT11),      { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
     {STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLSCALE),     { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLSCALE),    tex_bumpenvlum_arbfp    }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLOFFSET),    { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLSCALE),    tex_bumpenvlum_arbfp    }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP),           { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG1),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG2),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG0),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP),           { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG1),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG2),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG0),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(3, WINED3DTSS_RESULTARG),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLOFFSET),    { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLSCALE),    NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP),           { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG1),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG2),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG0),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP),           { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG1),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG2),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG0),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(3, WINED3DTSS_RESULTARG),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
     {STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),      { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),     set_bumpmat_arbfp       }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT01),      { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),     set_bumpmat_arbfp       }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT10),      { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),     set_bumpmat_arbfp       }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT11),      { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),     set_bumpmat_arbfp       }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT01),      { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT10),      { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT11),      { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
     {STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLSCALE),     { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLSCALE),    tex_bumpenvlum_arbfp    }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLOFFSET),    { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLSCALE),    tex_bumpenvlum_arbfp    }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP),           { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG1),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG2),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG0),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP),           { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG1),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG2),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG0),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(4, WINED3DTSS_RESULTARG),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLOFFSET),    { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLSCALE),    NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP),           { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG1),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG2),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG0),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP),           { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG1),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG2),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG0),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(4, WINED3DTSS_RESULTARG),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
     {STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),      { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),     set_bumpmat_arbfp       }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT01),      { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),     set_bumpmat_arbfp       }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT10),      { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),     set_bumpmat_arbfp       }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT11),      { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),     set_bumpmat_arbfp       }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT01),      { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT10),      { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT11),      { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
     {STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLSCALE),     { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLSCALE),    tex_bumpenvlum_arbfp    }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLOFFSET),    { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLSCALE),    tex_bumpenvlum_arbfp    }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP),           { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG1),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG2),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG0),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP),           { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG1),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG2),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG0),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(5, WINED3DTSS_RESULTARG),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLOFFSET),    { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLSCALE),    NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP),           { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG1),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG2),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG0),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP),           { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG1),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG2),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG0),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(5, WINED3DTSS_RESULTARG),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
     {STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),      { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),     set_bumpmat_arbfp       }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT01),      { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),     set_bumpmat_arbfp       }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT10),      { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),     set_bumpmat_arbfp       }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT11),      { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),     set_bumpmat_arbfp       }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT01),      { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT10),      { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT11),      { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
     {STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLSCALE),     { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLSCALE),    tex_bumpenvlum_arbfp    }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLOFFSET),    { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLSCALE),    tex_bumpenvlum_arbfp    }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP),           { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG1),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG2),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG0),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP),           { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG1),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG2),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG0),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(6, WINED3DTSS_RESULTARG),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLOFFSET),    { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLSCALE),    NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP),           { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG1),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG2),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG0),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP),           { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG1),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG2),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG0),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(6, WINED3DTSS_RESULTARG),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
     {STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),      { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),     set_bumpmat_arbfp       }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT01),      { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),     set_bumpmat_arbfp       }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT10),      { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),     set_bumpmat_arbfp       }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT11),      { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),     set_bumpmat_arbfp       }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT01),      { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT10),      { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT11),      { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
     {STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLSCALE),     { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLSCALE),    tex_bumpenvlum_arbfp    }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLOFFSET),    { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLSCALE),    tex_bumpenvlum_arbfp    }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP),           { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG1),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG2),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG0),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP),           { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG1),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG2),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG0),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(7, WINED3DTSS_RESULTARG),         { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLOFFSET),    { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLSCALE),    NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP),           { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG1),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG2),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG0),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP),           { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG1),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG2),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG0),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(7, WINED3DTSS_RESULTARG),         { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
     {STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),      { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),     set_bumpmat_arbfp       }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT01),      { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),     set_bumpmat_arbfp       }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT10),      { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),     set_bumpmat_arbfp       }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT11),      { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),     set_bumpmat_arbfp       }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT01),      { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT10),      { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT11),      { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
     {STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLSCALE),     { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLSCALE),    tex_bumpenvlum_arbfp    }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLOFFSET),    { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLSCALE),    tex_bumpenvlum_arbfp    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLOFFSET),    { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLSCALE),    NULL                    }, WINED3D_GL_EXT_NONE             },
     {STATE_SAMPLER(0),                                    { STATE_SAMPLER(0),                                   sampler_texdim          }, WINED3D_GL_EXT_NONE             },
     {STATE_SAMPLER(1),                                    { STATE_SAMPLER(1),                                   sampler_texdim          }, WINED3D_GL_EXT_NONE             },
@@ -6160,9 +6199,9 @@
     {STATE_PIXELSHADER,                                   { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
     {STATE_RENDER(WINED3DRS_FOGENABLE),                   { STATE_RENDER(WINED3DRS_FOGENABLE),                  state_arbfp_fog         }, WINED3D_GL_EXT_NONE             },
-    {STATE_RENDER(WINED3DRS_FOGTABLEMODE),                { STATE_RENDER(WINED3DRS_FOGENABLE),                  state_arbfp_fog         }, WINED3D_GL_EXT_NONE             },
-    {STATE_RENDER(WINED3DRS_FOGVERTEXMODE),               { STATE_RENDER(WINED3DRS_FOGENABLE),                  state_arbfp_fog         }, WINED3D_GL_EXT_NONE             },
+    {STATE_RENDER(WINED3DRS_FOGTABLEMODE),                { STATE_RENDER(WINED3DRS_FOGENABLE),                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_RENDER(WINED3DRS_FOGVERTEXMODE),               { STATE_RENDER(WINED3DRS_FOGENABLE),                  NULL                    }, WINED3D_GL_EXT_NONE             },
     {STATE_RENDER(WINED3DRS_FOGSTART),                    { STATE_RENDER(WINED3DRS_FOGSTART),                   state_fogstartend       }, WINED3D_GL_EXT_NONE             },
-    {STATE_RENDER(WINED3DRS_FOGEND),                      { STATE_RENDER(WINED3DRS_FOGSTART),                   state_fogstartend       }, WINED3D_GL_EXT_NONE             },
-    {STATE_RENDER(WINED3DRS_SRGBWRITEENABLE),             { STATE_PIXELSHADER,                                  fragment_prog_arbfp     }, WINED3D_GL_EXT_NONE             },
+    {STATE_RENDER(WINED3DRS_FOGEND),                      { STATE_RENDER(WINED3DRS_FOGSTART),                   NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_RENDER(WINED3DRS_SRGBWRITEENABLE),             { STATE_PIXELSHADER,                                  NULL                    }, WINED3D_GL_EXT_NONE             },
     {STATE_RENDER(WINED3DRS_FOGCOLOR),                    { STATE_RENDER(WINED3DRS_FOGCOLOR),                   state_fogcolor          }, WINED3D_GL_EXT_NONE             },
     {STATE_RENDER(WINED3DRS_FOGDENSITY),                  { STATE_RENDER(WINED3DRS_FOGDENSITY),                 state_fogdensity        }, WINED3D_GL_EXT_NONE             },
@@ -6195,4 +6234,6 @@
     GLenum uyvy_rect_shader, uyvy_2d_shader;
     GLenum yv12_rect_shader, yv12_2d_shader;
+    GLenum p8_rect_shader, p8_2d_shader;
+    GLuint palette_texture;
 };
 
@@ -6219,5 +6260,9 @@
     GL_EXTCALL(glDeleteProgramsARB(1, &priv->yv12_rect_shader));
     GL_EXTCALL(glDeleteProgramsARB(1, &priv->yv12_2d_shader));
-    checkGLcall("Delete yuv programs");
+    GL_EXTCALL(glDeleteProgramsARB(1, &priv->p8_rect_shader));
+    GL_EXTCALL(glDeleteProgramsARB(1, &priv->p8_2d_shader));
+    checkGLcall("Delete yuv and p8 programs");
+
+    if(priv->palette_texture) glDeleteTextures(1, &priv->palette_texture);
     LEAVE_GL();
 
@@ -6226,5 +6271,5 @@
 }
 
-static BOOL gen_planar_yuv_read(struct wined3d_shader_buffer *buffer, enum yuv_fixup yuv_fixup,
+static BOOL gen_planar_yuv_read(struct wined3d_shader_buffer *buffer, enum complex_fixup fixup,
         GLenum textype, char *luminance)
 {
@@ -6232,5 +6277,5 @@
     const char *tex, *texinstr;
 
-    if (yuv_fixup == YUV_FIXUP_UYVY) {
+    if (fixup == COMPLEX_FIXUP_UYVY) {
         chroma = 'x';
         *luminance = 'w';
@@ -6460,6 +6505,104 @@
 }
 
+static GLuint gen_p8_shader(IWineD3DDeviceImpl *device, GLenum textype)
+{
+    GLenum shader;
+    struct wined3d_shader_buffer buffer;
+    struct arbfp_blit_priv *priv = device->blit_priv;
+    GLint pos;
+
+    /* Shader header */
+    if (!shader_buffer_init(&buffer))
+    {
+        ERR("Failed to initialize shader buffer.\n");
+        return 0;
+    }
+
+    ENTER_GL();
+    GL_EXTCALL(glGenProgramsARB(1, &shader));
+    GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, shader));
+    LEAVE_GL();
+    if(!shader) {
+        shader_buffer_free(&buffer);
+        return 0;
+    }
+
+    shader_addline(&buffer, "!!ARBfp1.0\n");
+    shader_addline(&buffer, "TEMP index;\n");
+
+    /* { 255/256, 0.5/255*255/256, 0, 0 } */
+    shader_addline(&buffer, "PARAM constants = { 0.996, 0.00195, 0, 0 };\n");
+
+    /* The alpha-component contains the palette index */
+    if(textype == GL_TEXTURE_RECTANGLE_ARB)
+        shader_addline(&buffer, "TXP index, fragment.texcoord[0], texture[0], RECT;\n");
+    else
+        shader_addline(&buffer, "TEX index, fragment.texcoord[0], texture[0], 2D;\n");
+
+    /* Scale the index by 255/256 and add a bias of '0.5' in order to sample in the middle */
+    shader_addline(&buffer, "MAD index.a, index.a, constants.x, constants.y;\n");
+
+    /* Use the alpha-component as an index in the palette to get the final color */
+    shader_addline(&buffer, "TEX result.color, index.a, texture[1], 1D;\n");
+    shader_addline(&buffer, "END\n");
+
+    ENTER_GL();
+    GL_EXTCALL(glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
+            strlen(buffer.buffer), buffer.buffer));
+    checkGLcall("glProgramStringARB()");
+
+    glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos);
+    if (pos != -1)
+    {
+        FIXME("Fragment program error at position %d: %s\n\n", pos,
+              debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
+        shader_arb_dump_program_source(buffer.buffer);
+    }
+
+    if (textype == GL_TEXTURE_RECTANGLE_ARB)
+        priv->p8_rect_shader = shader;
+    else
+        priv->p8_2d_shader = shader;
+
+    shader_buffer_free(&buffer);
+    LEAVE_GL();
+
+    return shader;
+}
+
 /* Context activation is done by the caller. */
-static GLuint gen_yuv_shader(IWineD3DDeviceImpl *device, enum yuv_fixup yuv_fixup, GLenum textype)
+static void upload_palette(IWineD3DSurfaceImpl *surface)
+{
+    BYTE table[256][4];
+    IWineD3DDeviceImpl *device = surface->resource.device;
+    struct arbfp_blit_priv *priv = device->blit_priv;
+    BOOL colorkey = (surface->CKeyFlags & WINEDDSD_CKSRCBLT) ? TRUE : FALSE;
+
+    d3dfmt_p8_init_palette(surface, table, colorkey);
+
+    ENTER_GL();
+    if (!priv->palette_texture)
+        glGenTextures(1, &priv->palette_texture);
+
+    GL_EXTCALL(glActiveTextureARB(GL_TEXTURE1));
+    glBindTexture(GL_TEXTURE_1D, priv->palette_texture);
+
+    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+
+    glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+    /* Make sure we have discrete color levels. */
+    glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+    glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+    /* Upload the palette */
+    /* TODO: avoid unneeed uploads in the future by adding some SFLAG_PALETTE_DIRTY mechanism */
+    glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, table);
+
+    /* Switch back to unit 0 in which the 2D texture will be stored. */
+    GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0));
+    LEAVE_GL();
+}
+
+/* Context activation is done by the caller. */
+static GLuint gen_yuv_shader(IWineD3DDeviceImpl *device, enum complex_fixup yuv_fixup, GLenum textype)
 {
     GLenum shader;
@@ -6534,6 +6677,6 @@
     switch (yuv_fixup)
     {
-        case YUV_FIXUP_UYVY:
-        case YUV_FIXUP_YUY2:
+        case COMPLEX_FIXUP_UYVY:
+        case COMPLEX_FIXUP_YUY2:
             if (!gen_planar_yuv_read(&buffer, yuv_fixup, textype, &luminance_component))
             {
@@ -6543,5 +6686,5 @@
             break;
 
-        case YUV_FIXUP_YV12:
+        case COMPLEX_FIXUP_YV12:
             if (!gen_yv12_read(&buffer, textype, &luminance_component))
             {
@@ -6577,6 +6720,7 @@
     if (pos != -1)
     {
-        FIXME("Fragment program error at position %d: %s\n", pos,
+        FIXME("Fragment program error at position %d: %s\n\n", pos,
               debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
+        shader_arb_dump_program_source(buffer.buffer);
     }
     else
@@ -6594,18 +6738,20 @@
     switch (yuv_fixup)
     {
-        case YUV_FIXUP_YUY2:
+        case COMPLEX_FIXUP_YUY2:
             if (textype == GL_TEXTURE_RECTANGLE_ARB) priv->yuy2_rect_shader = shader;
             else priv->yuy2_2d_shader = shader;
             break;
 
-        case YUV_FIXUP_UYVY:
+        case COMPLEX_FIXUP_UYVY:
             if (textype == GL_TEXTURE_RECTANGLE_ARB) priv->uyvy_rect_shader = shader;
             else priv->uyvy_2d_shader = shader;
             break;
 
-        case YUV_FIXUP_YV12:
+        case COMPLEX_FIXUP_YV12:
             if (textype == GL_TEXTURE_RECTANGLE_ARB) priv->yv12_rect_shader = shader;
             else priv->yv12_2d_shader = shader;
             break;
+        default:
+            ERR("Unsupported complex fixup: %d\n", yuv_fixup);
     }
 
@@ -6614,17 +6760,17 @@
 
 /* Context activation is done by the caller. */
-static HRESULT arbfp_blit_set(IWineD3DDevice *iface, const struct GlPixelFormatDesc *format_desc,
-        GLenum textype, UINT width, UINT height)
+static HRESULT arbfp_blit_set(IWineD3DDevice *iface, IWineD3DSurfaceImpl *surface)
 {
     GLenum shader;
     IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) iface;
-    float size[4] = {width, height, 1, 1};
+    float size[4] = {surface->pow2Width, surface->pow2Height, 1, 1};
     struct arbfp_blit_priv *priv = device->blit_priv;
-    enum yuv_fixup yuv_fixup;
-
-    if (!is_yuv_fixup(format_desc->color_fixup))
+    enum complex_fixup fixup;
+    GLenum textype = surface->texture_target;
+
+    if (!is_complex_fixup(surface->resource.format_desc->color_fixup))
     {
         TRACE("Fixup:\n");
-        dump_color_fixup_desc(format_desc->color_fixup);
+        dump_color_fixup_desc(surface->resource.format_desc->color_fixup);
         /* Don't bother setting up a shader for unconverted formats */
         ENTER_GL();
@@ -6635,22 +6781,29 @@
     }
 
-    yuv_fixup = get_yuv_fixup(format_desc->color_fixup);
-
-    switch(yuv_fixup)
-    {
-        case YUV_FIXUP_YUY2:
+    fixup = get_complex_fixup(surface->resource.format_desc->color_fixup);
+
+    switch(fixup)
+    {
+        case COMPLEX_FIXUP_YUY2:
             shader = textype == GL_TEXTURE_RECTANGLE_ARB ? priv->yuy2_rect_shader : priv->yuy2_2d_shader;
             break;
 
-        case YUV_FIXUP_UYVY:
+        case COMPLEX_FIXUP_UYVY:
             shader = textype == GL_TEXTURE_RECTANGLE_ARB ? priv->uyvy_rect_shader : priv->uyvy_2d_shader;
             break;
 
-        case YUV_FIXUP_YV12:
+        case COMPLEX_FIXUP_YV12:
             shader = textype == GL_TEXTURE_RECTANGLE_ARB ? priv->yv12_rect_shader : priv->yv12_2d_shader;
             break;
 
+        case COMPLEX_FIXUP_P8:
+            shader = textype == GL_TEXTURE_RECTANGLE_ARB ? priv->p8_rect_shader : priv->p8_2d_shader;
+            if (!shader) shader = gen_p8_shader(device, textype);
+
+            upload_palette(surface);
+            break;
+
         default:
-            FIXME("Unsupported YUV fixup %#x, not setting a shader\n", yuv_fixup);
+            FIXME("Unsupported complex fixup %#x, not setting a shader\n", fixup);
             ENTER_GL();
             glEnable(textype);
@@ -6660,5 +6813,5 @@
     }
 
-    if (!shader) shader = gen_yuv_shader(device, yuv_fixup, textype);
+    if (!shader) shader = gen_yuv_shader(device, fixup, textype);
 
     ENTER_GL();
@@ -6697,15 +6850,32 @@
 }
 
-static BOOL arbfp_blit_color_fixup_supported(struct color_fixup_desc fixup)
-{
-    enum yuv_fixup yuv_fixup;
-
+static BOOL arbfp_blit_supported(const struct wined3d_gl_info *gl_info, enum blit_operation blit_op,
+                                 const RECT *src_rect, DWORD src_usage, WINED3DPOOL src_pool,
+                                 const struct wined3d_format_desc *src_format_desc,
+                                 const RECT *dst_rect, DWORD dst_usage, WINED3DPOOL dst_pool,
+                                 const struct wined3d_format_desc *dst_format_desc)
+{
+    enum complex_fixup src_fixup;
+
+    if (blit_op != BLIT_OP_BLIT)
+    {
+        TRACE("Unsupported blit_op=%d\n", blit_op);
+        return FALSE;
+    }
+
+    src_fixup = get_complex_fixup(src_format_desc->color_fixup);
     if (TRACE_ON(d3d_shader) && TRACE_ON(d3d))
     {
         TRACE("Checking support for fixup:\n");
-        dump_color_fixup_desc(fixup);
-    }
-
-    if (is_identity_fixup(fixup))
+        dump_color_fixup_desc(src_format_desc->color_fixup);
+    }
+
+    if (!is_identity_fixup(dst_format_desc->color_fixup))
+    {
+        TRACE("Destination fixups are not supported\n");
+        return FALSE;
+    }
+
+    if (is_identity_fixup(src_format_desc->color_fixup))
     {
         TRACE("[OK]\n");
@@ -6713,6 +6883,6 @@
     }
 
-    /* We only support YUV conversions. */
-    if (!is_yuv_fixup(fixup))
+     /* We only support YUV conversions. */
+    if (!is_complex_fixup(src_format_desc->color_fixup))
     {
         TRACE("[FAILED]\n");
@@ -6720,18 +6890,80 @@
     }
 
-    yuv_fixup = get_yuv_fixup(fixup);
-    switch(yuv_fixup)
-    {
-        case YUV_FIXUP_YUY2:
-        case YUV_FIXUP_UYVY:
-        case YUV_FIXUP_YV12:
+    switch(src_fixup)
+    {
+        case COMPLEX_FIXUP_YUY2:
+        case COMPLEX_FIXUP_UYVY:
+        case COMPLEX_FIXUP_YV12:
+        case COMPLEX_FIXUP_P8:
             TRACE("[OK]\n");
             return TRUE;
 
         default:
-            FIXME("Unsupported YUV fixup %#x\n", yuv_fixup);
+            FIXME("Unsupported YUV fixup %#x\n", src_fixup);
             TRACE("[FAILED]\n");
             return FALSE;
     }
+}
+
+HRESULT arbfp_blit_surface(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *src_surface, const RECT *src_rect,
+                           IWineD3DSurfaceImpl *dst_surface, const RECT *dst_rect_in, enum blit_operation blit_op,
+                           DWORD Filter)
+{
+    IWineD3DSwapChainImpl *dst_swapchain;
+    struct wined3d_context *context;
+    RECT dst_rect = *dst_rect_in;
+
+    /* Now load the surface */
+    surface_internal_preload((IWineD3DSurface *)src_surface, SRGB_RGB);
+
+    /* Activate the destination context, set it up for blitting */
+    context = context_acquire(device, (IWineD3DSurface *)dst_surface, CTXUSAGE_BLIT);
+
+    /* The coordinates of the ddraw front buffer are always fullscreen ('screen coordinates',
+     * while OpenGL coordinates are window relative.
+     * Also beware of the origin difference(top left vs bottom left).
+     * Also beware that the front buffer's surface size is screen width x screen height,
+     * whereas the real gl drawable size is the size of the window. */
+    dst_swapchain = (dst_surface->Flags & SFLAG_SWAPCHAIN) ? (IWineD3DSwapChainImpl *)dst_surface->container : NULL;
+    if (dst_swapchain && (IWineD3DSurface *)dst_surface == dst_swapchain->frontBuffer)
+    {
+        RECT windowsize;
+        POINT offset = {0,0};
+        UINT h;
+        ClientToScreen(context->win_handle, &offset);
+        GetClientRect(context->win_handle, &windowsize);
+        h = windowsize.bottom - windowsize.top;
+        dst_rect.left -= offset.x; dst_rect.right -=offset.x;
+        dst_rect.top -= offset.y; dst_rect.bottom -=offset.y;
+        dst_rect.top += dst_surface->currentDesc.Height - h; dst_rect.bottom += dst_surface->currentDesc.Height - h;
+    }
+
+    arbfp_blit_set((IWineD3DDevice *)device, src_surface);
+
+    ENTER_GL();
+
+    /* Draw a textured quad */
+    draw_textured_quad(src_surface, src_rect, &dst_rect, Filter);
+
+    LEAVE_GL();
+
+    /* Leave the opengl state valid for blitting */
+    arbfp_blit_unset((IWineD3DDevice *)device);
+
+    if (wined3d_settings.strict_draw_ordering || (dst_swapchain
+            && ((IWineD3DSurface *)dst_surface == dst_swapchain->frontBuffer
+            || dst_swapchain->num_contexts > 1)))
+        wglFlush(); /* Flush to ensure ordering across contexts. */
+
+    context_release(context);
+
+    IWineD3DSurface_ModifyLocation((IWineD3DSurface *)dst_surface, SFLAG_INDRAWABLE, TRUE);
+    return WINED3D_OK;
+}
+
+static HRESULT arbfp_blit_color_fill(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *dst_surface, const RECT *dst_rect, DWORD fill_color)
+{
+    FIXME("Color filling not implemented by arbfp_blit\n");
+    return WINED3DERR_INVALIDCALL;
 }
 
@@ -6741,5 +6973,6 @@
     arbfp_blit_set,
     arbfp_blit_unset,
-    arbfp_blit_color_fixup_supported,
+    arbfp_blit_supported,
+    arbfp_blit_color_fill
 };
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/ati_fragment_shader.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/ati_fragment_shader.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/ati_fragment_shader.c	(revision 28475)
@@ -917,7 +917,6 @@
         device->shader_backend->shader_select(context, FALSE, use_vshader);
 
-        if (!isStateDirty(context, STATE_VERTEXSHADERCONSTANT) && use_vshader) {
-            device->StateTable[STATE_VERTEXSHADERCONSTANT].apply(STATE_VERTEXSHADERCONSTANT, stateblock, context);
-        }
+        if (!isStateDirty(context, STATE_VERTEXSHADERCONSTANT) && use_vshader)
+            stateblock_apply_state(STATE_VERTEXSHADERCONSTANT, stateblock, context);
     }
 }
@@ -930,112 +929,112 @@
     {STATE_RENDER(WINED3DRS_FOGDENSITY),                  { STATE_RENDER(WINED3DRS_FOGDENSITY),                 state_fogdensity        }, WINED3D_GL_EXT_NONE             },
     {STATE_RENDER(WINED3DRS_FOGENABLE),                   { STATE_RENDER(WINED3DRS_FOGENABLE),                  state_fog_fragpart      }, WINED3D_GL_EXT_NONE             },
-    {STATE_RENDER(WINED3DRS_FOGTABLEMODE),                { STATE_RENDER(WINED3DRS_FOGENABLE),                  state_fog_fragpart      }, WINED3D_GL_EXT_NONE             },
-    {STATE_RENDER(WINED3DRS_FOGVERTEXMODE),               { STATE_RENDER(WINED3DRS_FOGENABLE),                  state_fog_fragpart      }, WINED3D_GL_EXT_NONE             },
+    {STATE_RENDER(WINED3DRS_FOGTABLEMODE),                { STATE_RENDER(WINED3DRS_FOGENABLE),                  NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_RENDER(WINED3DRS_FOGVERTEXMODE),               { STATE_RENDER(WINED3DRS_FOGENABLE),                  NULL                    }, WINED3D_GL_EXT_NONE             },
     {STATE_RENDER(WINED3DRS_FOGSTART),                    { STATE_RENDER(WINED3DRS_FOGSTART),                   state_fogstartend       }, WINED3D_GL_EXT_NONE             },
-    {STATE_RENDER(WINED3DRS_FOGEND),                      { STATE_RENDER(WINED3DRS_FOGSTART),                   state_fogstartend       }, WINED3D_GL_EXT_NONE             },
+    {STATE_RENDER(WINED3DRS_FOGEND),                      { STATE_RENDER(WINED3DRS_FOGSTART),                   NULL                    }, WINED3D_GL_EXT_NONE             },
     {STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),           { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG1),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG2),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG0),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP),           { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG1),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG2),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG0),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(0, WINED3DTSS_RESULTARG),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG1),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG2),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG0),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP),           { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG1),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG2),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG0),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(0, WINED3DTSS_RESULTARG),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
     {STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),      { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),     set_bumpmat             }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT01),      { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),     set_bumpmat             }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT10),      { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),     set_bumpmat             }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT11),      { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),     set_bumpmat             }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP),           { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG1),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG2),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG0),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP),           { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG1),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG2),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG0),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(1, WINED3DTSS_RESULTARG),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT01),      { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT10),      { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT11),      { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP),           { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG1),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG2),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG0),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP),           { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG1),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG2),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG0),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(1, WINED3DTSS_RESULTARG),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
     {STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),      { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),     set_bumpmat             }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT01),      { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),     set_bumpmat             }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT10),      { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),     set_bumpmat             }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT11),      { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),     set_bumpmat             }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP),           { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG1),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG2),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG0),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP),           { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG1),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG2),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG0),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(2, WINED3DTSS_RESULTARG),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT01),      { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT10),      { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT11),      { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP),           { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG1),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG2),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG0),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP),           { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG1),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG2),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG0),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(2, WINED3DTSS_RESULTARG),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
     {STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),      { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),     set_bumpmat             }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT01),      { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),     set_bumpmat             }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT10),      { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),     set_bumpmat             }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT11),      { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),     set_bumpmat             }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP),           { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG1),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG2),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG0),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP),           { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG1),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG2),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG0),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(3, WINED3DTSS_RESULTARG),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT01),      { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT10),      { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT11),      { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP),           { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG1),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG2),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG0),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP),           { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG1),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG2),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG0),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(3, WINED3DTSS_RESULTARG),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
     {STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),      { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),     set_bumpmat             }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT01),      { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),     set_bumpmat             }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT10),      { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),     set_bumpmat             }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT11),      { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),     set_bumpmat             }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP),           { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG1),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG2),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG0),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP),           { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG1),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG2),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG0),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(4, WINED3DTSS_RESULTARG),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT01),      { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT10),      { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT11),      { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP),           { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG1),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG2),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG0),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP),           { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG1),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG2),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG0),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(4, WINED3DTSS_RESULTARG),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
     {STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),      { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),     set_bumpmat             }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT01),      { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),     set_bumpmat             }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT10),      { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),     set_bumpmat             }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT11),      { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),     set_bumpmat             }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP),           { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG1),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG2),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG0),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP),           { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG1),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG2),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG0),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(5, WINED3DTSS_RESULTARG),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT01),      { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT10),      { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT11),      { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP),           { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG1),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG2),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG0),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP),           { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG1),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG2),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG0),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(5, WINED3DTSS_RESULTARG),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
     {STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),      { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),     set_bumpmat             }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT01),      { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),     set_bumpmat             }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT10),      { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),     set_bumpmat             }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT11),      { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),     set_bumpmat             }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP),           { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG1),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG2),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG0),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP),           { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG1),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG2),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG0),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(6, WINED3DTSS_RESULTARG),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT01),      { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT10),      { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT11),      { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP),           { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG1),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG2),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG0),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP),           { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG1),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG2),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG0),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(6, WINED3DTSS_RESULTARG),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
     {STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),      { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),     set_bumpmat             }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT01),      { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),     set_bumpmat             }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT10),      { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),     set_bumpmat             }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT11),      { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),     set_bumpmat             }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP),           { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG1),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG2),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG0),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP),           { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG1),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG2),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG0),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(7, WINED3DTSS_RESULTARG),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          set_tex_op_atifs        }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT01),      { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT10),      { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT11),      { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP),           { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG1),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG2),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG0),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP),           { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG1),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG2),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG0),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(7, WINED3DTSS_RESULTARG),         { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                    }, WINED3D_GL_EXT_NONE             },
     {STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),      { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),     set_bumpmat             }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT01),      { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),     set_bumpmat             }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT10),      { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),     set_bumpmat             }, WINED3D_GL_EXT_NONE             },
-    {STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT11),      { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),     set_bumpmat             }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT01),      { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT10),      { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
+    {STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT11),      { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),     NULL                    }, WINED3D_GL_EXT_NONE             },
     { STATE_SAMPLER(0),                                   { STATE_SAMPLER(0),                                   sampler_texdim          }, WINED3D_GL_EXT_NONE             },
     { STATE_SAMPLER(1),                                   { STATE_SAMPLER(1),                                   sampler_texdim          }, WINED3D_GL_EXT_NONE             },
@@ -1071,5 +1070,5 @@
 }
 
-static void atifs_get_caps(WINED3DDEVTYPE devtype, const struct wined3d_gl_info *gl_info, struct fragment_caps *caps)
+static void atifs_get_caps(const struct wined3d_gl_info *gl_info, struct fragment_caps *caps)
 {
     caps->TextureOpCaps =  WINED3DTEXOPCAPS_DISABLE                     |
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/baseshader.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/baseshader.c	(revision 28382)
+++ 	(revision )
@@ -1,1454 +1,0 @@
-/*
- * shaders implementation
- *
- * Copyright 2002-2003 Jason Edmeades
- * Copyright 2002-2003 Raphael Junqueira
- * Copyright 2004 Christian Costa
- * Copyright 2005 Oliver Stieber
- * Copyright 2006 Ivan Gyurdiev
- * Copyright 2007-2008 Stefan Dösinger for CodeWeavers
- * Copyright 2009 Henri Verbeet for CodeWeavers
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-/*
- * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
- * other than GPL or LGPL is available it will apply instead, Sun elects to use only
- * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
- * a choice of LGPL license versions is made available with the language indicating
- * that LGPLv2 or any later version may be used, or where a choice of which version
- * of the LGPL is applied is otherwise unspecified.
- */
-
-#include "config.h"
-#include "wine/port.h"
-#include <string.h>
-#include <stdio.h>
-#include "wined3d_private.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
-WINE_DECLARE_DEBUG_CHANNEL(d3d);
-
-static const char *shader_opcode_names[] =
-{
-    /* WINED3DSIH_ABS           */ "abs",
-    /* WINED3DSIH_ADD           */ "add",
-    /* WINED3DSIH_BEM           */ "bem",
-    /* WINED3DSIH_BREAK         */ "break",
-    /* WINED3DSIH_BREAKC        */ "breakc",
-    /* WINED3DSIH_BREAKP        */ "breakp",
-    /* WINED3DSIH_CALL          */ "call",
-    /* WINED3DSIH_CALLNZ        */ "callnz",
-    /* WINED3DSIH_CMP           */ "cmp",
-    /* WINED3DSIH_CND           */ "cnd",
-    /* WINED3DSIH_CRS           */ "crs",
-    /* WINED3DSIH_CUT           */ "cut",
-    /* WINED3DSIH_DCL           */ "dcl",
-    /* WINED3DSIH_DEF           */ "def",
-    /* WINED3DSIH_DEFB          */ "defb",
-    /* WINED3DSIH_DEFI          */ "defi",
-    /* WINED3DSIH_DP2ADD        */ "dp2add",
-    /* WINED3DSIH_DP3           */ "dp3",
-    /* WINED3DSIH_DP4           */ "dp4",
-    /* WINED3DSIH_DST           */ "dst",
-    /* WINED3DSIH_DSX           */ "dsx",
-    /* WINED3DSIH_DSY           */ "dsy",
-    /* WINED3DSIH_ELSE          */ "else",
-    /* WINED3DSIH_EMIT          */ "emit",
-    /* WINED3DSIH_ENDIF         */ "endif",
-    /* WINED3DSIH_ENDLOOP       */ "endloop",
-    /* WINED3DSIH_ENDREP        */ "endrep",
-    /* WINED3DSIH_EXP           */ "exp",
-    /* WINED3DSIH_EXPP          */ "expp",
-    /* WINED3DSIH_FRC           */ "frc",
-    /* WINED3DSIH_IADD          */ "iadd",
-    /* WINED3DSIH_IF            */ "if",
-    /* WINED3DSIH_IFC           */ "ifc",
-    /* WINED3DSIH_IGE           */ "ige",
-    /* WINED3DSIH_LABEL         */ "label",
-    /* WINED3DSIH_LIT           */ "lit",
-    /* WINED3DSIH_LOG           */ "log",
-    /* WINED3DSIH_LOGP          */ "logp",
-    /* WINED3DSIH_LOOP          */ "loop",
-    /* WINED3DSIH_LRP           */ "lrp",
-    /* WINED3DSIH_LT            */ "lt",
-    /* WINED3DSIH_M3x2          */ "m3x2",
-    /* WINED3DSIH_M3x3          */ "m3x3",
-    /* WINED3DSIH_M3x4          */ "m3x4",
-    /* WINED3DSIH_M4x3          */ "m4x3",
-    /* WINED3DSIH_M4x4          */ "m4x4",
-    /* WINED3DSIH_MAD           */ "mad",
-    /* WINED3DSIH_MAX           */ "max",
-    /* WINED3DSIH_MIN           */ "min",
-    /* WINED3DSIH_MOV           */ "mov",
-    /* WINED3DSIH_MOVA          */ "mova",
-    /* WINED3DSIH_MUL           */ "mul",
-    /* WINED3DSIH_NOP           */ "nop",
-    /* WINED3DSIH_NRM           */ "nrm",
-    /* WINED3DSIH_PHASE         */ "phase",
-    /* WINED3DSIH_POW           */ "pow",
-    /* WINED3DSIH_RCP           */ "rcp",
-    /* WINED3DSIH_REP           */ "rep",
-    /* WINED3DSIH_RET           */ "ret",
-    /* WINED3DSIH_RSQ           */ "rsq",
-    /* WINED3DSIH_SETP          */ "setp",
-    /* WINED3DSIH_SGE           */ "sge",
-    /* WINED3DSIH_SGN           */ "sgn",
-    /* WINED3DSIH_SINCOS        */ "sincos",
-    /* WINED3DSIH_SLT           */ "slt",
-    /* WINED3DSIH_SUB           */ "sub",
-    /* WINED3DSIH_TEX           */ "texld",
-    /* WINED3DSIH_TEXBEM        */ "texbem",
-    /* WINED3DSIH_TEXBEML       */ "texbeml",
-    /* WINED3DSIH_TEXCOORD      */ "texcrd",
-    /* WINED3DSIH_TEXDEPTH      */ "texdepth",
-    /* WINED3DSIH_TEXDP3        */ "texdp3",
-    /* WINED3DSIH_TEXDP3TEX     */ "texdp3tex",
-    /* WINED3DSIH_TEXKILL       */ "texkill",
-    /* WINED3DSIH_TEXLDD        */ "texldd",
-    /* WINED3DSIH_TEXLDL        */ "texldl",
-    /* WINED3DSIH_TEXM3x2DEPTH  */ "texm3x2depth",
-    /* WINED3DSIH_TEXM3x2PAD    */ "texm3x2pad",
-    /* WINED3DSIH_TEXM3x2TEX    */ "texm3x2tex",
-    /* WINED3DSIH_TEXM3x3       */ "texm3x3",
-    /* WINED3DSIH_TEXM3x3DIFF   */ "texm3x3diff",
-    /* WINED3DSIH_TEXM3x3PAD    */ "texm3x3pad",
-    /* WINED3DSIH_TEXM3x3SPEC   */ "texm3x3spec",
-    /* WINED3DSIH_TEXM3x3TEX    */ "texm3x3tex",
-    /* WINED3DSIH_TEXM3x3VSPEC  */ "texm3x3vspec",
-    /* WINED3DSIH_TEXREG2AR     */ "texreg2ar",
-    /* WINED3DSIH_TEXREG2GB     */ "texreg2gb",
-    /* WINED3DSIH_TEXREG2RGB    */ "texreg2rgb",
-};
-
-const struct wined3d_shader_frontend *shader_select_frontend(DWORD version_token)
-{
-    switch (version_token >> 16)
-    {
-        case WINED3D_SM1_VS:
-        case WINED3D_SM1_PS:
-            return &sm1_shader_frontend;
-
-        case WINED3D_SM4_PS:
-        case WINED3D_SM4_VS:
-        case WINED3D_SM4_GS:
-            return &sm4_shader_frontend;
-
-        default:
-            FIXME("Unrecognised version token %#x\n", version_token);
-            return NULL;
-    }
-}
-
-void shader_buffer_clear(struct wined3d_shader_buffer *buffer)
-{
-    buffer->buffer[0] = '\0';
-    buffer->bsize = 0;
-    buffer->lineNo = 0;
-    buffer->newline = TRUE;
-}
-
-BOOL shader_buffer_init(struct wined3d_shader_buffer *buffer)
-{
-    buffer->buffer = HeapAlloc(GetProcessHeap(), 0, SHADER_PGMSIZE);
-    if (!buffer->buffer)
-    {
-        ERR("Failed to allocate shader buffer memory.\n");
-        return FALSE;
-    }
-
-    shader_buffer_clear(buffer);
-    return TRUE;
-}
-
-void shader_buffer_free(struct wined3d_shader_buffer *buffer)
-{
-    HeapFree(GetProcessHeap(), 0, buffer->buffer);
-}
-
-int shader_vaddline(struct wined3d_shader_buffer *buffer, const char *format, va_list args)
-{
-    char* base = buffer->buffer + buffer->bsize;
-    int rc;
-
-    rc = vsnprintf(base, SHADER_PGMSIZE - 1 - buffer->bsize, format, args);
-
-    if (rc < 0 /* C89 */ || (unsigned int)rc > SHADER_PGMSIZE - 1 - buffer->bsize /* C99 */)
-    {
-        ERR("The buffer allocated for the shader program string "
-            "is too small at %d bytes.\n", SHADER_PGMSIZE);
-        buffer->bsize = SHADER_PGMSIZE - 1;
-        return -1;
-    }
-
-    if (buffer->newline) {
-        TRACE("GL HW (%u, %u) : %s", buffer->lineNo + 1, buffer->bsize, base);
-        buffer->newline = FALSE;
-    } else {
-        TRACE("%s", base);
-    }
-
-    buffer->bsize += rc;
-    if (buffer->buffer[buffer->bsize-1] == '\n') {
-        buffer->lineNo++;
-        buffer->newline = TRUE;
-    }
-    return 0;
-}
-
-int shader_addline(struct wined3d_shader_buffer *buffer, const char *format, ...)
-{
-    int ret;
-    va_list args;
-
-    va_start(args, format);
-    ret = shader_vaddline(buffer, format, args);
-    va_end(args);
-
-    return ret;
-}
-
-void shader_init(struct IWineD3DBaseShaderClass *shader, IWineD3DDeviceImpl *device,
-        IUnknown *parent, const struct wined3d_parent_ops *parent_ops)
-{
-    shader->ref = 1;
-    shader->device = (IWineD3DDevice *)device;
-    shader->parent = parent;
-    shader->parent_ops = parent_ops;
-    list_init(&shader->linked_programs);
-    list_add_head(&device->shaders, &shader->shader_list_entry);
-}
-
-/* Convert floating point offset relative
- * to a register file to an absolute offset for float constants */
-static unsigned int shader_get_float_offset(WINED3DSHADER_PARAM_REGISTER_TYPE register_type, UINT register_idx)
-{
-    switch (register_type)
-    {
-        case WINED3DSPR_CONST: return register_idx;
-        case WINED3DSPR_CONST2: return 2048 + register_idx;
-        case WINED3DSPR_CONST3: return 4096 + register_idx;
-        case WINED3DSPR_CONST4: return 6144 + register_idx;
-        default:
-            FIXME("Unsupported register type: %d\n", register_type);
-            return register_idx;
-    }
-}
-
-static void shader_delete_constant_list(struct list* clist) {
-
-    struct list *ptr;
-    struct local_constant* constant;
-
-    ptr = list_head(clist);
-    while (ptr) {
-        constant = LIST_ENTRY(ptr, struct local_constant, entry);
-        ptr = list_next(clist, ptr);
-        HeapFree(GetProcessHeap(), 0, constant);
-    }
-    list_init(clist);
-}
-
-static inline void set_bitmap_bit(DWORD *bitmap, DWORD bit)
-{
-    DWORD idx, shift;
-    idx = bit >> 5;
-    shift = bit & 0x1f;
-    bitmap[idx] |= (1 << shift);
-}
-
-static void shader_record_register_usage(IWineD3DBaseShaderImpl *This, struct shader_reg_maps *reg_maps,
-        const struct wined3d_shader_register *reg, enum wined3d_shader_type shader_type)
-{
-    switch (reg->type)
-    {
-        case WINED3DSPR_TEXTURE: /* WINED3DSPR_ADDR */
-            if (shader_type == WINED3D_SHADER_TYPE_PIXEL) reg_maps->texcoord |= 1 << reg->idx;
-            else reg_maps->address |= 1 << reg->idx;
-            break;
-
-        case WINED3DSPR_TEMP:
-            reg_maps->temporary |= 1 << reg->idx;
-            break;
-
-        case WINED3DSPR_INPUT:
-            if (shader_type == WINED3D_SHADER_TYPE_PIXEL)
-            {
-                if (reg->rel_addr)
-                {
-                    /* If relative addressing is used, we must assume that all registers
-                     * are used. Even if it is a construct like v3[aL], we can't assume
-                     * that v0, v1 and v2 aren't read because aL can be negative */
-                    unsigned int i;
-                    for (i = 0; i < MAX_REG_INPUT; ++i)
-                    {
-                        ((IWineD3DPixelShaderImpl *)This)->input_reg_used[i] = TRUE;
-                    }
-                }
-                else
-                {
-                    ((IWineD3DPixelShaderImpl *)This)->input_reg_used[reg->idx] = TRUE;
-                }
-            }
-            else reg_maps->input_registers |= 1 << reg->idx;
-            break;
-
-        case WINED3DSPR_RASTOUT:
-            if (reg->idx == 1) reg_maps->fog = 1;
-            break;
-
-        case WINED3DSPR_MISCTYPE:
-            if (shader_type == WINED3D_SHADER_TYPE_PIXEL)
-            {
-                if (reg->idx == 0) reg_maps->vpos = 1;
-                else if (reg->idx == 1) reg_maps->usesfacing = 1;
-            }
-            break;
-
-        case WINED3DSPR_CONST:
-            if (reg->rel_addr)
-            {
-                if (shader_type != WINED3D_SHADER_TYPE_PIXEL)
-                {
-                    if (reg->idx < ((IWineD3DVertexShaderImpl *)This)->min_rel_offset)
-                    {
-                        ((IWineD3DVertexShaderImpl *)This)->min_rel_offset = reg->idx;
-                    }
-                    if (reg->idx > ((IWineD3DVertexShaderImpl *)This)->max_rel_offset)
-                    {
-                        ((IWineD3DVertexShaderImpl *)This)->max_rel_offset = reg->idx;
-                    }
-                }
-                reg_maps->usesrelconstF = TRUE;
-            }
-            else
-            {
-                set_bitmap_bit(reg_maps->constf, reg->idx);
-            }
-            break;
-
-        case WINED3DSPR_CONSTINT:
-            reg_maps->integer_constants |= (1 << reg->idx);
-            break;
-
-        case WINED3DSPR_CONSTBOOL:
-            reg_maps->boolean_constants |= (1 << reg->idx);
-            break;
-
-        case WINED3DSPR_COLOROUT:
-            reg_maps->highest_render_target = max(reg_maps->highest_render_target, reg->idx);
-            break;
-
-        default:
-            TRACE("Not recording register of type %#x and idx %u\n", reg->type, reg->idx);
-            break;
-    }
-}
-
-static unsigned int get_instr_extra_regcount(enum WINED3D_SHADER_INSTRUCTION_HANDLER instr, unsigned int param)
-{
-    switch(instr)
-    {
-        case WINED3DSIH_M4x4:
-        case WINED3DSIH_M3x4:
-            return param == 1 ? 3 : 0;
-
-        case WINED3DSIH_M4x3:
-        case WINED3DSIH_M3x3:
-            return param == 1 ? 2 : 0;
-
-        case WINED3DSIH_M3x2:
-            return param == 1 ? 1 : 0;
-
-        default:
-            return 0;
-    }
-}
-
-static const char *semantic_names[] =
-{
-    /* WINED3DDECLUSAGE_POSITION        */ "SV_POSITION",
-    /* WINED3DDECLUSAGE_BLENDWEIGHT     */ "BLENDWEIGHT",
-    /* WINED3DDECLUSAGE_BLENDINDICES    */ "BLENDINDICES",
-    /* WINED3DDECLUSAGE_NORMAL          */ "NORMAL",
-    /* WINED3DDECLUSAGE_PSIZE           */ "PSIZE",
-    /* WINED3DDECLUSAGE_TEXCOORD        */ "TEXCOORD",
-    /* WINED3DDECLUSAGE_TANGENT         */ "TANGENT",
-    /* WINED3DDECLUSAGE_BINORMAL        */ "BINORMAL",
-    /* WINED3DDECLUSAGE_TESSFACTOR      */ "TESSFACTOR",
-    /* WINED3DDECLUSAGE_POSITIONT       */ "POSITIONT",
-    /* WINED3DDECLUSAGE_COLOR           */ "COLOR",
-    /* WINED3DDECLUSAGE_FOG             */ "FOG",
-    /* WINED3DDECLUSAGE_DEPTH           */ "DEPTH",
-    /* WINED3DDECLUSAGE_SAMPLE          */ "SAMPLE",
-};
-
-static const char *shader_semantic_name_from_usage(WINED3DDECLUSAGE usage)
-{
-    if (usage >= sizeof(semantic_names) / sizeof(*semantic_names))
-    {
-        FIXME("Unrecognized usage %#x\n", usage);
-        return "UNRECOGNIZED";
-    }
-
-    return semantic_names[usage];
-}
-
-WINED3DDECLUSAGE shader_usage_from_semantic_name(const char *name)
-{
-    unsigned int i;
-
-    for (i = 0; i < sizeof(semantic_names) / sizeof(*semantic_names); ++i)
-    {
-        if (!strcmp(name, semantic_names[i])) return i;
-    }
-
-    return ~0U;
-}
-
-BOOL shader_match_semantic(const char *semantic_name, WINED3DDECLUSAGE usage)
-{
-    return !strcmp(semantic_name, shader_semantic_name_from_usage(usage));
-}
-
-static void shader_signature_from_semantic(struct wined3d_shader_signature_element *e,
-        const struct wined3d_shader_semantic *s)
-{
-    e->semantic_name = shader_semantic_name_from_usage(s->usage);
-    e->semantic_idx = s->usage_idx;
-    e->sysval_semantic = 0;
-    e->component_type = 0;
-    e->register_idx = s->reg.reg.idx;
-    e->mask = s->reg.write_mask;
-}
-
-/* Note that this does not count the loop register
- * as an address register. */
-
-HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3d_shader_frontend *fe,
-        struct shader_reg_maps *reg_maps, struct wined3d_shader_signature_element *input_signature,
-        struct wined3d_shader_signature_element *output_signature, const DWORD *byte_code, DWORD constf_size)
-{
-    IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface;
-    void *fe_data = This->baseShader.frontend_data;
-    struct wined3d_shader_version shader_version;
-    unsigned int cur_loop_depth = 0, max_loop_depth = 0;
-    const DWORD* pToken = byte_code;
-
-    /* There are some minor differences between pixel and vertex shaders */
-
-    memset(reg_maps, 0, sizeof(*reg_maps));
-
-    /* get_registers_used is called on every compile on some 1.x shaders, which can result
-     * in stacking up a collection of local constants. Delete the old constants if existing
-     */
-    shader_delete_constant_list(&This->baseShader.constantsF);
-    shader_delete_constant_list(&This->baseShader.constantsB);
-    shader_delete_constant_list(&This->baseShader.constantsI);
-
-    fe->shader_read_header(fe_data, &pToken, &shader_version);
-    reg_maps->shader_version = shader_version;
-
-    reg_maps->constf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
-                                 sizeof(*reg_maps->constf) * ((constf_size + 31) / 32));
-    if(!reg_maps->constf) {
-        ERR("Out of memory\n");
-        return E_OUTOFMEMORY;
-    }
-
-    while (!fe->shader_is_end(fe_data, &pToken))
-    {
-        struct wined3d_shader_instruction ins;
-        const char *comment;
-        UINT param_size;
-
-        /* Skip comments */
-        fe->shader_read_comment(&pToken, &comment);
-        if (comment) continue;
-
-        /* Fetch opcode */
-        fe->shader_read_opcode(fe_data, &pToken, &ins, &param_size);
-
-        /* Unhandled opcode, and its parameters */
-        if (ins.handler_idx == WINED3DSIH_TABLE_SIZE)
-        {
-            TRACE("Skipping unrecognized instruction.\n");
-            pToken += param_size;
-            continue;
-        }
-
-        /* Handle declarations */
-        if (ins.handler_idx == WINED3DSIH_DCL)
-        {
-            struct wined3d_shader_semantic semantic;
-
-            fe->shader_read_semantic(&pToken, &semantic);
-
-            switch (semantic.reg.reg.type)
-            {
-                /* Mark input registers used. */
-                case WINED3DSPR_INPUT:
-                    reg_maps->input_registers |= 1 << semantic.reg.reg.idx;
-                    shader_signature_from_semantic(&input_signature[semantic.reg.reg.idx], &semantic);
-                    break;
-
-                /* Vshader: mark 3.0 output registers used, save token */
-                case WINED3DSPR_OUTPUT:
-                    reg_maps->output_registers |= 1 << semantic.reg.reg.idx;
-                    shader_signature_from_semantic(&output_signature[semantic.reg.reg.idx], &semantic);
-                    if (semantic.usage == WINED3DDECLUSAGE_FOG) reg_maps->fog = 1;
-                    break;
-
-                /* Save sampler usage token */
-                case WINED3DSPR_SAMPLER:
-                    reg_maps->sampler_type[semantic.reg.reg.idx] = semantic.sampler_type;
-                    break;
-
-                default:
-                    TRACE("Not recording DCL register type %#x.\n", semantic.reg.reg.type);
-                    break;
-            }
-        }
-        else if (ins.handler_idx == WINED3DSIH_DEF)
-        {
-            struct wined3d_shader_dst_param dst;
-            struct wined3d_shader_src_param rel_addr;
-
-            local_constant* lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant));
-            if (!lconst) return E_OUTOFMEMORY;
-
-            fe->shader_read_dst_param(fe_data, &pToken, &dst, &rel_addr);
-            lconst->idx = dst.reg.idx;
-
-            memcpy(lconst->value, pToken, 4 * sizeof(DWORD));
-            pToken += 4;
-
-            /* In pixel shader 1.X shaders, the constants are clamped between [-1;1] */
-            if (shader_version.major == 1 && shader_version.type == WINED3D_SHADER_TYPE_PIXEL)
-            {
-                float *value = (float *) lconst->value;
-                if (value[0] < -1.0f) value[0] = -1.0f;
-                else if (value[0] > 1.0f) value[0] = 1.0f;
-                if (value[1] < -1.0f) value[1] = -1.0f;
-                else if (value[1] > 1.0f) value[1] = 1.0f;
-                if (value[2] < -1.0f) value[2] = -1.0f;
-                else if (value[2] > 1.0f) value[2] = 1.0f;
-                if (value[3] < -1.0f) value[3] = -1.0f;
-                else if (value[3] > 1.0f) value[3] = 1.0f;
-            }
-
-            list_add_head(&This->baseShader.constantsF, &lconst->entry);
-        }
-        else if (ins.handler_idx == WINED3DSIH_DEFI)
-        {
-            struct wined3d_shader_dst_param dst;
-            struct wined3d_shader_src_param rel_addr;
-
-            local_constant* lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant));
-            if (!lconst) return E_OUTOFMEMORY;
-
-            fe->shader_read_dst_param(fe_data, &pToken, &dst, &rel_addr);
-            lconst->idx = dst.reg.idx;
-
-            memcpy(lconst->value, pToken, 4 * sizeof(DWORD));
-            pToken += 4;
-
-            list_add_head(&This->baseShader.constantsI, &lconst->entry);
-            reg_maps->local_int_consts |= (1 << dst.reg.idx);
-        }
-        else if (ins.handler_idx == WINED3DSIH_DEFB)
-        {
-            struct wined3d_shader_dst_param dst;
-            struct wined3d_shader_src_param rel_addr;
-
-            local_constant* lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant));
-            if (!lconst) return E_OUTOFMEMORY;
-
-            fe->shader_read_dst_param(fe_data, &pToken, &dst, &rel_addr);
-            lconst->idx = dst.reg.idx;
-
-            memcpy(lconst->value, pToken, sizeof(DWORD));
-            ++pToken;
-
-            list_add_head(&This->baseShader.constantsB, &lconst->entry);
-            reg_maps->local_bool_consts |= (1 << dst.reg.idx);
-        }
-        /* If there's a loop in the shader */
-        else if (ins.handler_idx == WINED3DSIH_LOOP
-                || ins.handler_idx == WINED3DSIH_REP)
-        {
-            struct wined3d_shader_src_param src, rel_addr;
-
-            fe->shader_read_src_param(fe_data, &pToken, &src, &rel_addr);
-
-            /* Rep and Loop always use an integer constant for the control parameters */
-            if (ins.handler_idx == WINED3DSIH_REP)
-            {
-                reg_maps->integer_constants |= 1 << src.reg.idx;
-            }
-            else
-            {
-                fe->shader_read_src_param(fe_data, &pToken, &src, &rel_addr);
-                reg_maps->integer_constants |= 1 << src.reg.idx;
-            }
-
-            cur_loop_depth++;
-            if(cur_loop_depth > max_loop_depth)
-                max_loop_depth = cur_loop_depth;
-        }
-        else if (ins.handler_idx == WINED3DSIH_ENDLOOP
-                || ins.handler_idx == WINED3DSIH_ENDREP)
-        {
-            cur_loop_depth--;
-        }
-        /* For subroutine prototypes */
-        else if (ins.handler_idx == WINED3DSIH_LABEL)
-        {
-            struct wined3d_shader_src_param src, rel_addr;
-
-            fe->shader_read_src_param(fe_data, &pToken, &src, &rel_addr);
-            reg_maps->labels |= 1 << src.reg.idx;
-        }
-        /* Set texture, address, temporary registers */
-        else
-        {
-            int i, limit;
-            BOOL color0_mov = FALSE;
-
-            /* This will loop over all the registers and try to
-             * make a bitmask of the ones we're interested in.
-             *
-             * Relative addressing tokens are ignored, but that's
-             * okay, since we'll catch any address registers when
-             * they are initialized (required by spec) */
-
-            if (ins.dst_count)
-            {
-                struct wined3d_shader_dst_param dst_param;
-                struct wined3d_shader_src_param dst_rel_addr;
-
-                fe->shader_read_dst_param(fe_data, &pToken, &dst_param, &dst_rel_addr);
-
-                shader_record_register_usage(This, reg_maps, &dst_param.reg, shader_version.type);
-
-                /* WINED3DSPR_TEXCRDOUT is the same as WINED3DSPR_OUTPUT. _OUTPUT can be > MAX_REG_TEXCRD and
-                 * is used in >= 3.0 shaders. Filter 3.0 shaders to prevent overflows, and also filter pixel
-                 * shaders because TECRDOUT isn't used in them, but future register types might cause issues */
-                if (shader_version.type == WINED3D_SHADER_TYPE_VERTEX && shader_version.major < 3
-                        && dst_param.reg.type == WINED3DSPR_TEXCRDOUT)
-                {
-                    reg_maps->texcoord_mask[dst_param.reg.idx] |= dst_param.write_mask;
-                }
-
-                if (shader_version.type == WINED3D_SHADER_TYPE_PIXEL)
-                {
-                    IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *)This;
-
-                    if(dst_param.reg.type == WINED3DSPR_COLOROUT && dst_param.reg.idx == 0)
-                    {
-                    /* Many 2.0 and 3.0 pixel shaders end with a MOV from a temp register to
-                     * COLOROUT 0. If we know this in advance, the ARB shader backend can skip
-                     * the mov and perform the sRGB write correction from the source register.
-                     *
-                     * However, if the mov is only partial, we can't do this, and if the write
-                     * comes from an instruction other than MOV it is hard to do as well. If
-                     * COLOROUT 0 is overwritten partially later, the marker is dropped again. */
-
-                        ps->color0_mov = FALSE;
-                        if (ins.handler_idx == WINED3DSIH_MOV)
-                        {
-                            /* Used later when the source register is read. */
-                            color0_mov = TRUE;
-                        }
-                    }
-                    /* Also drop the MOV marker if the source register is overwritten prior to the shader
-                     * end
-                     */
-                    else if(dst_param.reg.type == WINED3DSPR_TEMP && dst_param.reg.idx == ps->color0_reg)
-                    {
-                        ps->color0_mov = FALSE;
-                    }
-                }
-
-                /* Declare 1.X samplers implicitly, based on the destination reg. number */
-                if (shader_version.major == 1
-                        && (ins.handler_idx == WINED3DSIH_TEX
-                            || ins.handler_idx == WINED3DSIH_TEXBEM
-                            || ins.handler_idx == WINED3DSIH_TEXBEML
-                            || ins.handler_idx == WINED3DSIH_TEXDP3TEX
-                            || ins.handler_idx == WINED3DSIH_TEXM3x2TEX
-                            || ins.handler_idx == WINED3DSIH_TEXM3x3SPEC
-                            || ins.handler_idx == WINED3DSIH_TEXM3x3TEX
-                            || ins.handler_idx == WINED3DSIH_TEXM3x3VSPEC
-                            || ins.handler_idx == WINED3DSIH_TEXREG2AR
-                            || ins.handler_idx == WINED3DSIH_TEXREG2GB
-                            || ins.handler_idx == WINED3DSIH_TEXREG2RGB))
-                {
-                    /* Fake sampler usage, only set reserved bit and ttype */
-                    DWORD sampler_code = dst_param.reg.idx;
-
-                    TRACE("Setting fake 2D sampler for 1.x pixelshader\n");
-                    reg_maps->sampler_type[sampler_code] = WINED3DSTT_2D;
-
-                    /* texbem is only valid with < 1.4 pixel shaders */
-                    if (ins.handler_idx == WINED3DSIH_TEXBEM
-                            || ins.handler_idx == WINED3DSIH_TEXBEML)
-                    {
-                        reg_maps->bumpmat |= 1 << dst_param.reg.idx;
-                        if (ins.handler_idx == WINED3DSIH_TEXBEML)
-                        {
-                            reg_maps->luminanceparams |= 1 << dst_param.reg.idx;
-                        }
-                    }
-                }
-                else if (ins.handler_idx == WINED3DSIH_BEM)
-                {
-                    reg_maps->bumpmat |= 1 << dst_param.reg.idx;
-                }
-            }
-
-            if (ins.handler_idx == WINED3DSIH_NRM)
-            {
-                reg_maps->usesnrm = 1;
-            }
-            else if (ins.handler_idx == WINED3DSIH_DSY)
-            {
-                reg_maps->usesdsy = 1;
-            }
-            else if (ins.handler_idx == WINED3DSIH_DSX)
-            {
-                reg_maps->usesdsx = 1;
-            }
-            else if(ins.handler_idx == WINED3DSIH_TEXLDD)
-            {
-                reg_maps->usestexldd = 1;
-            }
-            else if(ins.handler_idx == WINED3DSIH_TEXLDL)
-            {
-                reg_maps->usestexldl = 1;
-            }
-            else if(ins.handler_idx == WINED3DSIH_MOVA)
-            {
-                reg_maps->usesmova = 1;
-            }
-            else if(ins.handler_idx == WINED3DSIH_IFC)
-            {
-                reg_maps->usesifc = 1;
-            }
-            else if(ins.handler_idx == WINED3DSIH_CALL)
-            {
-                reg_maps->usescall = 1;
-            }
-
-            limit = ins.src_count + (ins.predicate ? 1 : 0);
-            for (i = 0; i < limit; ++i)
-            {
-                struct wined3d_shader_src_param src_param, src_rel_addr;
-                unsigned int count;
-
-                fe->shader_read_src_param(fe_data, &pToken, &src_param, &src_rel_addr);
-                count = get_instr_extra_regcount(ins.handler_idx, i);
-
-                shader_record_register_usage(This, reg_maps, &src_param.reg, shader_version.type);
-                while (count)
-                {
-                    ++src_param.reg.idx;
-                    shader_record_register_usage(This, reg_maps, &src_param.reg, shader_version.type);
-                    --count;
-                }
-
-                if(color0_mov)
-                {
-                    IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *) This;
-                    if(src_param.reg.type == WINED3DSPR_TEMP &&
-                       src_param.swizzle == WINED3DSP_NOSWIZZLE)
-                    {
-                        ps->color0_mov = TRUE;
-                        ps->color0_reg = src_param.reg.idx;
-                    }
-                }
-            }
-        }
-    }
-    reg_maps->loop_depth = max_loop_depth;
-
-    This->baseShader.functionLength = ((const char *)pToken - (const char *)byte_code);
-
-    return WINED3D_OK;
-}
-
-unsigned int shader_find_free_input_register(const struct shader_reg_maps *reg_maps, unsigned int max)
-{
-    DWORD map = 1 << max;
-    map |= map - 1;
-    map &= reg_maps->shader_version.major < 3 ? ~reg_maps->texcoord : ~reg_maps->input_registers;
-
-    return wined3d_log2i(map);
-}
-
-static void shader_dump_decl_usage(const struct wined3d_shader_semantic *semantic,
-        const struct wined3d_shader_version *shader_version)
-{
-    TRACE("dcl");
-
-    if (semantic->reg.reg.type == WINED3DSPR_SAMPLER)
-    {
-        switch (semantic->sampler_type)
-        {
-            case WINED3DSTT_2D: TRACE("_2d"); break;
-            case WINED3DSTT_CUBE: TRACE("_cube"); break;
-            case WINED3DSTT_VOLUME: TRACE("_volume"); break;
-            default: TRACE("_unknown_ttype(0x%08x)", semantic->sampler_type);
-        }
-    }
-    else
-    {
-        /* Pixel shaders 3.0 don't have usage semantics */
-        if (shader_version->major < 3 && shader_version->type == WINED3D_SHADER_TYPE_PIXEL)
-            return;
-        else
-            TRACE("_");
-
-        switch (semantic->usage)
-        {
-            case WINED3DDECLUSAGE_POSITION:
-                TRACE("position%d", semantic->usage_idx);
-                break;
-            case WINED3DDECLUSAGE_BLENDINDICES:
-                TRACE("blend");
-                break;
-            case WINED3DDECLUSAGE_BLENDWEIGHT:
-                TRACE("weight");
-                break;
-            case WINED3DDECLUSAGE_NORMAL:
-                TRACE("normal%d", semantic->usage_idx);
-                break;
-            case WINED3DDECLUSAGE_PSIZE:
-                TRACE("psize");
-                break;
-            case WINED3DDECLUSAGE_COLOR:
-                if (semantic->usage_idx == 0) TRACE("color");
-                else TRACE("specular%d", (semantic->usage_idx - 1));
-                break;
-            case WINED3DDECLUSAGE_TEXCOORD:
-                TRACE("texture%d", semantic->usage_idx);
-                break;
-            case WINED3DDECLUSAGE_TANGENT:
-                TRACE("tangent");
-                break;
-            case WINED3DDECLUSAGE_BINORMAL:
-                TRACE("binormal");
-                break;
-            case WINED3DDECLUSAGE_TESSFACTOR:
-                TRACE("tessfactor");
-                break;
-            case WINED3DDECLUSAGE_POSITIONT:
-                TRACE("positionT%d", semantic->usage_idx);
-                break;
-            case WINED3DDECLUSAGE_FOG:
-                TRACE("fog");
-                break;
-            case WINED3DDECLUSAGE_DEPTH:
-                TRACE("depth");
-                break;
-            case WINED3DDECLUSAGE_SAMPLE:
-                TRACE("sample");
-                break;
-            default:
-                FIXME("unknown_semantics(0x%08x)", semantic->usage);
-        }
-    }
-}
-
-static void shader_dump_register(const struct wined3d_shader_register *reg,
-        const struct wined3d_shader_version *shader_version)
-{
-    static const char * const rastout_reg_names[] = {"oPos", "oFog", "oPts"};
-    static const char * const misctype_reg_names[] = {"vPos", "vFace"};
-    UINT offset = reg->idx;
-
-    switch (reg->type)
-    {
-        case WINED3DSPR_TEMP:
-            TRACE("r");
-            break;
-
-        case WINED3DSPR_INPUT:
-            TRACE("v");
-            break;
-
-        case WINED3DSPR_CONST:
-        case WINED3DSPR_CONST2:
-        case WINED3DSPR_CONST3:
-        case WINED3DSPR_CONST4:
-            TRACE("c");
-            offset = shader_get_float_offset(reg->type, reg->idx);
-            break;
-
-        case WINED3DSPR_TEXTURE: /* vs: case WINED3DSPR_ADDR */
-            TRACE("%c", shader_version->type == WINED3D_SHADER_TYPE_PIXEL ? 't' : 'a');
-            break;
-
-        case WINED3DSPR_RASTOUT:
-            TRACE("%s", rastout_reg_names[reg->idx]);
-            break;
-
-        case WINED3DSPR_COLOROUT:
-            TRACE("oC");
-            break;
-
-        case WINED3DSPR_DEPTHOUT:
-            TRACE("oDepth");
-            break;
-
-        case WINED3DSPR_ATTROUT:
-            TRACE("oD");
-            break;
-
-        case WINED3DSPR_TEXCRDOUT:
-            /* Vertex shaders >= 3.0 use general purpose output registers
-             * (WINED3DSPR_OUTPUT), which can include an address token */
-            if (shader_version->major >= 3) TRACE("o");
-            else TRACE("oT");
-            break;
-
-        case WINED3DSPR_CONSTINT:
-            TRACE("i");
-            break;
-
-        case WINED3DSPR_CONSTBOOL:
-            TRACE("b");
-            break;
-
-        case WINED3DSPR_LABEL:
-            TRACE("l");
-            break;
-
-        case WINED3DSPR_LOOP:
-            TRACE("aL");
-            break;
-
-        case WINED3DSPR_SAMPLER:
-            TRACE("s");
-            break;
-
-        case WINED3DSPR_MISCTYPE:
-            if (reg->idx > 1) FIXME("Unhandled misctype register %d\n", reg->idx);
-            else TRACE("%s", misctype_reg_names[reg->idx]);
-            break;
-
-        case WINED3DSPR_PREDICATE:
-            TRACE("p");
-            break;
-
-        case WINED3DSPR_IMMCONST:
-            TRACE("l");
-            break;
-
-        case WINED3DSPR_CONSTBUFFER:
-            TRACE("cb");
-            break;
-
-        default:
-            TRACE("unhandled_rtype(%#x)", reg->type);
-            break;
-    }
-
-    if (reg->type == WINED3DSPR_IMMCONST)
-    {
-        TRACE("(");
-        switch (reg->immconst_type)
-        {
-            case WINED3D_IMMCONST_FLOAT:
-                TRACE("%.8e", *(const float *)reg->immconst_data);
-                break;
-
-            case WINED3D_IMMCONST_FLOAT4:
-                TRACE("%.8e, %.8e, %.8e, %.8e",
-                        *(const float *)&reg->immconst_data[0], *(const float *)&reg->immconst_data[1],
-                        *(const float *)&reg->immconst_data[2], *(const float *)&reg->immconst_data[3]);
-                break;
-
-            default:
-                TRACE("<unhandled immconst_type %#x>", reg->immconst_type);
-                break;
-        }
-        TRACE(")");
-    }
-    else if (reg->type != WINED3DSPR_RASTOUT && reg->type != WINED3DSPR_MISCTYPE)
-    {
-        if (reg->array_idx != ~0U)
-        {
-            TRACE("%u[%u", offset, reg->array_idx);
-            if (reg->rel_addr)
-            {
-                TRACE(" + ");
-                shader_dump_src_param(reg->rel_addr, shader_version);
-            }
-            TRACE("]");
-        }
-        else
-        {
-            if (reg->rel_addr)
-            {
-                TRACE("[");
-                shader_dump_src_param(reg->rel_addr, shader_version);
-                TRACE(" + ");
-            }
-            TRACE("%u", offset);
-            if (reg->rel_addr) TRACE("]");
-        }
-    }
-}
-
-void shader_dump_dst_param(const struct wined3d_shader_dst_param *param,
-        const struct wined3d_shader_version *shader_version)
-{
-    DWORD write_mask = param->write_mask;
-
-    shader_dump_register(&param->reg, shader_version);
-
-    if (write_mask != WINED3DSP_WRITEMASK_ALL)
-    {
-        static const char *write_mask_chars = "xyzw";
-
-        TRACE(".");
-        if (write_mask & WINED3DSP_WRITEMASK_0) TRACE("%c", write_mask_chars[0]);
-        if (write_mask & WINED3DSP_WRITEMASK_1) TRACE("%c", write_mask_chars[1]);
-        if (write_mask & WINED3DSP_WRITEMASK_2) TRACE("%c", write_mask_chars[2]);
-        if (write_mask & WINED3DSP_WRITEMASK_3) TRACE("%c", write_mask_chars[3]);
-    }
-}
-
-void shader_dump_src_param(const struct wined3d_shader_src_param *param,
-        const struct wined3d_shader_version *shader_version)
-{
-    DWORD src_modifier = param->modifiers;
-    DWORD swizzle = param->swizzle;
-
-    if (src_modifier == WINED3DSPSM_NEG
-            || src_modifier == WINED3DSPSM_BIASNEG
-            || src_modifier == WINED3DSPSM_SIGNNEG
-            || src_modifier == WINED3DSPSM_X2NEG
-            || src_modifier == WINED3DSPSM_ABSNEG)
-        TRACE("-");
-    else if (src_modifier == WINED3DSPSM_COMP)
-        TRACE("1-");
-    else if (src_modifier == WINED3DSPSM_NOT)
-        TRACE("!");
-
-    if (src_modifier == WINED3DSPSM_ABS || src_modifier == WINED3DSPSM_ABSNEG)
-        TRACE("abs(");
-
-    shader_dump_register(&param->reg, shader_version);
-
-    if (src_modifier)
-    {
-        switch (src_modifier)
-        {
-            case WINED3DSPSM_NONE:    break;
-            case WINED3DSPSM_NEG:     break;
-            case WINED3DSPSM_NOT:     break;
-            case WINED3DSPSM_BIAS:    TRACE("_bias"); break;
-            case WINED3DSPSM_BIASNEG: TRACE("_bias"); break;
-            case WINED3DSPSM_SIGN:    TRACE("_bx2"); break;
-            case WINED3DSPSM_SIGNNEG: TRACE("_bx2"); break;
-            case WINED3DSPSM_COMP:    break;
-            case WINED3DSPSM_X2:      TRACE("_x2"); break;
-            case WINED3DSPSM_X2NEG:   TRACE("_x2"); break;
-            case WINED3DSPSM_DZ:      TRACE("_dz"); break;
-            case WINED3DSPSM_DW:      TRACE("_dw"); break;
-            case WINED3DSPSM_ABSNEG:  TRACE(")"); break;
-            case WINED3DSPSM_ABS:     TRACE(")"); break;
-            default:
-                                      TRACE("_unknown_modifier(%#x)", src_modifier);
-        }
-    }
-
-    if (swizzle != WINED3DSP_NOSWIZZLE)
-    {
-        static const char *swizzle_chars = "xyzw";
-        DWORD swizzle_x = swizzle & 0x03;
-        DWORD swizzle_y = (swizzle >> 2) & 0x03;
-        DWORD swizzle_z = (swizzle >> 4) & 0x03;
-        DWORD swizzle_w = (swizzle >> 6) & 0x03;
-
-        if (swizzle_x == swizzle_y
-                && swizzle_x == swizzle_z
-                && swizzle_x == swizzle_w)
-        {
-            TRACE(".%c", swizzle_chars[swizzle_x]);
-        }
-        else
-        {
-            TRACE(".%c%c%c%c", swizzle_chars[swizzle_x], swizzle_chars[swizzle_y],
-                    swizzle_chars[swizzle_z], swizzle_chars[swizzle_w]);
-        }
-    }
-}
-
-/* Shared code in order to generate the bulk of the shader string.
- * NOTE: A description of how to parse tokens can be found on msdn */
-void shader_generate_main(IWineD3DBaseShader *iface, struct wined3d_shader_buffer *buffer,
-        const shader_reg_maps *reg_maps, const DWORD *pFunction, void *backend_ctx)
-{
-    IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface;
-    IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) This->baseShader.device; /* To access shader backend callbacks */
-    const struct wined3d_shader_frontend *fe = This->baseShader.frontend;
-    void *fe_data = This->baseShader.frontend_data;
-    struct wined3d_shader_src_param src_rel_addr[4];
-    struct wined3d_shader_src_param src_param[4];
-    struct wined3d_shader_version shader_version;
-    struct wined3d_shader_src_param dst_rel_addr;
-    struct wined3d_shader_dst_param dst_param;
-    struct wined3d_shader_instruction ins;
-    struct wined3d_shader_context ctx;
-    const DWORD *pToken = pFunction;
-    DWORD i;
-
-    /* Initialize current parsing state */
-    ctx.shader = iface;
-    ctx.reg_maps = reg_maps;
-    ctx.buffer = buffer;
-    ctx.backend_data = backend_ctx;
-
-    ins.ctx = &ctx;
-    ins.dst = &dst_param;
-    ins.src = src_param;
-    This->baseShader.parse_state.current_row = 0;
-
-    fe->shader_read_header(fe_data, &pToken, &shader_version);
-
-    while (!fe->shader_is_end(fe_data, &pToken))
-    {
-        const char *comment;
-        UINT param_size;
-
-        /* Skip comment tokens */
-        fe->shader_read_comment(&pToken, &comment);
-        if (comment) continue;
-
-        /* Read opcode */
-        fe->shader_read_opcode(fe_data, &pToken, &ins, &param_size);
-
-        /* Unknown opcode and its parameters */
-        if (ins.handler_idx == WINED3DSIH_TABLE_SIZE)
-        {
-            TRACE("Skipping unrecognized instruction.\n");
-            pToken += param_size;
-            continue;
-        }
-
-        /* Nothing to do */
-        if (ins.handler_idx == WINED3DSIH_DCL
-                || ins.handler_idx == WINED3DSIH_NOP
-                || ins.handler_idx == WINED3DSIH_DEF
-                || ins.handler_idx == WINED3DSIH_DEFI
-                || ins.handler_idx == WINED3DSIH_DEFB
-                || ins.handler_idx == WINED3DSIH_PHASE)
-        {
-            pToken += param_size;
-            continue;
-        }
-
-        /* Destination token */
-        if (ins.dst_count) fe->shader_read_dst_param(fe_data, &pToken, &dst_param, &dst_rel_addr);
-
-        /* Predication token */
-        if (ins.predicate) ins.predicate = *pToken++;
-
-        /* Other source tokens */
-        for (i = 0; i < ins.src_count; ++i)
-        {
-            fe->shader_read_src_param(fe_data, &pToken, &src_param[i], &src_rel_addr[i]);
-        }
-
-        /* Call appropriate function for output target */
-        device->shader_backend->shader_handle_instruction(&ins);
-    }
-}
-
-static void shader_dump_ins_modifiers(const struct wined3d_shader_dst_param *dst)
-{
-    DWORD mmask = dst->modifiers;
-
-    switch (dst->shift)
-    {
-        case 0: break;
-        case 13: TRACE("_d8"); break;
-        case 14: TRACE("_d4"); break;
-        case 15: TRACE("_d2"); break;
-        case 1: TRACE("_x2"); break;
-        case 2: TRACE("_x4"); break;
-        case 3: TRACE("_x8"); break;
-        default: TRACE("_unhandled_shift(%d)", dst->shift); break;
-    }
-
-    if (mmask & WINED3DSPDM_SATURATE)         TRACE("_sat");
-    if (mmask & WINED3DSPDM_PARTIALPRECISION) TRACE("_pp");
-    if (mmask & WINED3DSPDM_MSAMPCENTROID)    TRACE("_centroid");
-
-    mmask &= ~(WINED3DSPDM_SATURATE | WINED3DSPDM_PARTIALPRECISION | WINED3DSPDM_MSAMPCENTROID);
-    if (mmask)
-        FIXME("_unrecognized_modifier(%#x)", mmask);
-}
-
-void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe_data, const DWORD *pFunction)
-{
-    struct wined3d_shader_version shader_version;
-    const DWORD* pToken = pFunction;
-    const char *type_prefix;
-    DWORD i;
-
-    TRACE("Parsing %p\n", pFunction);
-
-    fe->shader_read_header(fe_data, &pToken, &shader_version);
-
-    switch (shader_version.type)
-    {
-        case WINED3D_SHADER_TYPE_VERTEX:
-            type_prefix = "vs";
-            break;
-
-        case WINED3D_SHADER_TYPE_GEOMETRY:
-            type_prefix = "gs";
-            break;
-
-        case WINED3D_SHADER_TYPE_PIXEL:
-            type_prefix = "ps";
-            break;
-
-        default:
-            FIXME("Unhandled shader type %#x.\n", shader_version.type);
-            type_prefix = "unknown";
-            break;
-    }
-
-    TRACE("%s_%u_%u\n", type_prefix, shader_version.major, shader_version.minor);
-
-    while (!fe->shader_is_end(fe_data, &pToken))
-    {
-        struct wined3d_shader_instruction ins;
-        const char *comment;
-        UINT param_size;
-
-        /* comment */
-        fe->shader_read_comment(&pToken, &comment);
-        if (comment)
-        {
-            TRACE("//%s\n", comment);
-            continue;
-        }
-
-        fe->shader_read_opcode(fe_data, &pToken, &ins, &param_size);
-        if (ins.handler_idx == WINED3DSIH_TABLE_SIZE)
-        {
-            TRACE("Skipping unrecognized instruction.\n");
-            pToken += param_size;
-            continue;
-        }
-
-        if (ins.handler_idx == WINED3DSIH_DCL)
-        {
-            struct wined3d_shader_semantic semantic;
-
-            fe->shader_read_semantic(&pToken, &semantic);
-
-            shader_dump_decl_usage(&semantic, &shader_version);
-            shader_dump_ins_modifiers(&semantic.reg);
-            TRACE(" ");
-            shader_dump_dst_param(&semantic.reg, &shader_version);
-        }
-        else if (ins.handler_idx == WINED3DSIH_DEF)
-        {
-            struct wined3d_shader_dst_param dst;
-            struct wined3d_shader_src_param rel_addr;
-
-            fe->shader_read_dst_param(fe_data, &pToken, &dst, &rel_addr);
-
-            TRACE("def c%u = %f, %f, %f, %f", shader_get_float_offset(dst.reg.type, dst.reg.idx),
-                    *(const float *)(pToken),
-                    *(const float *)(pToken + 1),
-                    *(const float *)(pToken + 2),
-                    *(const float *)(pToken + 3));
-            pToken += 4;
-        }
-        else if (ins.handler_idx == WINED3DSIH_DEFI)
-        {
-            struct wined3d_shader_dst_param dst;
-            struct wined3d_shader_src_param rel_addr;
-
-            fe->shader_read_dst_param(fe_data, &pToken, &dst, &rel_addr);
-
-            TRACE("defi i%u = %d, %d, %d, %d", dst.reg.idx,
-                    *(pToken),
-                    *(pToken + 1),
-                    *(pToken + 2),
-                    *(pToken + 3));
-            pToken += 4;
-        }
-        else if (ins.handler_idx == WINED3DSIH_DEFB)
-        {
-            struct wined3d_shader_dst_param dst;
-            struct wined3d_shader_src_param rel_addr;
-
-            fe->shader_read_dst_param(fe_data, &pToken, &dst, &rel_addr);
-
-            TRACE("defb b%u = %s", dst.reg.idx, *pToken ? "true" : "false");
-            ++pToken;
-        }
-        else
-        {
-            struct wined3d_shader_src_param dst_rel_addr, src_rel_addr;
-            struct wined3d_shader_dst_param dst_param;
-            struct wined3d_shader_src_param src_param;
-
-            if (ins.dst_count)
-            {
-                fe->shader_read_dst_param(fe_data, &pToken, &dst_param, &dst_rel_addr);
-            }
-
-            /* Print out predication source token first - it follows
-             * the destination token. */
-            if (ins.predicate)
-            {
-                fe->shader_read_src_param(fe_data, &pToken, &src_param, &src_rel_addr);
-                TRACE("(");
-                shader_dump_src_param(&src_param, &shader_version);
-                TRACE(") ");
-            }
-
-            /* PixWin marks instructions with the coissue flag with a '+' */
-            if (ins.coissue) TRACE("+");
-
-            TRACE("%s", shader_opcode_names[ins.handler_idx]);
-
-            if (ins.handler_idx == WINED3DSIH_IFC
-                    || ins.handler_idx == WINED3DSIH_BREAKC)
-            {
-                switch (ins.flags)
-                {
-                    case COMPARISON_GT: TRACE("_gt"); break;
-                    case COMPARISON_EQ: TRACE("_eq"); break;
-                    case COMPARISON_GE: TRACE("_ge"); break;
-                    case COMPARISON_LT: TRACE("_lt"); break;
-                    case COMPARISON_NE: TRACE("_ne"); break;
-                    case COMPARISON_LE: TRACE("_le"); break;
-                    default: TRACE("_(%u)", ins.flags);
-                }
-            }
-            else if (ins.handler_idx == WINED3DSIH_TEX
-                    && shader_version.major >= 2
-                    && (ins.flags & WINED3DSI_TEXLD_PROJECT))
-            {
-                TRACE("p");
-            }
-
-            /* We already read the destination token, print it. */
-            if (ins.dst_count)
-            {
-                shader_dump_ins_modifiers(&dst_param);
-                TRACE(" ");
-                shader_dump_dst_param(&dst_param, &shader_version);
-            }
-
-            /* Other source tokens */
-            for (i = ins.dst_count; i < (ins.dst_count + ins.src_count); ++i)
-            {
-                fe->shader_read_src_param(fe_data, &pToken, &src_param, &src_rel_addr);
-                TRACE(!i ? " " : ", ");
-                shader_dump_src_param(&src_param, &shader_version);
-            }
-        }
-        TRACE("\n");
-    }
-}
-
-void shader_cleanup(IWineD3DBaseShader *iface)
-{
-    IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *)iface;
-
-    ((IWineD3DDeviceImpl *)This->baseShader.device)->shader_backend->shader_destroy(iface);
-    HeapFree(GetProcessHeap(), 0, This->baseShader.reg_maps.constf);
-    HeapFree(GetProcessHeap(), 0, This->baseShader.function);
-    shader_delete_constant_list(&This->baseShader.constantsF);
-    shader_delete_constant_list(&This->baseShader.constantsB);
-    shader_delete_constant_list(&This->baseShader.constantsI);
-    list_remove(&This->baseShader.shader_list_entry);
-
-    if (This->baseShader.frontend && This->baseShader.frontend_data)
-    {
-        This->baseShader.frontend->shader_free(This->baseShader.frontend_data);
-    }
-}
-
-static void shader_none_handle_instruction(const struct wined3d_shader_instruction *ins) {}
-static void shader_none_select(const struct wined3d_context *context, BOOL usePS, BOOL useVS) {}
-static void shader_none_select_depth_blt(IWineD3DDevice *iface, enum tex_types tex_type) {}
-static void shader_none_deselect_depth_blt(IWineD3DDevice *iface) {}
-static void shader_none_update_float_vertex_constants(IWineD3DDevice *iface, UINT start, UINT count) {}
-static void shader_none_update_float_pixel_constants(IWineD3DDevice *iface, UINT start, UINT count) {}
-static void shader_none_load_constants(const struct wined3d_context *context, char usePS, char useVS) {}
-static void shader_none_load_np2fixup_constants(IWineD3DDevice *iface, char usePS, char useVS) {}
-static void shader_none_destroy(IWineD3DBaseShader *iface) {}
-static HRESULT shader_none_alloc(IWineD3DDevice *iface) {return WINED3D_OK;}
-static void shader_none_free(IWineD3DDevice *iface) {}
-static BOOL shader_none_dirty_const(IWineD3DDevice *iface) {return FALSE;}
-
-static void shader_none_get_caps(WINED3DDEVTYPE devtype,
-        const struct wined3d_gl_info *gl_info, struct shader_caps *pCaps)
-{
-    /* Set the shader caps to 0 for the none shader backend */
-    pCaps->VertexShaderVersion  = 0;
-    pCaps->PixelShaderVersion    = 0;
-    pCaps->PixelShader1xMaxValue = 0.0f;
-}
-
-static BOOL shader_none_color_fixup_supported(struct color_fixup_desc fixup)
-{
-    if (TRACE_ON(d3d_shader) && TRACE_ON(d3d))
-    {
-        TRACE("Checking support for fixup:\n");
-        dump_color_fixup_desc(fixup);
-    }
-
-    /* Faked to make some apps happy. */
-    if (!is_yuv_fixup(fixup))
-    {
-        TRACE("[OK]\n");
-        return TRUE;
-    }
-
-    TRACE("[FAILED]\n");
-    return FALSE;
-}
-
-const shader_backend_t none_shader_backend = {
-    shader_none_handle_instruction,
-    shader_none_select,
-    shader_none_select_depth_blt,
-    shader_none_deselect_depth_blt,
-    shader_none_update_float_vertex_constants,
-    shader_none_update_float_pixel_constants,
-    shader_none_load_constants,
-    shader_none_load_np2fixup_constants,
-    shader_none_destroy,
-    shader_none_alloc,
-    shader_none_free,
-    shader_none_dirty_const,
-    shader_none_get_caps,
-    shader_none_color_fixup_supported,
-};
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/basetexture.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/basetexture.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/basetexture.c	(revision 28475)
@@ -38,5 +38,5 @@
 
 HRESULT basetexture_init(IWineD3DBaseTextureImpl *texture, UINT levels, WINED3DRESOURCETYPE resource_type,
-        IWineD3DDeviceImpl *device, UINT size, DWORD usage, const struct GlPixelFormatDesc *format_desc,
+        IWineD3DDeviceImpl *device, UINT size, DWORD usage, const struct wined3d_format_desc *format_desc,
         WINED3DPOOL pool, IUnknown *parent, const struct wined3d_parent_ops *parent_ops)
 {
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/buffer.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/buffer.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/buffer.c	(revision 28475)
@@ -4,5 +4,5 @@
  * Copyright 2004 Christian Costa
  * Copyright 2005 Oliver Stieber
- * Copyright 2007 Stefan Dösinger for CodeWeavers
+ * Copyright 2007-2010 Stefan Dösinger for CodeWeavers
  * Copyright 2009 Henri Verbeet for CodeWeavers
  *
@@ -66,5 +66,11 @@
     }
 
-    if(!offset && !size)
+    if(offset > This->resource.size || offset + size > This->resource.size)
+    {
+        WARN("Invalid range dirtified, marking entire buffer dirty\n");
+        offset = 0;
+        size = This->resource.size;
+    }
+    else if(!offset && !size)
     {
         size = This->resource.size;
@@ -99,4 +105,23 @@
     }
     return FALSE;
+}
+
+/* Context activation is done by the caller */
+static void delete_gl_buffer(struct wined3d_buffer *This)
+{
+    if(!This->buffer_object) return;
+
+    ENTER_GL();
+    GL_EXTCALL(glDeleteBuffersARB(1, &This->buffer_object));
+    checkGLcall("glDeleteBuffersARB");
+    LEAVE_GL();
+    This->buffer_object = 0;
+
+    if(This->query)
+    {
+        wined3d_event_query_destroy(This->query);
+        This->query = NULL;
+    }
+    This->flags &= ~WINED3D_BUFFER_APPLESYNC;
 }
 
@@ -155,9 +180,4 @@
         TRACE("Gl usage = GL_STREAM_DRAW_ARB\n");
         gl_usage = GL_STREAM_DRAW_ARB;
-    }
-    else
-    {
-        TRACE("Gl usage = GL_DYNAMIC_DRAW_ARB\n");
-        gl_usage = GL_DYNAMIC_DRAW_ARB;
 
         if(gl_info->supported[APPLE_FLUSH_BUFFER_RANGE])
@@ -166,5 +186,15 @@
             checkGLcall("glBufferParameteriAPPLE(This->buffer_type_hint, GL_BUFFER_FLUSHING_UNMAP_APPLE, GL_FALSE)");
             This->flags |= WINED3D_BUFFER_FLUSH;
-        }
+
+            GL_EXTCALL(glBufferParameteriAPPLE(This->buffer_type_hint, GL_BUFFER_SERIALIZED_MODIFY_APPLE, GL_FALSE));
+            checkGLcall("glBufferParameteriAPPLE(This->buffer_type_hint, GL_BUFFER_SERIALIZED_MODIFY_APPLE, GL_FALSE)");
+            This->flags |= WINED3D_BUFFER_APPLESYNC;
+        }
+        /* No setup is needed here for GL_ARB_map_buffer_range */
+    }
+    else
+    {
+        TRACE("Gl usage = GL_DYNAMIC_DRAW_ARB\n");
+        gl_usage = GL_DYNAMIC_DRAW_ARB;
     }
 
@@ -206,11 +236,5 @@
     /* Clean up all vbo init, but continue because we can work without a vbo :-) */
     ERR("Failed to create a vertex buffer object. Continuing, but performance issues may occur\n");
-    if (This->buffer_object)
-    {
-        ENTER_GL();
-        GL_EXTCALL(glDeleteBuffersARB(1, &This->buffer_object));
-        LEAVE_GL();
-    }
-    This->buffer_object = 0;
+    delete_gl_buffer(This);
     buffer_clear_dirty_areas(This);
 }
@@ -261,10 +285,11 @@
     for (i = 0; i < attrib_size; ++i)
     {
-        if (This->conversion_map[data + i] != conversion_type)
-        {
-            TRACE("Byte %ld in vertex changed\n", i + data);
-            TRACE("It was type %d, is %d now\n", This->conversion_map[data + i], conversion_type);
+        DWORD_PTR idx = (data + i) % This->stride;
+        if (This->conversion_map[idx] != conversion_type)
+        {
+            TRACE("Byte %ld in vertex changed\n", idx);
+            TRACE("It was type %d, is %d now\n", This->conversion_map[idx], conversion_type);
             ret = TRUE;
-            This->conversion_map[data + i] = conversion_type;
+            This->conversion_map[idx] = conversion_type;
         }
     }
@@ -493,5 +518,5 @@
          * the attributes that our current fixed function pipeline implementation cares for.
          */
-        BOOL support_d3dcolor = gl_info->supported[EXT_VERTEX_ARRAY_BGRA];
+        BOOL support_d3dcolor = gl_info->supported[ARB_VERTEX_ARRAY_BGRA];
         ret = buffer_check_attribute(This, si, WINED3D_FFP_POSITION,
                 TRUE, TRUE,  FALSE, &stride_this_run, &float16_used) || ret;
@@ -598,5 +623,5 @@
 
 /* Context activation is done by the caller. */
-const BYTE *buffer_get_memory(IWineD3DBuffer *iface, UINT offset, GLuint *buffer_object)
+const BYTE *buffer_get_memory(IWineD3DBuffer *iface, GLuint *buffer_object)
 {
     struct wined3d_buffer *This = (struct wined3d_buffer *)iface;
@@ -612,12 +637,12 @@
             {
                 *buffer_object = This->buffer_object;
-                return (const BYTE *)offset;
-            }
-        }
-        return This->resource.allocatedMemory + offset;
+                return NULL;
+            }
+        }
+        return This->resource.allocatedMemory;
     }
     else
     {
-        return (const BYTE *)offset;
+        return NULL;
     }
 }
@@ -694,9 +719,5 @@
         }
 
-        ENTER_GL();
-        GL_EXTCALL(glDeleteBuffersARB(1, &This->buffer_object));
-        checkGLcall("glDeleteBuffersARB");
-        LEAVE_GL();
-        This->buffer_object = 0;
+        delete_gl_buffer(This);
         This->flags |= WINED3D_BUFFER_CREATEBO; /* Recreate the buffer object next load */
         buffer_clear_dirty_areas(This);
@@ -769,4 +790,145 @@
 }
 
+/* The caller provides a context and binds the buffer */
+static void buffer_sync_apple(struct wined3d_buffer *This, DWORD flags, const struct wined3d_gl_info *gl_info)
+{
+    enum wined3d_event_query_result ret;
+
+    /* No fencing needs to be done if the app promises not to overwrite
+     * existing data */
+    if(flags & WINED3DLOCK_NOOVERWRITE) return;
+    if(flags & WINED3DLOCK_DISCARD)
+    {
+        ENTER_GL();
+        GL_EXTCALL(glBufferDataARB(This->buffer_type_hint, This->resource.size, NULL, This->buffer_object_usage));
+        checkGLcall("glBufferDataARB\n");
+        LEAVE_GL();
+        return;
+    }
+
+    if(!This->query)
+    {
+        TRACE("Creating event query for buffer %p\n", This);
+
+        if (!wined3d_event_query_supported(gl_info))
+        {
+            FIXME("Event queries not supported, dropping async buffer locks.\n");
+            goto drop_query;
+        }
+
+        This->query = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*This->query));
+        if (!This->query)
+        {
+            ERR("Failed to allocate event query memory, dropping async buffer locks.\n");
+            goto drop_query;
+        }
+
+        /* Since we don't know about old draws a glFinish is needed once */
+        wglFinish();
+        return;
+    }
+    TRACE("Synchronizing buffer %p\n", This);
+    ret = wined3d_event_query_finish(This->query, This->resource.device);
+    switch(ret)
+    {
+        case WINED3D_EVENT_QUERY_NOT_STARTED:
+        case WINED3D_EVENT_QUERY_OK:
+            /* All done */
+            return;
+
+        case WINED3D_EVENT_QUERY_WRONG_THREAD:
+            WARN("Cannot synchronize buffer lock due to a thread conflict\n");
+            goto drop_query;
+
+        default:
+            ERR("wined3d_event_query_finish returned %u, dropping async buffer locks\n", ret);
+            goto drop_query;
+    }
+
+drop_query:
+    if(This->query)
+    {
+        wined3d_event_query_destroy(This->query);
+        This->query = NULL;
+    }
+
+    wglFinish();
+    ENTER_GL();
+    GL_EXTCALL(glBufferParameteriAPPLE(This->buffer_type_hint, GL_BUFFER_SERIALIZED_MODIFY_APPLE, GL_TRUE));
+    checkGLcall("glBufferParameteriAPPLE(This->buffer_type_hint, GL_BUFFER_SERIALIZED_MODIFY_APPLE, GL_TRUE)");
+    LEAVE_GL();
+    This->flags &= ~WINED3D_BUFFER_APPLESYNC;
+}
+
+/* The caller provides a GL context */
+static void buffer_direct_upload(struct wined3d_buffer *This, const struct wined3d_gl_info *gl_info, DWORD flags)
+{
+        BYTE *map;
+        UINT start = 0, len = 0;
+
+        ENTER_GL();
+        GL_EXTCALL(glBindBufferARB(This->buffer_type_hint, This->buffer_object));
+        checkGLcall("glBindBufferARB");
+        if (gl_info->supported[ARB_MAP_BUFFER_RANGE])
+        {
+            GLbitfield mapflags;
+            mapflags = GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT;
+            if (flags & WINED3D_BUFFER_DISCARD)
+            {
+                mapflags |= GL_MAP_UNSYNCHRONIZED_BIT | GL_MAP_INVALIDATE_BUFFER_BIT;
+            }
+            else if (flags & WINED3D_BUFFER_NOSYNC)
+            {
+                mapflags |= GL_MAP_UNSYNCHRONIZED_BIT;
+            }
+            map = GL_EXTCALL(glMapBufferRange(This->buffer_type_hint, 0,
+                                              This->resource.size, mapflags));
+            checkGLcall("glMapBufferRange");
+        }
+        else
+        {
+            if (This->flags & WINED3D_BUFFER_APPLESYNC)
+            {
+                DWORD syncflags = 0;
+                if (flags & WINED3D_BUFFER_DISCARD) syncflags |= WINED3DLOCK_DISCARD;
+                if (flags & WINED3D_BUFFER_NOSYNC) syncflags |= WINED3DLOCK_NOOVERWRITE;
+                LEAVE_GL();
+                buffer_sync_apple(This, syncflags, gl_info);
+                ENTER_GL();
+            }
+            map = GL_EXTCALL(glMapBufferARB(This->buffer_type_hint, GL_WRITE_ONLY_ARB));
+            checkGLcall("glMapBufferARB");
+        }
+        if (!map)
+        {
+            LEAVE_GL();
+            ERR("Failed to map opengl buffer\n");
+            return;
+        }
+
+        while(This->modified_areas)
+        {
+            This->modified_areas--;
+            start = This->maps[This->modified_areas].offset;
+            len = This->maps[This->modified_areas].size;
+
+            memcpy(map + start, This->resource.allocatedMemory + start, len);
+
+            if (gl_info->supported[ARB_MAP_BUFFER_RANGE])
+            {
+                GL_EXTCALL(glFlushMappedBufferRange(This->buffer_type_hint, start, len));
+                checkGLcall("glFlushMappedBufferRange");
+            }
+            else if (This->flags & WINED3D_BUFFER_FLUSH)
+            {
+                GL_EXTCALL(glFlushMappedBufferRangeAPPLE(This->buffer_type_hint, start, len));
+                checkGLcall("glFlushMappedBufferRangeAPPLE");
+            }
+        }
+        GL_EXTCALL(glUnmapBufferARB(This->buffer_type_hint));
+        checkGLcall("glUnmapBufferARB");
+        LEAVE_GL();
+}
+
 static void STDMETHODCALLTYPE buffer_PreLoad(IWineD3DBuffer *iface)
 {
@@ -778,6 +940,8 @@
     unsigned int i, j;
     BYTE *data;
+    DWORD flags = This->flags & (WINED3D_BUFFER_NOSYNC | WINED3D_BUFFER_DISCARD);
 
     TRACE("iface %p\n", iface);
+    This->flags &= ~(WINED3D_BUFFER_NOSYNC | WINED3D_BUFFER_DISCARD);
 
     context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
@@ -840,4 +1004,17 @@
         }
         buffer_check_buffer_object_size(This);
+
+        /* The declaration changed, reload the whole buffer */
+        WARN("Reloading buffer because of decl change\n");
+        buffer_clear_dirty_areas(This);
+        if(!buffer_add_dirty_area(This, 0, 0))
+        {
+            ERR("buffer_add_dirty_area failed, this is not expected\n");
+            return;
+        }
+        /* Avoid unfenced updates, we might overwrite more areas of the buffer than the application
+         * cleared for unsynchronized updates
+         */
+        flags = 0;
     }
     else
@@ -867,16 +1044,4 @@
     }
 
-    if (decl_changed)
-    {
-        /* The declaration changed, reload the whole buffer */
-        WARN("Reloading buffer because of decl change\n");
-        buffer_clear_dirty_areas(This);
-        if(!buffer_add_dirty_area(This, 0, 0))
-        {
-            ERR("buffer_add_dirty_area failed, this is not expected\n");
-            return;
-        }
-    }
-
     if(This->buffer_type_hint == GL_ELEMENT_ARRAY_BUFFER_ARB)
     {
@@ -899,16 +1064,5 @@
         }
 
-        ENTER_GL();
-        GL_EXTCALL(glBindBufferARB(This->buffer_type_hint, This->buffer_object));
-        checkGLcall("glBindBufferARB");
-        while(This->modified_areas)
-        {
-            This->modified_areas--;
-            start = This->maps[This->modified_areas].offset;
-            len = This->maps[This->modified_areas].size;
-            GL_EXTCALL(glBufferSubDataARB(This->buffer_type_hint, start, len, This->resource.allocatedMemory + start));
-            checkGLcall("glBufferSubDataARB");
-        }
-        LEAVE_GL();
+        buffer_direct_upload(This, context->gl_info, flags);
 
         context_release(context);
@@ -1036,33 +1190,145 @@
 /* IWineD3DBuffer methods */
 
+static DWORD buffer_sanitize_flags(struct wined3d_buffer *buffer, DWORD flags)
+{
+    /* Not all flags make sense together, but Windows never returns an error. Catch the
+     * cases that could cause issues */
+    if(flags & WINED3DLOCK_READONLY)
+    {
+        if(flags & WINED3DLOCK_DISCARD)
+        {
+            WARN("WINED3DLOCK_READONLY combined with WINED3DLOCK_DISCARD, ignoring flags\n");
+            return 0;
+        }
+        if(flags & WINED3DLOCK_NOOVERWRITE)
+        {
+            WARN("WINED3DLOCK_READONLY combined with WINED3DLOCK_NOOVERWRITE, ignoring flags\n");
+            return 0;
+        }
+    }
+    else if((flags & (WINED3DLOCK_DISCARD | WINED3DLOCK_NOOVERWRITE)) == (WINED3DLOCK_DISCARD | WINED3DLOCK_NOOVERWRITE))
+    {
+        WARN("WINED3DLOCK_DISCARD and WINED3DLOCK_NOOVERWRITE used together, ignoring\n");
+        return 0;
+    }
+    else if (flags & (WINED3DLOCK_DISCARD | WINED3DLOCK_NOOVERWRITE) && !(buffer->resource.usage & WINED3DUSAGE_DYNAMIC))
+    {
+        WARN("DISCARD or NOOVERWRITE lock on non-dynamic buffer, ignoring\n");
+        return 0;
+    }
+
+    return flags;
+}
+
+static GLbitfield buffer_gl_map_flags(DWORD d3d_flags)
+{
+    GLbitfield ret = 0;
+
+    if (!(d3d_flags & WINED3DLOCK_READONLY)) ret = GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT;
+
+    if (d3d_flags & (WINED3DLOCK_DISCARD | WINED3DLOCK_NOOVERWRITE))
+    {
+        if(d3d_flags & WINED3DLOCK_DISCARD) ret |= GL_MAP_INVALIDATE_BUFFER_BIT;
+        ret |= GL_MAP_UNSYNCHRONIZED_BIT;
+    }
+    else
+    {
+        ret |= GL_MAP_READ_BIT;
+    }
+
+    return ret;
+}
+
 static HRESULT STDMETHODCALLTYPE buffer_Map(IWineD3DBuffer *iface, UINT offset, UINT size, BYTE **data, DWORD flags)
 {
     struct wined3d_buffer *This = (struct wined3d_buffer *)iface;
     LONG count;
+    BOOL dirty = buffer_is_dirty(This);
 
     TRACE("iface %p, offset %u, size %u, data %p, flags %#x\n", iface, offset, size, data, flags);
 
-    if (!buffer_add_dirty_area(This, offset, size)) return E_OUTOFMEMORY;
+    flags = buffer_sanitize_flags(This, flags);
+    if (!(flags & WINED3DLOCK_READONLY))
+    {
+        if (!buffer_add_dirty_area(This, offset, size)) return E_OUTOFMEMORY;
+    }
 
     count = InterlockedIncrement(&This->lock_count);
 
-    if(!(This->flags & WINED3D_BUFFER_DOUBLEBUFFER) && This->buffer_object)
-    {
-        if(count == 1)
-        {
-            IWineD3DDeviceImpl *device = This->resource.device;
-            struct wined3d_context *context;
-
-            if(This->buffer_type_hint == GL_ELEMENT_ARRAY_BUFFER_ARB)
-            {
-                IWineD3DDeviceImpl_MarkStateDirty(This->resource.device, STATE_INDEXBUFFER);
-            }
-
-            context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
-            ENTER_GL();
-            GL_EXTCALL(glBindBufferARB(This->buffer_type_hint, This->buffer_object));
-            This->resource.allocatedMemory = GL_EXTCALL(glMapBufferARB(This->buffer_type_hint, GL_READ_WRITE_ARB));
-            LEAVE_GL();
-            context_release(context);
+    if (This->buffer_object)
+    {
+        if(!(This->flags & WINED3D_BUFFER_DOUBLEBUFFER))
+        {
+            if(count == 1)
+            {
+                IWineD3DDeviceImpl *device = This->resource.device;
+                struct wined3d_context *context;
+                const struct wined3d_gl_info *gl_info;
+
+                if(This->buffer_type_hint == GL_ELEMENT_ARRAY_BUFFER_ARB)
+                {
+                    IWineD3DDeviceImpl_MarkStateDirty(This->resource.device, STATE_INDEXBUFFER);
+                }
+
+                context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
+                gl_info = context->gl_info;
+                ENTER_GL();
+                GL_EXTCALL(glBindBufferARB(This->buffer_type_hint, This->buffer_object));
+
+                if (gl_info->supported[ARB_MAP_BUFFER_RANGE])
+                {
+                    GLbitfield mapflags = buffer_gl_map_flags(flags);
+                    This->resource.allocatedMemory = GL_EXTCALL(glMapBufferRange(This->buffer_type_hint, 0,
+                                                                                This->resource.size, mapflags));
+                    checkGLcall("glMapBufferRange");
+                }
+                else
+                {
+                    if(This->flags & WINED3D_BUFFER_APPLESYNC)
+                    {
+                        LEAVE_GL();
+                        buffer_sync_apple(This, flags, gl_info);
+                        ENTER_GL();
+                    }
+                    This->resource.allocatedMemory = GL_EXTCALL(glMapBufferARB(This->buffer_type_hint, GL_READ_WRITE_ARB));
+                    checkGLcall("glMapBufferARB");
+                }
+                LEAVE_GL();
+
+                if (((DWORD_PTR) This->resource.allocatedMemory) & (RESOURCE_ALIGNMENT - 1))
+                {
+                    WARN("Pointer %p is not %u byte aligned, falling back to double buffered operation\n",
+                        This->resource.allocatedMemory, RESOURCE_ALIGNMENT);
+
+                    ENTER_GL();
+                    GL_EXTCALL(glUnmapBufferARB(This->buffer_type_hint));
+                    checkGLcall("glUnmapBufferARB");
+                    LEAVE_GL();
+                    This->resource.allocatedMemory = NULL;
+
+                    buffer_get_sysmem(This);
+                    TRACE("New pointer is %p\n", This->resource.allocatedMemory);
+                }
+                context_release(context);
+            }
+        }
+        else
+        {
+            if (dirty)
+            {
+                if (This->flags & WINED3D_BUFFER_NOSYNC && !(flags & WINED3DLOCK_NOOVERWRITE))
+                {
+                    This->flags &= ~WINED3D_BUFFER_NOSYNC;
+                }
+            }
+            else if(flags & WINED3DLOCK_NOOVERWRITE)
+            {
+                This->flags |= WINED3D_BUFFER_NOSYNC;
+            }
+
+            if (flags & WINED3DLOCK_DISCARD)
+            {
+                This->flags |= WINED3D_BUFFER_DISCARD;
+            }
         }
     }
@@ -1103,4 +1369,5 @@
     {
         IWineD3DDeviceImpl *device = This->resource.device;
+        const struct wined3d_gl_info *gl_info;
         struct wined3d_context *context;
 
@@ -1111,8 +1378,19 @@
 
         context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
+        gl_info = context->gl_info;
         ENTER_GL();
         GL_EXTCALL(glBindBufferARB(This->buffer_type_hint, This->buffer_object));
 
-        if(This->flags & WINED3D_BUFFER_FLUSH)
+        if (gl_info->supported[ARB_MAP_BUFFER_RANGE])
+        {
+            for(i = 0; i < This->modified_areas; i++)
+            {
+                GL_EXTCALL(glFlushMappedBufferRange(This->buffer_type_hint,
+                                                    This->maps[i].offset,
+                                                    This->maps[i].size));
+                checkGLcall("glFlushMappedBufferRange");
+            }
+        }
+        else if (This->flags & WINED3D_BUFFER_FLUSH)
         {
             for(i = 0; i < This->modified_areas; i++)
@@ -1181,5 +1459,5 @@
         const char *data, IUnknown *parent, const struct wined3d_parent_ops *parent_ops)
 {
-    const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(format, &device->adapter->gl_info);
+    const struct wined3d_format_desc *format_desc = getFormatDescEntry(format, &device->adapter->gl_info);
     HRESULT hr;
     const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
@@ -1206,6 +1484,5 @@
             debug_d3dformat(buffer->resource.format_desc->format), buffer->resource.allocatedMemory, buffer);
 
-    /* TODO: GL_ARB_map_buffer_range */
-    dynamic_buffer_ok = gl_info->supported[APPLE_FLUSH_BUFFER_RANGE];
+    dynamic_buffer_ok = gl_info->supported[APPLE_FLUSH_BUFFER_RANGE] || gl_info->supported[ARB_MAP_BUFFER_RANGE];
 
     /* Observations show that drawStridedSlow is faster on dynamic VBs than converting +
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/context.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/context.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/context.c	(revision 28475)
@@ -124,15 +124,16 @@
 
 /* GL locking is done by the caller */
-static void context_apply_attachment_filter_states(IWineD3DSurface *surface, BOOL force_preload)
-{
-    const IWineD3DSurfaceImpl *surface_impl = (IWineD3DSurfaceImpl *)surface;
-    IWineD3DDeviceImpl *device = surface_impl->resource.device;
+static void context_apply_attachment_filter_states(IWineD3DSurfaceImpl *surface)
+{
     IWineD3DBaseTextureImpl *texture_impl;
-    BOOL update_minfilter = FALSE;
-    BOOL update_magfilter = FALSE;
 
     /* Update base texture states array */
-    if (SUCCEEDED(IWineD3DSurface_GetContainer(surface, &IID_IWineD3DBaseTexture, (void **)&texture_impl)))
-    {
+    if (SUCCEEDED(IWineD3DSurface_GetContainer((IWineD3DSurface *)surface,
+            &IID_IWineD3DBaseTexture, (void **)&texture_impl)))
+    {
+        IWineD3DDeviceImpl *device = surface->resource.device;
+        BOOL update_minfilter = FALSE;
+        BOOL update_magfilter = FALSE;
+
         if (texture_impl->baseTexture.texture_rgb.states[WINED3DTEXSTA_MINFILTER] != WINED3DTEXF_POINT
             || texture_impl->baseTexture.texture_rgb.states[WINED3DTEXSTA_MIPFILTER] != WINED3DTEXF_NONE)
@@ -156,40 +157,41 @@
 
         IWineD3DBaseTexture_Release((IWineD3DBaseTexture *)texture_impl);
-    }
-
-    if (update_minfilter || update_magfilter || force_preload)
-    {
-        GLenum target, bind_target;
-        GLint old_binding;
-
-        target = surface_impl->texture_target;
-        if (target == GL_TEXTURE_2D)
-        {
-            bind_target = GL_TEXTURE_2D;
-            glGetIntegerv(GL_TEXTURE_BINDING_2D, &old_binding);
-        } else if (target == GL_TEXTURE_RECTANGLE_ARB) {
-            bind_target = GL_TEXTURE_RECTANGLE_ARB;
-            glGetIntegerv(GL_TEXTURE_BINDING_RECTANGLE_ARB, &old_binding);
-        } else {
-            bind_target = GL_TEXTURE_CUBE_MAP_ARB;
-            glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP_ARB, &old_binding);
-        }
-
-        surface_internal_preload(surface, SRGB_RGB);
-
-        glBindTexture(bind_target, surface_impl->texture_name);
-        if (update_minfilter) glTexParameteri(bind_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-        if (update_magfilter) glTexParameteri(bind_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-        glBindTexture(bind_target, old_binding);
-    }
-
-    checkGLcall("apply_attachment_filter_states()");
+
+        if (update_minfilter || update_magfilter)
+        {
+            GLenum target, bind_target;
+            GLint old_binding;
+
+            target = surface->texture_target;
+            if (target == GL_TEXTURE_2D)
+            {
+                bind_target = GL_TEXTURE_2D;
+                glGetIntegerv(GL_TEXTURE_BINDING_2D, &old_binding);
+            }
+            else if (target == GL_TEXTURE_RECTANGLE_ARB)
+            {
+                bind_target = GL_TEXTURE_RECTANGLE_ARB;
+                glGetIntegerv(GL_TEXTURE_BINDING_RECTANGLE_ARB, &old_binding);
+            }
+            else
+            {
+                bind_target = GL_TEXTURE_CUBE_MAP_ARB;
+                glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP_ARB, &old_binding);
+            }
+
+            glBindTexture(bind_target, surface->texture_name);
+            if (update_minfilter) glTexParameteri(bind_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+            if (update_magfilter) glTexParameteri(bind_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+            glBindTexture(bind_target, old_binding);
+        }
+
+        checkGLcall("apply_attachment_filter_states()");
+    }
 }
 
 /* GL locking is done by the caller */
 void context_attach_depth_stencil_fbo(struct wined3d_context *context,
-        GLenum fbo_target, IWineD3DSurface *depth_stencil, BOOL use_render_buffer)
-{
-    IWineD3DSurfaceImpl *depth_stencil_impl = (IWineD3DSurfaceImpl *)depth_stencil;
+        GLenum fbo_target, IWineD3DSurfaceImpl *depth_stencil, BOOL use_render_buffer)
+{
     const struct wined3d_gl_info *gl_info = context->gl_info;
 
@@ -198,12 +200,12 @@
     if (depth_stencil)
     {
-        DWORD format_flags = depth_stencil_impl->resource.format_desc->Flags;
-
-        if (use_render_buffer && depth_stencil_impl->current_renderbuffer)
+        DWORD format_flags = depth_stencil->resource.format_desc->Flags;
+
+        if (use_render_buffer && depth_stencil->current_renderbuffer)
         {
             if (format_flags & WINED3DFMT_FLAG_DEPTH)
             {
                 gl_info->fbo_ops.glFramebufferRenderbuffer(fbo_target, GL_DEPTH_ATTACHMENT,
-                        GL_RENDERBUFFER, depth_stencil_impl->current_renderbuffer->id);
+                        GL_RENDERBUFFER, depth_stencil->current_renderbuffer->id);
                 checkGLcall("glFramebufferRenderbuffer()");
             }
@@ -212,5 +214,5 @@
             {
                 gl_info->fbo_ops.glFramebufferRenderbuffer(fbo_target, GL_STENCIL_ATTACHMENT,
-                        GL_RENDERBUFFER, depth_stencil_impl->current_renderbuffer->id);
+                        GL_RENDERBUFFER, depth_stencil->current_renderbuffer->id);
                 checkGLcall("glFramebufferRenderbuffer()");
             }
@@ -218,11 +220,12 @@
         else
         {
-            context_apply_attachment_filter_states(depth_stencil, TRUE);
+            surface_prepare_texture(depth_stencil, gl_info, FALSE);
+            context_apply_attachment_filter_states(depth_stencil);
 
             if (format_flags & WINED3DFMT_FLAG_DEPTH)
             {
                 gl_info->fbo_ops.glFramebufferTexture2D(fbo_target, GL_DEPTH_ATTACHMENT,
-                        depth_stencil_impl->texture_target, depth_stencil_impl->texture_name,
-                        depth_stencil_impl->texture_level);
+                        depth_stencil->texture_target, depth_stencil->texture_name,
+                        depth_stencil->texture_level);
                 checkGLcall("glFramebufferTexture2D()");
             }
@@ -231,6 +234,6 @@
             {
                 gl_info->fbo_ops.glFramebufferTexture2D(fbo_target, GL_STENCIL_ATTACHMENT,
-                        depth_stencil_impl->texture_target, depth_stencil_impl->texture_name,
-                        depth_stencil_impl->texture_level);
+                        depth_stencil->texture_target, depth_stencil->texture_name,
+                        depth_stencil->texture_level);
                 checkGLcall("glFramebufferTexture2D()");
             }
@@ -261,7 +264,6 @@
 /* GL locking is done by the caller */
 void context_attach_surface_fbo(const struct wined3d_context *context,
-        GLenum fbo_target, DWORD idx, IWineD3DSurface *surface)
-{
-    const IWineD3DSurfaceImpl *surface_impl = (IWineD3DSurfaceImpl *)surface;
+        GLenum fbo_target, DWORD idx, IWineD3DSurfaceImpl *surface)
+{
     const struct wined3d_gl_info *gl_info = context->gl_info;
 
@@ -270,8 +272,9 @@
     if (surface)
     {
-        context_apply_attachment_filter_states(surface, TRUE);
-
-        gl_info->fbo_ops.glFramebufferTexture2D(fbo_target, GL_COLOR_ATTACHMENT0 + idx, surface_impl->texture_target,
-                surface_impl->texture_name, surface_impl->texture_level);
+        surface_prepare_texture(surface, gl_info, FALSE);
+        context_apply_attachment_filter_states(surface);
+
+        gl_info->fbo_ops.glFramebufferTexture2D(fbo_target, GL_COLOR_ATTACHMENT0 + idx, surface->texture_target,
+                surface->texture_name, surface->texture_level);
         checkGLcall("glFramebufferTexture2D()");
     }
@@ -307,5 +310,5 @@
         for (i = 0; i < gl_info->limits.buffers; ++i)
         {
-            attachment = (IWineD3DSurfaceImpl *)context->current_fbo->render_targets[i];
+            attachment = context->current_fbo->render_targets[i];
             if (attachment)
             {
@@ -315,5 +318,5 @@
             }
         }
-        attachment = (IWineD3DSurfaceImpl *)context->current_fbo->depth_stencil;
+        attachment = context->current_fbo->depth_stencil;
         if (attachment)
         {
@@ -327,6 +330,6 @@
 static struct fbo_entry *context_create_fbo_entry(struct wined3d_context *context)
 {
-    IWineD3DDeviceImpl *device = ((IWineD3DSurfaceImpl *)context->surface)->resource.device;
     const struct wined3d_gl_info *gl_info = context->gl_info;
+    IWineD3DDeviceImpl *device = context->swapchain->device;
     struct fbo_entry *entry;
 
@@ -334,5 +337,5 @@
     entry->render_targets = HeapAlloc(GetProcessHeap(), 0, gl_info->limits.buffers * sizeof(*entry->render_targets));
     memcpy(entry->render_targets, device->render_targets, gl_info->limits.buffers * sizeof(*entry->render_targets));
-    entry->depth_stencil = device->stencilBufferTarget;
+    entry->depth_stencil = (IWineD3DSurfaceImpl *)device->stencilBufferTarget;
     entry->attached = FALSE;
     entry->id = 0;
@@ -344,6 +347,6 @@
 static void context_reuse_fbo_entry(struct wined3d_context *context, struct fbo_entry *entry)
 {
-    IWineD3DDeviceImpl *device = ((IWineD3DSurfaceImpl *)context->surface)->resource.device;
     const struct wined3d_gl_info *gl_info = context->gl_info;
+    IWineD3DDeviceImpl *device = context->swapchain->device;
 
     context_bind_fbo(context, GL_FRAMEBUFFER, &entry->id);
@@ -351,5 +354,5 @@
 
     memcpy(entry->render_targets, device->render_targets, gl_info->limits.buffers * sizeof(*entry->render_targets));
-    entry->depth_stencil = device->stencilBufferTarget;
+    entry->depth_stencil = (IWineD3DSurfaceImpl *)device->stencilBufferTarget;
     entry->attached = FALSE;
 }
@@ -373,6 +376,6 @@
 static struct fbo_entry *context_find_fbo_entry(struct wined3d_context *context)
 {
-    IWineD3DDeviceImpl *device = ((IWineD3DSurfaceImpl *)context->surface)->resource.device;
     const struct wined3d_gl_info *gl_info = context->gl_info;
+    IWineD3DDeviceImpl *device = context->swapchain->device;
     struct fbo_entry *entry;
 
@@ -381,5 +384,5 @@
         if (!memcmp(entry->render_targets,
                 device->render_targets, gl_info->limits.buffers * sizeof(*entry->render_targets))
-                && entry->depth_stencil == device->stencilBufferTarget)
+                && entry->depth_stencil == (IWineD3DSurfaceImpl *)device->stencilBufferTarget)
         {
             list_remove(&entry->entry);
@@ -409,6 +412,6 @@
 static void context_apply_fbo_entry(struct wined3d_context *context, struct fbo_entry *entry)
 {
-    IWineD3DDeviceImpl *device = ((IWineD3DSurfaceImpl *)context->surface)->resource.device;
     const struct wined3d_gl_info *gl_info = context->gl_info;
+    IWineD3DDeviceImpl *device = context->swapchain->device;
     unsigned int i;
 
@@ -420,5 +423,5 @@
         for (i = 0; i < gl_info->limits.buffers; ++i)
         {
-            IWineD3DSurface *render_target = device->render_targets[i];
+            IWineD3DSurfaceImpl *render_target = (IWineD3DSurfaceImpl *)device->render_targets[i];
             context_attach_surface_fbo(context, GL_FRAMEBUFFER, i, render_target);
         }
@@ -432,5 +435,5 @@
             surface_set_compatible_renderbuffer(device->stencilBufferTarget, w, h);
         }
-        context_attach_depth_stencil_fbo(context, GL_FRAMEBUFFER, device->stencilBufferTarget, TRUE);
+        context_attach_depth_stencil_fbo(context, GL_FRAMEBUFFER, (IWineD3DSurfaceImpl *)device->stencilBufferTarget, TRUE);
 
         entry->attached = TRUE;
@@ -441,8 +444,8 @@
         {
             if (device->render_targets[i])
-                context_apply_attachment_filter_states(device->render_targets[i], FALSE);
+                context_apply_attachment_filter_states((IWineD3DSurfaceImpl *)device->render_targets[i]);
         }
         if (device->stencilBufferTarget)
-            context_apply_attachment_filter_states(device->stencilBufferTarget, FALSE);
+            context_apply_attachment_filter_states((IWineD3DSurfaceImpl *)device->stencilBufferTarget);
     }
 
@@ -464,4 +467,10 @@
     {
         context_destroy_fbo_entry(context, entry);
+    }
+
+    if (context->rebind_fbo)
+    {
+        context_bind_fbo(context, GL_FRAMEBUFFER, NULL);
+        context->rebind_fbo = FALSE;
     }
 
@@ -544,30 +553,36 @@
     if (context->free_event_query_count)
     {
-        query->id = context->free_event_queries[--context->free_event_query_count];
+        query->object = context->free_event_queries[--context->free_event_query_count];
     }
     else
     {
-        if (gl_info->supported[APPLE_FENCE])
+        if (gl_info->supported[ARB_SYNC])
+        {
+            /* Using ARB_sync, not much to do here. */
+            query->object.sync = NULL;
+            TRACE("Allocated event query %p in context %p.\n", query->object.sync, context);
+        }
+        else if (gl_info->supported[APPLE_FENCE])
         {
             ENTER_GL();
-            GL_EXTCALL(glGenFencesAPPLE(1, &query->id));
+            GL_EXTCALL(glGenFencesAPPLE(1, &query->object.id));
             checkGLcall("glGenFencesAPPLE");
             LEAVE_GL();
 
-            TRACE("Allocated event query %u in context %p.\n", query->id, context);
+            TRACE("Allocated event query %u in context %p.\n", query->object.id, context);
         }
         else if(gl_info->supported[NV_FENCE])
         {
             ENTER_GL();
-            GL_EXTCALL(glGenFencesNV(1, &query->id));
+            GL_EXTCALL(glGenFencesNV(1, &query->object.id));
             checkGLcall("glGenFencesNV");
             LEAVE_GL();
 
-            TRACE("Allocated event query %u in context %p.\n", query->id, context);
+            TRACE("Allocated event query %u in context %p.\n", query->object.id, context);
         }
         else
         {
             WARN("Event queries not supported, not allocating query id.\n");
-            query->id = 0;
+            query->object.id = 0;
         }
     }
@@ -587,10 +602,10 @@
     {
         UINT new_size = context->free_event_query_size << 1;
-        GLuint *new_data = HeapReAlloc(GetProcessHeap(), 0, context->free_event_queries,
+        union wined3d_gl_query_object *new_data = HeapReAlloc(GetProcessHeap(), 0, context->free_event_queries,
                 new_size * sizeof(*context->free_event_queries));
 
         if (!new_data)
         {
-            ERR("Failed to grow free list, leaking query %u in context %p.\n", query->id, context);
+            ERR("Failed to grow free list, leaking query %u in context %p.\n", query->object.id, context);
             return;
         }
@@ -600,5 +615,5 @@
     }
 
-    context->free_event_queries[context->free_event_query_count++] = query->id;
+    context->free_event_queries[context->free_event_query_count++] = query->object;
 }
 
@@ -626,5 +641,5 @@
                     UINT j;
 
-                    if (entry->depth_stencil == (IWineD3DSurface *)resource)
+                    if (entry->depth_stencil == (IWineD3DSurfaceImpl *)resource)
                     {
                         list_remove(&entry->entry);
@@ -635,5 +650,5 @@
                     for (j = 0; j < gl_info->limits.buffers; ++j)
                     {
-                        if (entry->render_targets[j] == (IWineD3DSurface *)resource)
+                        if (entry->render_targets[j] == (IWineD3DSurfaceImpl *)resource)
                         {
                             list_remove(&entry->entry);
@@ -653,4 +668,113 @@
 }
 
+void context_surface_update(struct wined3d_context *context, IWineD3DSurfaceImpl *surface)
+{
+    const struct wined3d_gl_info *gl_info = context->gl_info;
+    struct fbo_entry *entry = context->current_fbo;
+    unsigned int i;
+
+    if (!entry || context->rebind_fbo) return;
+
+    for (i = 0; i < gl_info->limits.buffers; ++i)
+    {
+        if (surface == entry->render_targets[i])
+        {
+            TRACE("Updated surface %p is bound as color attachment %u to the current FBO.\n", surface, i);
+            context->rebind_fbo = TRUE;
+            return;
+        }
+    }
+
+    if (surface == entry->depth_stencil)
+    {
+        TRACE("Updated surface %p is bound as depth attachment to the current FBO.\n", surface);
+        context->rebind_fbo = TRUE;
+    }
+}
+
+static BOOL context_set_pixel_format(const struct wined3d_gl_info *gl_info, HDC dc, int format)
+{
+    int current = GetPixelFormat(dc);
+
+    if (current == format) return TRUE;
+
+    if (!current)
+    {
+        if (!SetPixelFormat(dc, format, NULL))
+        {
+            ERR("Failed to set pixel format %d on device context %p, last error %#x.\n",
+                    format, dc, GetLastError());
+            return FALSE;
+        }
+        return TRUE;
+    }
+
+    /* By default WGL doesn't allow pixel format adjustments but we need it
+     * here. For this reason there's a Wine specific wglSetPixelFormat()
+     * which allows us to set the pixel format multiple times. Only use it
+     * when really needed. */
+    if (gl_info->supported[WGL_WINE_PIXEL_FORMAT_PASSTHROUGH])
+    {
+        if (!GL_EXTCALL(wglSetPixelFormatWINE(dc, format, NULL)))
+        {
+            ERR("wglSetPixelFormatWINE failed to set pixel format %d on device context %p.\n",
+                    format, dc);
+            return FALSE;
+        }
+        return TRUE;
+    }
+
+    /* OpenGL doesn't allow pixel format adjustments. Print an error and
+     * continue using the old format. There's a big chance that the old
+     * format works although with a performance hit and perhaps rendering
+     * errors. */
+    ERR("Unable to set pixel format %d on device context %p. Already using format %d.\n",
+            format, dc, current);
+    return TRUE;
+}
+
+static void context_update_window(struct wined3d_context *context)
+{
+    TRACE("Updating context %p window from %p to %p.\n",
+            context, context->win_handle, context->swapchain->win_handle);
+
+    if (context->valid)
+    {
+        if (!ReleaseDC(context->win_handle, context->hdc))
+        {
+            ERR("Failed to release device context %p, last error %#x.\n",
+                    context->hdc, GetLastError());
+        }
+    }
+    else context->valid = 1;
+
+    context->win_handle = context->swapchain->win_handle;
+
+    if (!(context->hdc = GetDC(context->win_handle)))
+    {
+        ERR("Failed to get a device context for window %p.\n", context->win_handle);
+        goto err;
+    }
+
+    if (!context_set_pixel_format(context->gl_info, context->hdc, context->pixel_format))
+    {
+        ERR("Failed to set pixel format %d on device context %p.\n",
+                context->pixel_format, context->hdc);
+        goto err;
+    }
+
+    if (!pwglMakeCurrent(context->hdc, context->glCtx))
+    {
+        ERR("Failed to make GL context %p current on device context %p, last error %#x.\n",
+                context->glCtx, context->hdc, GetLastError());
+        goto err;
+    }
+
+    return;
+
+err:
+    context->valid = 0;
+}
+
 static void context_validate(struct wined3d_context *context)
 {
@@ -663,4 +787,7 @@
         context->valid = 0;
     }
+
+    if (context->win_handle != context->swapchain->win_handle)
+        context_update_window(context);
 }
 
@@ -673,4 +800,5 @@
     HGLRC restore_ctx;
     HDC restore_dc;
+    unsigned int i;
 
     restore_ctx = pwglGetCurrentContext();
@@ -694,6 +822,10 @@
         if (context->valid)
         {
-            if (gl_info->supported[APPLE_FENCE]) GL_EXTCALL(glDeleteFencesAPPLE(1, &event_query->id));
-            else if (gl_info->supported[NV_FENCE]) GL_EXTCALL(glDeleteFencesNV(1, &event_query->id));
+            if (gl_info->supported[ARB_SYNC])
+            {
+                if (event_query->object.sync) GL_EXTCALL(glDeleteSync(event_query->object.sync));
+            }
+            else if (gl_info->supported[APPLE_FENCE]) GL_EXTCALL(glDeleteFencesAPPLE(1, &event_query->object.id));
+            else if (gl_info->supported[NV_FENCE]) GL_EXTCALL(glDeleteFencesNV(1, &event_query->object.id));
         }
         event_query->context = NULL;
@@ -732,8 +864,22 @@
             GL_EXTCALL(glDeleteQueriesARB(context->free_occlusion_query_count, context->free_occlusion_queries));
 
-        if (gl_info->supported[APPLE_FENCE])
-            GL_EXTCALL(glDeleteFencesAPPLE(context->free_event_query_count, context->free_event_queries));
+        if (gl_info->supported[ARB_SYNC])
+        {
+            if (event_query->object.sync) GL_EXTCALL(glDeleteSync(event_query->object.sync));
+        }
+        else if (gl_info->supported[APPLE_FENCE])
+        {
+            for (i = 0; i < context->free_event_query_count; ++i)
+            {
+                GL_EXTCALL(glDeleteFencesAPPLE(1, &context->free_event_queries[i].id));
+            }
+        }
         else if (gl_info->supported[NV_FENCE])
-            GL_EXTCALL(glDeleteFencesNV(context->free_event_query_count, context->free_event_queries));
+        {
+            for (i = 0; i < context->free_event_query_count; ++i)
+            {
+                GL_EXTCALL(glDeleteFencesNV(1, &context->free_event_queries[i].id));
+            }
+        }
 
         checkGLcall("context cleanup");
@@ -759,13 +905,5 @@
     }
 
-    if (context->pbuffer)
-    {
-        GL_EXTCALL(wglReleasePbufferDCARB(context->pbuffer, context->hdc));
-        GL_EXTCALL(wglDestroyPbufferARB(context->pbuffer));
-    }
-    else
-    {
-        ReleaseDC(context->win_handle, context->hdc);
-    }
+    ReleaseDC(context->win_handle, context->hdc);
 
     if (!pwglDeleteContext(context->glCtx))
@@ -915,66 +1053,8 @@
 }
 
-/*****************************************************************************
- * AddContextToArray
- *
- * Adds a context to the context array. Helper function for context_create().
- *
- * This method is not called in performance-critical code paths, only when a
- * new render target or swapchain is created. Thus performance is not an issue
- * here.
- *
- * Params:
- *  This: Device to add the context for
- *  hdc: device context
- *  glCtx: WGL context to add
- *  pbuffer: optional pbuffer used with this context
- *
- *****************************************************************************/
-static struct wined3d_context *AddContextToArray(IWineD3DDeviceImpl *This,
-        HWND win_handle, HDC hdc, HGLRC glCtx, HPBUFFERARB pbuffer)
-{
-    struct wined3d_context **oldArray = This->contexts;
-    DWORD state;
-
-    This->contexts = HeapAlloc(GetProcessHeap(), 0, sizeof(*This->contexts) * (This->numContexts + 1));
-    if(This->contexts == NULL) {
-        ERR("Unable to grow the context array\n");
-        This->contexts = oldArray;
-        return NULL;
-    }
-    if(oldArray) {
-        memcpy(This->contexts, oldArray, sizeof(*This->contexts) * This->numContexts);
-    }
-
-    This->contexts[This->numContexts] = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(**This->contexts));
-    if(This->contexts[This->numContexts] == NULL) {
-        ERR("Unable to allocate a new context\n");
-        HeapFree(GetProcessHeap(), 0, This->contexts);
-        This->contexts = oldArray;
-        return NULL;
-    }
-
-    This->contexts[This->numContexts]->hdc = hdc;
-    This->contexts[This->numContexts]->glCtx = glCtx;
-    This->contexts[This->numContexts]->pbuffer = pbuffer;
-    This->contexts[This->numContexts]->win_handle = win_handle;
-    HeapFree(GetProcessHeap(), 0, oldArray);
-
-    /* Mark all states dirty to force a proper initialization of the states on the first use of the context
-     */
-    for(state = 0; state <= STATE_HIGHEST; state++) {
-        if (This->StateTable[state].representative)
-            Context_MarkStateDirty(This->contexts[This->numContexts], state, This->StateTable);
-    }
-
-    This->numContexts++;
-    TRACE("Created context %p\n", This->contexts[This->numContexts - 1]);
-    return This->contexts[This->numContexts - 1];
-}
-
 /* This function takes care of WineD3D pixel format selection. */
 static int WineD3D_ChoosePixelFormat(IWineD3DDeviceImpl *This, HDC hdc,
-        const struct GlPixelFormatDesc *color_format_desc, const struct GlPixelFormatDesc *ds_format_desc,
-        BOOL auxBuffers, int numSamples, BOOL pbuffer, BOOL findCompatible)
+        const struct wined3d_format_desc *color_format_desc, const struct wined3d_format_desc *ds_format_desc,
+        BOOL auxBuffers, int numSamples, BOOL findCompatible)
 {
     int iPixelFormat=0;
@@ -1006,7 +1086,7 @@
     int nCfgs = This->adapter->nCfgs;
 
-    TRACE("ColorFormat=%s, DepthStencilFormat=%s, auxBuffers=%d, numSamples=%d, pbuffer=%d, findCompatible=%d\n",
+    TRACE("ColorFormat=%s, DepthStencilFormat=%s, auxBuffers=%d, numSamples=%d, findCompatible=%d\n",
           debug_d3dformat(color_format_desc->format), debug_d3dformat(ds_format_desc->format),
-          auxBuffers, numSamples, pbuffer, findCompatible);
+          auxBuffers, numSamples, findCompatible);
 
     if (!getColorBits(color_format_desc, &redBits, &greenBits, &blueBits, &alphaBits, &colorBits))
@@ -1015,21 +1095,4 @@
                 debug_d3dformat(color_format_desc->format), color_format_desc->format);
         return 0;
-    }
-
-    /* In WGL both color, depth and stencil are features of a pixel format. In case of D3D they are separate.
-     * You are able to add a depth + stencil surface at a later stage when you need it.
-     * In order to support this properly in WineD3D we need the ability to recreate the opengl context and
-     * drawable when this is required. This is very tricky as we need to reapply ALL opengl states for the new
-     * context, need torecreate shaders, textures and other resources.
-     *
-     * The context manager already takes care of the state problem and for the other tasks code from Reset
-     * can be used. These changes are way to risky during the 1.0 code freeze which is taking place right now.
-     * Likely a lot of other new bugs will be exposed. For that reason request a depth stencil surface all the
-     * time. It can cause a slight performance hit but fixes a lot of regressions. A fixme reminds of that this
-     * issue needs to be fixed. */
-    if (ds_format_desc->format != WINED3DFMT_D24_UNORM_S8_UINT)
-    {
-        FIXME("Add OpenGL context recreation support to SetDepthStencilSurface\n");
-        ds_format_desc = getFormatDescEntry(WINED3DFMT_D24_UNORM_S8_UINT, &This->adapter->gl_info);
     }
 
@@ -1046,14 +1109,10 @@
                 continue;
 
-            /* In window mode (!pbuffer) we need a window drawable format and double buffering. */
-            if(!pbuffer && !(cfg->windowDrawable && cfg->doubleBuffer))
+            /* In window mode we need a window drawable format and double buffering. */
+            if(!(cfg->windowDrawable && cfg->doubleBuffer))
                 continue;
 
             /* We like to have aux buffers in backbuffer mode */
             if(auxBuffers && !cfg->auxBuffers && matches[matchtry].require_aux)
-                continue;
-
-            /* In pbuffer-mode we need a pbuffer-capable format but we don't want double buffering */
-            if(pbuffer && (!cfg->pbufferDrawable || cfg->doubleBuffer))
                 continue;
 
@@ -1154,5 +1213,5 @@
  * context_create
  *
- * Creates a new context for a window, or a pbuffer context.
+ * Creates a new context.
  *
  * * Params:
@@ -1160,175 +1219,117 @@
  *  target: Surface this context will render to
  *  win_handle: handle to the window which we are drawing to
- *  create_pbuffer: tells whether to create a pbuffer or not
  *  pPresentParameters: contains the pixelformats to use for onscreen rendering
  *
  *****************************************************************************/
-struct wined3d_context *context_create(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *target,
-        HWND win_handle, BOOL create_pbuffer, const WINED3DPRESENT_PARAMETERS *pPresentParms)
-{
-    const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
-    struct wined3d_context *ret = NULL;
-    HPBUFFERARB pbuffer = NULL;
+struct wined3d_context *context_create(IWineD3DSwapChainImpl *swapchain, IWineD3DSurfaceImpl *target,
+        const struct wined3d_format_desc *ds_format_desc)
+{
+    IWineD3DDeviceImpl *device = swapchain->device;
+    const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
+    const struct wined3d_format_desc *color_format_desc;
+    struct wined3d_context *ret;
+    PIXELFORMATDESCRIPTOR pfd;
+    BOOL auxBuffers = FALSE;
+    int numSamples = 0;
+    int pixel_format;
     unsigned int s;
+    DWORD state;
     HGLRC ctx;
     HDC hdc;
 
-    TRACE("(%p): Creating a %s context for render target %p\n", This, create_pbuffer ? "offscreen" : "onscreen", target);
-
-    if(create_pbuffer) {
-        HDC hdc_parent = GetDC(win_handle);
-        int iPixelFormat = 0;
-
-        IWineD3DSurface *StencilSurface = This->stencilBufferTarget;
-        const struct GlPixelFormatDesc *ds_format_desc = StencilSurface
-                ? ((IWineD3DSurfaceImpl *)StencilSurface)->resource.format_desc
-                : getFormatDescEntry(WINED3DFMT_UNKNOWN, &This->adapter->gl_info);
-
-        /* Try to find a pixel format with pbuffer support. */
-        iPixelFormat = WineD3D_ChoosePixelFormat(This, hdc_parent, target->resource.format_desc,
-                ds_format_desc, FALSE /* auxBuffers */, 0 /* numSamples */, TRUE /* PBUFFER */,
-                FALSE /* findCompatible */);
-        if(!iPixelFormat) {
-            TRACE("Trying to locate a compatible pixel format because an exact match failed.\n");
-
-            /* For some reason we weren't able to find a format, try to find something instead of crashing.
-             * A reason for failure could have been wglChoosePixelFormatARB strictness. */
-            iPixelFormat = WineD3D_ChoosePixelFormat(This, hdc_parent, target->resource.format_desc,
-                    ds_format_desc, FALSE /* auxBuffer */, 0 /* numSamples */, TRUE /* PBUFFER */,
-                    TRUE /* findCompatible */);
-        }
-
-        /* This shouldn't happen as ChoosePixelFormat always returns something */
-        if(!iPixelFormat) {
-            ERR("Unable to locate a pixel format for a pbuffer\n");
-            ReleaseDC(win_handle, hdc_parent);
-            goto out;
-        }
-
-        TRACE("Creating a pBuffer drawable for the new context\n");
-        pbuffer = GL_EXTCALL(wglCreatePbufferARB(hdc_parent, iPixelFormat, target->currentDesc.Width, target->currentDesc.Height, 0));
-        if(!pbuffer) {
-            ERR("Cannot create a pbuffer\n");
-            ReleaseDC(win_handle, hdc_parent);
-            goto out;
-        }
-
-        /* In WGL a pbuffer is 'wrapped' inside a HDC to 'fool' wglMakeCurrent */
-        hdc = GL_EXTCALL(wglGetPbufferDCARB(pbuffer));
-        if(!hdc) {
-            ERR("Cannot get a HDC for pbuffer (%p)\n", pbuffer);
-            GL_EXTCALL(wglDestroyPbufferARB(pbuffer));
-            ReleaseDC(win_handle, hdc_parent);
-            goto out;
-        }
-        ReleaseDC(win_handle, hdc_parent);
-    } else {
-        PIXELFORMATDESCRIPTOR pfd;
-        int iPixelFormat;
-        int res;
-        const struct GlPixelFormatDesc *color_format_desc = target->resource.format_desc;
-        const struct GlPixelFormatDesc *ds_format_desc = getFormatDescEntry(WINED3DFMT_UNKNOWN,
-                &This->adapter->gl_info);
-        BOOL auxBuffers = FALSE;
-        int numSamples = 0;
-
-        hdc = GetDC(win_handle);
-        if(hdc == NULL) {
-            ERR("Cannot retrieve a device context!\n");
-            goto out;
-        }
-
-        /* In case of ORM_BACKBUFFER, make sure to request an alpha component for X4R4G4B4/X8R8G8B8 as we might need it for the backbuffer. */
-        if(wined3d_settings.offscreen_rendering_mode == ORM_BACKBUFFER) {
-            auxBuffers = TRUE;
-
-            if (color_format_desc->format == WINED3DFMT_B4G4R4X4_UNORM)
-                color_format_desc = getFormatDescEntry(WINED3DFMT_B4G4R4A4_UNORM, &This->adapter->gl_info);
-            else if (color_format_desc->format == WINED3DFMT_B8G8R8X8_UNORM)
-                color_format_desc = getFormatDescEntry(WINED3DFMT_B8G8R8A8_UNORM, &This->adapter->gl_info);
-        }
-
-        /* DirectDraw supports 8bit paletted render targets and these are used by old games like Starcraft and C&C.
-         * Most modern hardware doesn't support 8bit natively so we perform some form of 8bit -> 32bit conversion.
-         * The conversion (ab)uses the alpha component for storing the palette index. For this reason we require
-         * a format with 8bit alpha, so request A8R8G8B8. */
-        if (color_format_desc->format == WINED3DFMT_P8_UINT)
-            color_format_desc = getFormatDescEntry(WINED3DFMT_B8G8R8A8_UNORM, &This->adapter->gl_info);
-
-        /* Retrieve the depth stencil format from the present parameters.
-         * The choice of the proper format can give a nice performance boost
-         * in case of GPU limited programs. */
-        if(pPresentParms->EnableAutoDepthStencil) {
-            TRACE("pPresentParms->EnableAutoDepthStencil=enabled; using AutoDepthStencilFormat=%s\n", debug_d3dformat(pPresentParms->AutoDepthStencilFormat));
-            ds_format_desc = getFormatDescEntry(pPresentParms->AutoDepthStencilFormat, &This->adapter->gl_info);
-        }
-
-        /* D3D only allows multisampling when SwapEffect is set to WINED3DSWAPEFFECT_DISCARD */
-        if(pPresentParms->MultiSampleType && (pPresentParms->SwapEffect == WINED3DSWAPEFFECT_DISCARD)) {
-            if (!gl_info->supported[ARB_MULTISAMPLE])
-                ERR("The program is requesting multisampling without support!\n");
-            else
-            {
-                TRACE("Requesting multisample type %#x.\n", pPresentParms->MultiSampleType);
-                numSamples = pPresentParms->MultiSampleType;
-            }
-        }
-
-        /* Try to find a pixel format which matches our requirements */
-        iPixelFormat = WineD3D_ChoosePixelFormat(This, hdc, color_format_desc, ds_format_desc,
-                auxBuffers, numSamples, FALSE /* PBUFFER */, FALSE /* findCompatible */);
-
-        /* Try to locate a compatible format if we weren't able to find anything */
-        if(!iPixelFormat) {
-            TRACE("Trying to locate a compatible pixel format because an exact match failed.\n");
-            iPixelFormat = WineD3D_ChoosePixelFormat(This, hdc, color_format_desc, ds_format_desc,
-                    auxBuffers, 0 /* numSamples */, FALSE /* PBUFFER */, TRUE /* findCompatible */ );
-        }
-
-        /* If we still don't have a pixel format, something is very wrong as ChoosePixelFormat barely fails */
-        if(!iPixelFormat) {
-            ERR("Can't find a suitable iPixelFormat\n");
-            return NULL;
-        }
-
-        DescribePixelFormat(hdc, iPixelFormat, sizeof(pfd), &pfd);
-        res = SetPixelFormat(hdc, iPixelFormat, NULL);
-        if(!res) {
-            int oldPixelFormat = GetPixelFormat(hdc);
-
-            /* By default WGL doesn't allow pixel format adjustments but we need it here.
-             * For this reason there is a WINE-specific wglSetPixelFormat which allows you to
-             * set the pixel format multiple times. Only use it when it is really needed. */
-
-            if(oldPixelFormat == iPixelFormat) {
-                /* We don't have to do anything as the formats are the same :) */
-            }
-            else if (oldPixelFormat && gl_info->supported[WGL_WINE_PIXEL_FORMAT_PASSTHROUGH])
-            {
-                res = GL_EXTCALL(wglSetPixelFormatWINE(hdc, iPixelFormat, NULL));
-
-                if(!res) {
-                    ERR("wglSetPixelFormatWINE failed on HDC=%p for iPixelFormat=%d\n", hdc, iPixelFormat);
-                    return NULL;
-                }
-            } else if(oldPixelFormat) {
-                /* OpenGL doesn't allow pixel format adjustments. Print an error and continue using the old format.
-                 * There's a big chance that the old format works although with a performance hit and perhaps rendering errors. */
-                ERR("HDC=%p is already set to iPixelFormat=%d and OpenGL doesn't allow changes!\n", hdc, oldPixelFormat);
-            } else {
-                ERR("SetPixelFormat failed on HDC=%p for iPixelFormat=%d\n", hdc, iPixelFormat);
-                return NULL;
-            }
-        }
+    TRACE("swapchain %p, target %p, window %p.\n", swapchain, target, swapchain->win_handle);
+
+    ret = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ret));
+    if (!ret)
+    {
+        ERR("Failed to allocate context memory.\n");
+        return NULL;
+    }
+
+    if (!(hdc = GetDC(swapchain->win_handle)))
+    {
+        ERR("Failed to retrieve a device context.\n");
+        goto out;
+    }
+
+    color_format_desc = target->resource.format_desc;
+
+    /* In case of ORM_BACKBUFFER, make sure to request an alpha component for
+     * X4R4G4B4/X8R8G8B8 as we might need it for the backbuffer. */
+    if (wined3d_settings.offscreen_rendering_mode == ORM_BACKBUFFER)
+    {
+        auxBuffers = TRUE;
+
+        if (color_format_desc->format == WINED3DFMT_B4G4R4X4_UNORM)
+            color_format_desc = getFormatDescEntry(WINED3DFMT_B4G4R4A4_UNORM, gl_info);
+        else if (color_format_desc->format == WINED3DFMT_B8G8R8X8_UNORM)
+            color_format_desc = getFormatDescEntry(WINED3DFMT_B8G8R8A8_UNORM, gl_info);
+    }
+
+    /* DirectDraw supports 8bit paletted render targets and these are used by
+     * old games like Starcraft and C&C. Most modern hardware doesn't support
+     * 8bit natively so we perform some form of 8bit -> 32bit conversion. The
+     * conversion (ab)uses the alpha component for storing the palette index.
+     * For this reason we require a format with 8bit alpha, so request
+     * A8R8G8B8. */
+    if (color_format_desc->format == WINED3DFMT_P8_UINT)
+        color_format_desc = getFormatDescEntry(WINED3DFMT_B8G8R8A8_UNORM, gl_info);
+
+    /* Retrieve the depth stencil format from the present parameters.
+     * The choice of the proper format can give a nice performance boost
+     * in case of GPU limited programs. */
+    if (swapchain->presentParms.EnableAutoDepthStencil)
+    {
+        TRACE("Auto depth stencil enabled, using format %s.\n",
+                debug_d3dformat(swapchain->presentParms.AutoDepthStencilFormat));
+        ds_format_desc = getFormatDescEntry(swapchain->presentParms.AutoDepthStencilFormat, gl_info);
+    }
+
+    /* D3D only allows multisampling when SwapEffect is set to WINED3DSWAPEFFECT_DISCARD. */
+    if (swapchain->presentParms.MultiSampleType && (swapchain->presentParms.SwapEffect == WINED3DSWAPEFFECT_DISCARD))
+    {
+        if (!gl_info->supported[ARB_MULTISAMPLE])
+            WARN("The application is requesting multisampling without support.\n");
+        else
+        {
+            TRACE("Requesting multisample type %#x.\n", swapchain->presentParms.MultiSampleType);
+            numSamples = swapchain->presentParms.MultiSampleType;
+        }
+    }
+
+    /* Try to find a pixel format which matches our requirements. */
+    pixel_format = WineD3D_ChoosePixelFormat(device, hdc, color_format_desc, ds_format_desc,
+            auxBuffers, numSamples, FALSE /* findCompatible */);
+
+    /* Try to locate a compatible format if we weren't able to find anything. */
+    if (!pixel_format)
+    {
+        TRACE("Trying to locate a compatible pixel format because an exact match failed.\n");
+        pixel_format = WineD3D_ChoosePixelFormat(device, hdc, color_format_desc, ds_format_desc,
+                auxBuffers, 0 /* numSamples */, TRUE /* findCompatible */);
+    }
+
+    /* If we still don't have a pixel format, something is very wrong as ChoosePixelFormat barely fails */
+    if (!pixel_format)
+    {
+        ERR("Can't find a suitable pixel format.\n");
+        goto out;
+    }
+
+    DescribePixelFormat(hdc, pixel_format, sizeof(pfd), &pfd);
+    if (!context_set_pixel_format(gl_info, hdc, pixel_format))
+    {
+        ERR("Failed to set pixel format %d on device context %p.\n", pixel_format, hdc);
+        goto out;
     }
 
     ctx = pwglCreateContext(hdc);
-    if (This->numContexts)
-    {
-        if (!pwglShareLists(This->contexts[0]->glCtx, ctx))
+    if (device->numContexts)
+    {
+        if (!pwglShareLists(device->contexts[0]->glCtx, ctx))
         {
             DWORD err = GetLastError();
             ERR("wglShareLists(%p, %p) failed, last error %#x.\n",
-                    This->contexts[0]->glCtx, ctx, err);
+                    device->contexts[0]->glCtx, ctx, err);
         }
     }
@@ -1336,12 +1337,9 @@
     if(!ctx) {
         ERR("Failed to create a WGL context\n");
-        if(create_pbuffer) {
-            GL_EXTCALL(wglReleasePbufferDCARB(pbuffer, hdc));
-            GL_EXTCALL(wglDestroyPbufferARB(pbuffer));
-        }
         goto out;
     }
-    ret = AddContextToArray(This, win_handle, hdc, ctx, pbuffer);
-    if(!ret) {
+
+    if (!device_context_add(device, ret))
+    {
         ERR("Failed to add the newly created context to the context list\n");
         if (!pwglDeleteContext(ctx))
@@ -1350,27 +1348,41 @@
             ERR("wglDeleteContext(%p) failed, last error %#x.\n", ctx, err);
         }
-        if(create_pbuffer) {
-            GL_EXTCALL(wglReleasePbufferDCARB(pbuffer, hdc));
-            GL_EXTCALL(wglDestroyPbufferARB(pbuffer));
-        }
         goto out;
     }
-    ret->valid = 1;
-    ret->gl_info = &This->adapter->gl_info;
-    ret->surface = (IWineD3DSurface *) target;
+
+    ret->gl_info = gl_info;
+
+    /* Mark all states dirty to force a proper initialization of the states
+     * on the first use of the context. */
+    for (state = 0; state <= STATE_HIGHEST; ++state)
+    {
+        if (device->StateTable[state].representative)
+            Context_MarkStateDirty(ret, state, device->StateTable);
+    }
+
+    ret->swapchain = swapchain;
     ret->current_rt = (IWineD3DSurface *)target;
+    ret->tid = GetCurrentThreadId();
+
     ret->render_offscreen = surface_is_offscreen((IWineD3DSurface *) target);
     ret->draw_buffer_dirty = TRUE;
-    ret->tid = GetCurrentThreadId();
-    if(This->shader_backend->shader_dirtifyable_constants((IWineD3DDevice *) This)) {
+    ret->valid = 1;
+
+    ret->glCtx = ctx;
+    ret->win_handle = swapchain->win_handle;
+    ret->hdc = hdc;
+    ret->pixel_format = pixel_format;
+
+    if (device->shader_backend->shader_dirtifyable_constants((IWineD3DDevice *)device))
+    {
         /* Create the dirty constants array and initialize them to dirty */
         ret->vshader_const_dirty = HeapAlloc(GetProcessHeap(), 0,
-                sizeof(*ret->vshader_const_dirty) * This->d3d_vshader_constantF);
+                sizeof(*ret->vshader_const_dirty) * device->d3d_vshader_constantF);
         ret->pshader_const_dirty = HeapAlloc(GetProcessHeap(), 0,
-                sizeof(*ret->pshader_const_dirty) * This->d3d_pshader_constantF);
+                sizeof(*ret->pshader_const_dirty) * device->d3d_pshader_constantF);
         memset(ret->vshader_const_dirty, 1,
-               sizeof(*ret->vshader_const_dirty) * This->d3d_vshader_constantF);
+               sizeof(*ret->vshader_const_dirty) * device->d3d_vshader_constantF);
         memset(ret->pshader_const_dirty, 1,
-                sizeof(*ret->pshader_const_dirty) * This->d3d_pshader_constantF);
+                sizeof(*ret->pshader_const_dirty) * device->d3d_pshader_constantF);
     }
 
@@ -1427,8 +1439,8 @@
     checkGLcall("glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);");
 
-    glPixelStorei(GL_PACK_ALIGNMENT, This->surface_alignment);
-    checkGLcall("glPixelStorei(GL_PACK_ALIGNMENT, This->surface_alignment);");
-    glPixelStorei(GL_UNPACK_ALIGNMENT, This->surface_alignment);
-    checkGLcall("glPixelStorei(GL_UNPACK_ALIGNMENT, This->surface_alignment);");
+    glPixelStorei(GL_PACK_ALIGNMENT, device->surface_alignment);
+    checkGLcall("glPixelStorei(GL_PACK_ALIGNMENT, device->surface_alignment);");
+    glPixelStorei(GL_UNPACK_ALIGNMENT, device->surface_alignment);
+    checkGLcall("glPixelStorei(GL_UNPACK_ALIGNMENT, device->surface_alignment);");
 
     if (gl_info->supported[APPLE_CLIENT_STORAGE])
@@ -1499,79 +1511,17 @@
     LEAVE_GL();
 
-    This->frag_pipe->enable_extension((IWineD3DDevice *) This, TRUE);
+    device->frag_pipe->enable_extension((IWineD3DDevice *)device, TRUE);
+
+    TRACE("Created context %p.\n", ret);
 
     return ret;
 
 out:
-    if (ret)
-    {
-        HeapFree(GetProcessHeap(), 0, ret->free_event_queries);
-        HeapFree(GetProcessHeap(), 0, ret->free_occlusion_queries);
-        HeapFree(GetProcessHeap(), 0, ret->pshader_const_dirty);
-        HeapFree(GetProcessHeap(), 0, ret->vshader_const_dirty);
-        HeapFree(GetProcessHeap(), 0, ret);
-    }
+    HeapFree(GetProcessHeap(), 0, ret->free_event_queries);
+    HeapFree(GetProcessHeap(), 0, ret->free_occlusion_queries);
+    HeapFree(GetProcessHeap(), 0, ret->pshader_const_dirty);
+    HeapFree(GetProcessHeap(), 0, ret->vshader_const_dirty);
+    HeapFree(GetProcessHeap(), 0, ret);
     return NULL;
-}
-
-/*****************************************************************************
- * RemoveContextFromArray
- *
- * Removes a context from the context manager. The opengl context is not
- * destroyed or unset. context is not a valid pointer after that call.
- *
- * Similar to the former call this isn't a performance critical function. A
- * helper function for context_destroy().
- *
- * Params:
- *  This: Device to activate the context for
- *  context: Context to remove
- *
- *****************************************************************************/
-static void RemoveContextFromArray(IWineD3DDeviceImpl *This, struct wined3d_context *context)
-{
-    struct wined3d_context **new_array;
-    BOOL found = FALSE;
-    UINT i;
-
-    TRACE("Removing ctx %p\n", context);
-
-    for (i = 0; i < This->numContexts; ++i)
-    {
-        if (This->contexts[i] == context)
-        {
-            found = TRUE;
-            break;
-        }
-    }
-
-    if (!found)
-    {
-        ERR("Context %p doesn't exist in context array\n", context);
-        return;
-    }
-
-    while (i < This->numContexts - 1)
-    {
-        This->contexts[i] = This->contexts[i + 1];
-        ++i;
-    }
-
-    --This->numContexts;
-    if (!This->numContexts)
-    {
-        HeapFree(GetProcessHeap(), 0, This->contexts);
-        This->contexts = NULL;
-        return;
-    }
-
-    new_array = HeapReAlloc(GetProcessHeap(), 0, This->contexts, This->numContexts * sizeof(*This->contexts));
-    if (!new_array)
-    {
-        ERR("Failed to shrink context array. Oh well.\n");
-        return;
-    }
-
-    This->contexts = new_array;
 }
 
@@ -1606,5 +1556,5 @@
     HeapFree(GetProcessHeap(), 0, context->vshader_const_dirty);
     HeapFree(GetProcessHeap(), 0, context->pshader_const_dirty);
-    RemoveContextFromArray(This, context);
+    device_context_remove(This, context);
     if (destroy) HeapFree(GetProcessHeap(), 0, context);
 }
@@ -1798,4 +1748,7 @@
     checkGLcall("glColorMask");
     Context_MarkStateDirty(context, STATE_RENDER(WINED3DRS_COLORWRITEENABLE), StateTable);
+    Context_MarkStateDirty(context, STATE_RENDER(WINED3DRS_COLORWRITEENABLE1), StateTable);
+    Context_MarkStateDirty(context, STATE_RENDER(WINED3DRS_COLORWRITEENABLE2), StateTable);
+    Context_MarkStateDirty(context, STATE_RENDER(WINED3DRS_COLORWRITEENABLE3), StateTable);
     if (gl_info->supported[EXT_SECONDARY_COLOR])
     {
@@ -1873,8 +1826,6 @@
     IWineD3DSwapChain *swapchain = NULL;
     struct wined3d_context *current_context = context_get_current();
-    const struct StateEntry *StateTable = This->StateTable;
     DWORD tid = GetCurrentThreadId();
     struct wined3d_context *context;
-    BOOL old_render_offscreen;
 
     if (current_context && current_context->destroyed) current_context = NULL;
@@ -1884,5 +1835,5 @@
         if (current_context
                 && current_context->current_rt
-                && ((IWineD3DSurfaceImpl *)current_context->surface)->resource.device == This)
+                && current_context->swapchain->device == This)
         {
             target = current_context->current_rt;
@@ -1906,17 +1857,4 @@
 
         context = findThreadContextForSwapChain(swapchain, tid);
-
-        old_render_offscreen = context->render_offscreen;
-        context->render_offscreen = surface_is_offscreen(target);
-        /* The context != This->activeContext will catch a NOP context change. This can occur
-         * if we are switching back to swapchain rendering in case of FBO or Back Buffer offscreen
-         * rendering. No context change is needed in that case
-         */
-
-        if(wined3d_settings.offscreen_rendering_mode == ORM_PBUFFER) {
-            if(This->pbufferContext && tid == This->pbufferContext->tid) {
-                This->pbufferContext->tid = 0;
-            }
-        }
         IWineD3DSwapChain_Release(swapchain);
     }
@@ -1925,139 +1863,22 @@
         TRACE("Rendering offscreen\n");
 
-retry:
-        if (wined3d_settings.offscreen_rendering_mode == ORM_PBUFFER)
-        {
-            IWineD3DSurfaceImpl *targetimpl = (IWineD3DSurfaceImpl *)target;
-            if (!This->pbufferContext
-                    || This->pbufferWidth < targetimpl->currentDesc.Width
-                    || This->pbufferHeight < targetimpl->currentDesc.Height)
-            {
-                if (This->pbufferContext) context_destroy(This, This->pbufferContext);
-
-                /* The display is irrelevant here, the window is 0. But
-                 * context_create() needs a valid X connection. Create the context
-                 * on the same server as the primary swapchain. The primary
-                 * swapchain is exists at this point. */
-                This->pbufferContext = context_create(This, targetimpl,
-                        ((IWineD3DSwapChainImpl *)This->swapchains[0])->context[0]->win_handle,
-                        TRUE /* pbuffer */, &((IWineD3DSwapChainImpl *)This->swapchains[0])->presentParms);
-                This->pbufferWidth = targetimpl->currentDesc.Width;
-                This->pbufferHeight = targetimpl->currentDesc.Height;
-                if (This->pbufferContext) context_release(This->pbufferContext);
-            }
-
-            if (This->pbufferContext)
-            {
-                if (This->pbufferContext->tid && This->pbufferContext->tid != tid)
-                {
-                    FIXME("The PBuffer context is only supported for one thread for now!\n");
-                }
-                This->pbufferContext->tid = tid;
-                context = This->pbufferContext;
-            }
-            else
-            {
-                ERR("Failed to create a buffer context and drawable, falling back to back buffer offscreen rendering.\n");
-                wined3d_settings.offscreen_rendering_mode = ORM_BACKBUFFER;
-                goto retry;
-            }
+        /* Stay with the currently active context. */
+        if (current_context && current_context->swapchain->device == This)
+        {
+            context = current_context;
         }
         else
         {
-            /* Stay with the currently active context. */
-            if (current_context
-                    && ((IWineD3DSurfaceImpl *)current_context->surface)->resource.device == This)
-            {
-                context = current_context;
-            }
-            else
-            {
-                /* This may happen if the app jumps straight into offscreen rendering
-                 * Start using the context of the primary swapchain. tid == 0 is no problem
-                 * for findThreadContextForSwapChain.
-                 *
-                 * Can also happen on thread switches - in that case findThreadContextForSwapChain
-                 * is perfect to call. */
-                context = findThreadContextForSwapChain(This->swapchains[0], tid);
-            }
-        }
-
-        old_render_offscreen = context->render_offscreen;
-        context->render_offscreen = TRUE;
+            /* This may happen if the app jumps straight into offscreen rendering
+             * Start using the context of the primary swapchain. tid == 0 is no problem
+             * for findThreadContextForSwapChain.
+             *
+             * Can also happen on thread switches - in that case findThreadContextForSwapChain
+             * is perfect to call. */
+            context = findThreadContextForSwapChain(This->swapchains[0], tid);
+        }
     }
 
     context_validate(context);
-
-    if (context->render_offscreen != old_render_offscreen)
-    {
-        Context_MarkStateDirty(context, STATE_TRANSFORM(WINED3DTS_PROJECTION), StateTable);
-        Context_MarkStateDirty(context, STATE_VDECL, StateTable);
-        Context_MarkStateDirty(context, STATE_VIEWPORT, StateTable);
-        Context_MarkStateDirty(context, STATE_SCISSORRECT, StateTable);
-        Context_MarkStateDirty(context, STATE_FRONTFACE, StateTable);
-    }
-
-    /* To compensate the lack of format switching with some offscreen rendering methods and on onscreen buffers
-     * the alpha blend state changes with different render target formats. */
-    if (!context->current_rt)
-    {
-        Context_MarkStateDirty(context, STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), StateTable);
-    }
-    else
-    {
-        const struct GlPixelFormatDesc *old = ((IWineD3DSurfaceImpl *)context->current_rt)->resource.format_desc;
-        const struct GlPixelFormatDesc *new = ((IWineD3DSurfaceImpl *)target)->resource.format_desc;
-
-        if (old->format != new->format)
-        {
-            /* Disable blending when the alpha mask has changed and when a format doesn't support blending. */
-            if ((old->alpha_mask && !new->alpha_mask) || (!old->alpha_mask && new->alpha_mask)
-                    || !(new->Flags & WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING))
-            {
-                Context_MarkStateDirty(context, STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), StateTable);
-            }
-        }
-
-        /* When switching away from an offscreen render target, and we're not
-         * using FBOs, we have to read the drawable into the texture. This is
-         * done via PreLoad (and SFLAG_INDRAWABLE set on the surface). There
-         * are some things that need care though. PreLoad needs a GL context,
-         * and FindContext is called before the context is activated. It also
-         * has to be called with the old rendertarget active, otherwise a
-         * wrong drawable is read. */
-        if (wined3d_settings.offscreen_rendering_mode != ORM_FBO
-                && old_render_offscreen && context->current_rt != target)
-        {
-            BOOL oldInDraw = This->isInDraw;
-
-            /* surface_internal_preload() requires a context to load the
-             * texture, so it will call context_acquire(). Set isInDraw to true
-             * to signal surface_internal_preload() that it has a context. */
-
-            /* FIXME: This is just broken. There's no guarantee whatsoever
-             * that the currently active context, if any, is appropriate for
-             * reading back the render target. We should probably call
-             * context_set_current(context) here and then rely on
-             * context_acquire() doing the right thing. */
-            This->isInDraw = TRUE;
-
-            /* Read the back buffer of the old drawable into the destination texture. */
-            if (((IWineD3DSurfaceImpl *)context->current_rt)->texture_name_srgb)
-            {
-                surface_internal_preload(context->current_rt, SRGB_BOTH);
-            }
-            else
-            {
-                surface_internal_preload(context->current_rt, SRGB_RGB);
-            }
-
-            IWineD3DSurface_ModifyLocation(context->current_rt, SFLAG_INDRAWABLE, FALSE);
-
-            This->isInDraw = oldInDraw;
-        }
-    }
-
-    context->draw_buffer_dirty = TRUE;
-    context->current_rt = target;
 
     return context;
@@ -2118,4 +1939,55 @@
 }
 
+static inline void context_set_render_offscreen(struct wined3d_context *context, const struct StateEntry *StateTable,
+        BOOL offscreen)
+{
+    if (context->render_offscreen == offscreen) return;
+
+    Context_MarkStateDirty(context, STATE_TRANSFORM(WINED3DTS_PROJECTION), StateTable);
+    Context_MarkStateDirty(context, STATE_VDECL, StateTable);
+    Context_MarkStateDirty(context, STATE_VIEWPORT, StateTable);
+    Context_MarkStateDirty(context, STATE_SCISSORRECT, StateTable);
+    Context_MarkStateDirty(context, STATE_FRONTFACE, StateTable);
+    context->render_offscreen = offscreen;
+}
+
+static BOOL match_depth_stencil_format(const struct wined3d_format_desc *existing,
+        const struct wined3d_format_desc *required)
+{
+    short existing_depth, existing_stencil, required_depth, required_stencil;
+
+    if(existing == required) return TRUE;
+    if((existing->Flags & WINED3DFMT_FLAG_FLOAT) != (required->Flags & WINED3DFMT_FLAG_FLOAT)) return FALSE;
+
+    getDepthStencilBits(existing, &existing_depth, &existing_stencil);
+    getDepthStencilBits(required, &required_depth, &required_stencil);
+
+    if(existing_depth < required_depth) return FALSE;
+    /* If stencil bits are used the exact amount is required - otherwise wrapping
+     * won't work correctly */
+    if(required_stencil && required_stencil != existing_stencil) return FALSE;
+    return TRUE;
+}
+/* The caller provides a context */
+static void context_validate_onscreen_formats(IWineD3DDeviceImpl *device, struct wined3d_context *context)
+{
+    /* Onscreen surfaces are always in a swapchain */
+    IWineD3DSurfaceImpl *depth_stencil = (IWineD3DSurfaceImpl *) device->stencilBufferTarget;
+    IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *) ((IWineD3DSurfaceImpl *)context->current_rt)->container;
+
+    if (!depth_stencil) return;
+    if (match_depth_stencil_format(swapchain->ds_format, depth_stencil->resource.format_desc)) return;
+
+    /* TODO: If the requested format would satisfy the needs of the existing one(reverse match),
+     * or no onscreen depth buffer was created, the OpenGL drawable could be changed to the new
+     * format. */
+    WARN("Depth stencil format is not supported by WGL, rendering the backbuffer in an FBO\n");
+
+    /* The currently active context is the necessary context to access the swapchain's onscreen buffers */
+    IWineD3DSurface_LoadLocation(context->current_rt, SFLAG_INTEXTURE, NULL);
+    swapchain->render_to_fbo = TRUE;
+    context_set_render_offscreen(context, device->StateTable, TRUE);
+}
+
 /* Context activation is done by the caller. */
 static void context_apply_state(struct wined3d_context *context, IWineD3DDeviceImpl *device, enum ContextUsage usage)
@@ -2128,4 +2000,5 @@
         case CTXUSAGE_DRAWPRIM:
             if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) {
+                if (!context->render_offscreen) context_validate_onscreen_formats(device, context);
                 ENTER_GL();
                 context_apply_fbo_state(context);
@@ -2140,10 +2013,13 @@
         case CTXUSAGE_BLIT:
             if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) {
+                if (!context->render_offscreen) context_validate_onscreen_formats(device, context);
                 if (context->render_offscreen)
                 {
                     FIXME("Activating for CTXUSAGE_BLIT for an offscreen target with ORM_FBO. This should be avoided.\n");
+                    surface_internal_preload(context->current_rt, SRGB_RGB);
+
                     ENTER_GL();
                     context_bind_fbo(context, GL_FRAMEBUFFER, &context->dst_fbo);
-                    context_attach_surface_fbo(context, GL_FRAMEBUFFER, 0, context->current_rt);
+                    context_attach_surface_fbo(context, GL_FRAMEBUFFER, 0, (IWineD3DSurfaceImpl *)context->current_rt);
                     context_attach_depth_stencil_fbo(context, GL_FRAMEBUFFER, NULL, FALSE);
                     LEAVE_GL();
@@ -2201,4 +2077,7 @@
 
             IWineD3DDeviceImpl_FindTexUnitMap(device);
+            device_preload_textures(device);
+            if (isStateDirty(context, STATE_VDECL))
+                device_update_stream_info(device, context->gl_info);
 
             ENTER_GL();
@@ -2225,4 +2104,79 @@
 }
 
+static void context_setup_target(IWineD3DDeviceImpl *device, struct wined3d_context *context, IWineD3DSurface *target)
+{
+    BOOL old_render_offscreen = context->render_offscreen, render_offscreen;
+    const struct StateEntry *StateTable = device->StateTable;
+
+    if (!target) return;
+    else if (context->current_rt == target) return;
+    render_offscreen = surface_is_offscreen(target);
+
+    context_set_render_offscreen(context, StateTable, render_offscreen);
+
+    /* To compensate the lack of format switching with some offscreen rendering methods and on onscreen buffers
+     * the alpha blend state changes with different render target formats. */
+    if (!context->current_rt)
+    {
+        Context_MarkStateDirty(context, STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), StateTable);
+    }
+    else
+    {
+        const struct wined3d_format_desc *old = ((IWineD3DSurfaceImpl *)context->current_rt)->resource.format_desc;
+        const struct wined3d_format_desc *new = ((IWineD3DSurfaceImpl *)target)->resource.format_desc;
+
+        if (old->format != new->format)
+        {
+            /* Disable blending when the alpha mask has changed and when a format doesn't support blending. */
+            if ((old->alpha_mask && !new->alpha_mask) || (!old->alpha_mask && new->alpha_mask)
+                    || !(new->Flags & WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING))
+            {
+                Context_MarkStateDirty(context, STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), StateTable);
+            }
+        }
+
+        /* When switching away from an offscreen render target, and we're not
+         * using FBOs, we have to read the drawable into the texture. This is
+         * done via PreLoad (and SFLAG_INDRAWABLE set on the surface). There
+         * are some things that need care though. PreLoad needs a GL context,
+         * and FindContext is called before the context is activated. It also
+         * has to be called with the old rendertarget active, otherwise a
+         * wrong drawable is read. */
+        if (wined3d_settings.offscreen_rendering_mode != ORM_FBO
+                && old_render_offscreen && context->current_rt != target)
+        {
+            BOOL oldInDraw = device->isInDraw;
+
+            /* surface_internal_preload() requires a context to load the
+             * texture, so it will call context_acquire(). Set isInDraw to true
+             * to signal surface_internal_preload() that it has a context. */
+
+            /* FIXME: This is just broken. There's no guarantee whatsoever
+             * that the currently active context, if any, is appropriate for
+             * reading back the render target. We should probably call
+             * context_set_current(context) here and then rely on
+             * context_acquire() doing the right thing. */
+            device->isInDraw = TRUE;
+
+            /* Read the back buffer of the old drawable into the destination texture. */
+            if (((IWineD3DSurfaceImpl *)context->current_rt)->texture_name_srgb)
+            {
+                surface_internal_preload(context->current_rt, SRGB_BOTH);
+            }
+            else
+            {
+                surface_internal_preload(context->current_rt, SRGB_RGB);
+            }
+
+            IWineD3DSurface_ModifyLocation(context->current_rt, SFLAG_INDRAWABLE, FALSE);
+
+            device->isInDraw = oldInDraw;
+        }
+    }
+
+    context->draw_buffer_dirty = TRUE;
+    context->current_rt = target;
+}
+
 /*****************************************************************************
  * context_acquire
@@ -2246,4 +2200,5 @@
 
     context = FindContext(device, target);
+    context_setup_target(device, context, target);
     context_enter(context);
     if (!context->valid) return context;
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/cubetexture.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/cubetexture.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/cubetexture.c	(revision 28475)
@@ -443,5 +443,5 @@
 {
     const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
-    const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(format, gl_info);
+    const struct wined3d_format_desc *format_desc = getFormatDescEntry(format, gl_info);
     UINT pow2_edge_length;
     unsigned int i, j;
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/device.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/device.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/device.c	(revision 28475)
@@ -189,6 +189,4 @@
     /* We need to deal with frequency data! */
     IWineD3DVertexDeclarationImpl *declaration = (IWineD3DVertexDeclarationImpl *)This->stateBlock->vertexDecl;
-    UINT stream_count = This->stateBlock->streamIsUP ? 0 : declaration->num_streams;
-    const DWORD *streams = declaration->streams;
     unsigned int i;
 
@@ -225,5 +223,5 @@
         {
             TRACE("Stream %u isn't UP, %p\n", element->input_slot, This->stateBlock->streamSource[element->input_slot]);
-            data = buffer_get_memory(This->stateBlock->streamSource[element->input_slot], 0, &buffer_object);
+            data = buffer_get_memory(This->stateBlock->streamSource[element->input_slot], &buffer_object);
 
             /* Can't use vbo's if the base vertex index is negative. OpenGL doesn't accept negative offsets
@@ -308,5 +306,5 @@
             stream_info->elements[idx].buffer_object = buffer_object;
 
-            if (!This->adapter->gl_info.supported[EXT_VERTEX_ARRAY_BGRA]
+            if (!This->adapter->gl_info.supported[ARB_VERTEX_ARRAY_BGRA]
                     && element->format_desc->format == WINED3DFMT_B8G8R8A8_UNORM)
             {
@@ -317,15 +315,35 @@
     }
 
-    /* Now call PreLoad on all the vertex buffers. In the very rare case
-     * that the buffers stopps converting PreLoad will dirtify the VDECL again.
-     * The vertex buffer can now use the strided structure in the device instead of finding its
-     * own again.
-     *
-     * NULL streams won't be recorded in the array, UP streams won't be either. A stream is only
-     * once in there. */
-    for (i = 0; i < stream_count; ++i)
-    {
-        IWineD3DBuffer *vb = This->stateBlock->streamSource[streams[i]];
-        if (vb) IWineD3DBuffer_PreLoad(vb);
+    This->num_buffer_queries = 0;
+    if (!This->stateBlock->streamIsUP)
+    {
+        WORD map = stream_info->use_map;
+
+        /* PreLoad all the vertex buffers. */
+        for (i = 0; map; map >>= 1, ++i)
+        {
+            struct wined3d_stream_info_element *element;
+            struct wined3d_buffer *buffer;
+            struct wined3d_event_query *query;
+
+            if (!(map & 1)) continue;
+
+            element = &stream_info->elements[i];
+            buffer = (struct wined3d_buffer *)This->stateBlock->streamSource[element->stream_idx];
+            IWineD3DBuffer_PreLoad((IWineD3DBuffer *)buffer);
+
+            /* If PreLoad dropped the buffer object, update the stream info. */
+            if (buffer->buffer_object != element->buffer_object)
+            {
+                element->buffer_object = 0;
+                element->data = buffer_get_sysmem(buffer) + (ptrdiff_t)element->data;
+            }
+
+            query = ((struct wined3d_buffer *) buffer)->query;
+            if(query)
+            {
+                This->buffer_queries[This->num_buffer_queries++] = query;
+            }
+        }
     }
 }
@@ -334,5 +352,5 @@
         const struct WineDirect3DStridedData *strided, struct wined3d_stream_info_element *e)
 {
-    const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(strided->format, gl_info);
+    const struct wined3d_format_desc *format_desc = getFormatDescEntry(strided->format, gl_info);
     e->format_desc = format_desc;
     e->stride = strided->dwStride;
@@ -342,5 +360,5 @@
 }
 
-void device_stream_info_from_strided(const struct wined3d_gl_info *gl_info,
+static void device_stream_info_from_strided(const struct wined3d_gl_info *gl_info,
         const struct WineDirect3DVertexStridedData *strided, struct wined3d_stream_info *stream_info)
 {
@@ -371,5 +389,5 @@
         if (!stream_info->elements[i].format_desc) continue;
 
-        if (!gl_info->supported[EXT_VERTEX_ARRAY_BGRA]
+        if (!gl_info->supported[ARB_VERTEX_ARRAY_BGRA]
                 && stream_info->elements[i].format_desc->format == WINED3DFMT_B8G8R8A8_UNORM)
         {
@@ -379,4 +397,180 @@
     }
 }
+
+static void device_trace_strided_stream_info(const struct wined3d_stream_info *stream_info)
+{
+    TRACE("Strided Data:\n");
+    TRACE_STRIDED(stream_info, WINED3D_FFP_POSITION);
+    TRACE_STRIDED(stream_info, WINED3D_FFP_BLENDWEIGHT);
+    TRACE_STRIDED(stream_info, WINED3D_FFP_BLENDINDICES);
+    TRACE_STRIDED(stream_info, WINED3D_FFP_NORMAL);
+    TRACE_STRIDED(stream_info, WINED3D_FFP_PSIZE);
+    TRACE_STRIDED(stream_info, WINED3D_FFP_DIFFUSE);
+    TRACE_STRIDED(stream_info, WINED3D_FFP_SPECULAR);
+    TRACE_STRIDED(stream_info, WINED3D_FFP_TEXCOORD0);
+    TRACE_STRIDED(stream_info, WINED3D_FFP_TEXCOORD1);
+    TRACE_STRIDED(stream_info, WINED3D_FFP_TEXCOORD2);
+    TRACE_STRIDED(stream_info, WINED3D_FFP_TEXCOORD3);
+    TRACE_STRIDED(stream_info, WINED3D_FFP_TEXCOORD4);
+    TRACE_STRIDED(stream_info, WINED3D_FFP_TEXCOORD5);
+    TRACE_STRIDED(stream_info, WINED3D_FFP_TEXCOORD6);
+    TRACE_STRIDED(stream_info, WINED3D_FFP_TEXCOORD7);
+}
+
+/* Context activation is done by the caller. */
+void device_update_stream_info(IWineD3DDeviceImpl *device, const struct wined3d_gl_info *gl_info)
+{
+    struct wined3d_stream_info *stream_info = &device->strided_streams;
+    IWineD3DStateBlockImpl *stateblock = device->stateBlock;
+    BOOL vs = stateblock->vertexShader && device->vs_selected_mode != SHADER_NONE;
+    BOOL fixup = FALSE;
+
+    if (device->up_strided)
+    {
+        /* Note: this is a ddraw fixed-function code path. */
+        TRACE("=============================== Strided Input ================================\n");
+        device_stream_info_from_strided(gl_info, device->up_strided, stream_info);
+        if (TRACE_ON(d3d)) device_trace_strided_stream_info(stream_info);
+    }
+    else
+    {
+        TRACE("============================= Vertex Declaration =============================\n");
+        device_stream_info_from_declaration(device, vs, stream_info, &fixup);
+    }
+
+    if (vs && !stream_info->position_transformed)
+    {
+        if (((IWineD3DVertexDeclarationImpl *)stateblock->vertexDecl)->half_float_conv_needed && !fixup)
+        {
+            TRACE("Using drawStridedSlow with vertex shaders for FLOAT16 conversion.\n");
+            device->useDrawStridedSlow = TRUE;
+        }
+        else
+        {
+            device->useDrawStridedSlow = FALSE;
+        }
+    }
+    else
+    {
+        WORD slow_mask = (1 << WINED3D_FFP_PSIZE);
+        slow_mask |= -!gl_info->supported[ARB_VERTEX_ARRAY_BGRA]
+                & ((1 << WINED3D_FFP_DIFFUSE) | (1 << WINED3D_FFP_SPECULAR));
+
+        if ((stream_info->position_transformed || (stream_info->use_map & slow_mask)) && !fixup)
+        {
+            device->useDrawStridedSlow = TRUE;
+        }
+        else
+        {
+            device->useDrawStridedSlow = FALSE;
+        }
+    }
+}
+
+static void device_preload_texture(IWineD3DStateBlockImpl *stateblock, unsigned int idx)
+{
+    IWineD3DBaseTextureImpl *texture;
+    enum WINED3DSRGB srgb;
+
+    if (!(texture = (IWineD3DBaseTextureImpl *)stateblock->textures[idx])) return;
+    srgb = stateblock->samplerState[idx][WINED3DSAMP_SRGBTEXTURE] ? SRGB_SRGB : SRGB_RGB;
+    texture->baseTexture.internal_preload((IWineD3DBaseTexture *)texture, srgb);
+}
+
+void device_preload_textures(IWineD3DDeviceImpl *device)
+{
+    IWineD3DStateBlockImpl *stateblock = device->stateBlock;
+    unsigned int i;
+
+    if (use_vs(stateblock))
+    {
+        for (i = 0; i < MAX_VERTEX_SAMPLERS; ++i)
+        {
+            if (((IWineD3DBaseShaderImpl *)stateblock->vertexShader)->baseShader.reg_maps.sampler_type[i])
+                device_preload_texture(stateblock, MAX_FRAGMENT_SAMPLERS + i);
+        }
+    }
+
+    if (use_ps(stateblock))
+    {
+        for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i)
+        {
+            if (((IWineD3DBaseShaderImpl *)stateblock->pixelShader)->baseShader.reg_maps.sampler_type[i])
+                device_preload_texture(stateblock, i);
+        }
+    }
+    else
+    {
+        WORD ffu_map = device->fixed_function_usage_map;
+
+        for (i = 0; ffu_map; ffu_map >>= 1, ++i)
+        {
+            if (ffu_map & 1)
+                device_preload_texture(stateblock, i);
+        }
+    }
+}
+
+BOOL device_context_add(IWineD3DDeviceImpl *device, struct wined3d_context *context)
+{
+    struct wined3d_context **new_array;
+
+    TRACE("Adding context %p.\n", context);
+
+    if (!device->contexts) new_array = HeapAlloc(GetProcessHeap(), 0, sizeof(*new_array));
+    else new_array = HeapReAlloc(GetProcessHeap(), 0, device->contexts, sizeof(*new_array) * (device->numContexts + 1));
+
+    if (!new_array)
+    {
+        ERR("Failed to grow the context array.\n");
+        return FALSE;
+    }
+
+    new_array[device->numContexts++] = context;
+    device->contexts = new_array;
+    return TRUE;
+}
+
+void device_context_remove(IWineD3DDeviceImpl *device, struct wined3d_context *context)
+{
+    struct wined3d_context **new_array;
+    BOOL found = FALSE;
+    UINT i;
+
+    TRACE("Removing context %p.\n", context);
+
+    for (i = 0; i < device->numContexts; ++i)
+    {
+        if (device->contexts[i] == context)
+        {
+            found = TRUE;
+            break;
+        }
+    }
+
+    if (!found)
+    {
+        ERR("Context %p doesn't exist in context array.\n", context);
+        return;
+    }
+
+    if (!--device->numContexts)
+    {
+        HeapFree(GetProcessHeap(), 0, device->contexts);
+        device->contexts = NULL;
+        return;
+    }
+
+    memmove(&device->contexts[i], &device->contexts[i + 1], (device->numContexts - i) * sizeof(*device->contexts));
+    new_array = HeapReAlloc(GetProcessHeap(), 0, device->contexts, device->numContexts * sizeof(*device->contexts));
+    if (!new_array)
+    {
+        ERR("Failed to shrink context array. Oh well.\n");
+        return;
+    }
+
+    device->contexts = new_array;
+}
+
 
 /**********************************************************
@@ -426,7 +620,15 @@
         ** ***************************/
 
-        if (!list_empty(&This->resources)) {
+        if (!list_empty(&This->resources))
+        {
+            IWineD3DResourceImpl *resource;
             FIXME("(%p) Device released with resources still bound, acceptable but unexpected\n", This);
-            dumpResources(&This->resources);
+
+            LIST_FOR_EACH_ENTRY(resource, &This->resources, IWineD3DResourceImpl, resource.resource_list_entry)
+            {
+                WINED3DRESOURCETYPE type = IWineD3DResource_GetType((IWineD3DResource *)resource);
+                FIXME("Leftover resource %p with type %s (%#x).\n",
+                        resource, debug_d3dresourcetype(type), type);
+            }
         }
 
@@ -606,5 +808,9 @@
     HRESULT hr;
 
-    TRACE("(%p) Create surface\n",This);
+    TRACE("iface %p, width %u, height %u, format %s (%#x), lockable %#x, discard %#x, level %u\n",
+            iface, Width, Height, debug_d3dformat(Format), Format, Lockable, Discard, Level);
+    TRACE("surface %p, usage %s (%#x), pool %s (%#x), multisample_type %#x, multisample_quality %u\n",
+            ppSurface, debug_d3dusage(Usage), Usage, debug_d3dpool(Pool), Pool, MultiSample, MultisampleQuality);
+    TRACE("surface_type %#x, parent %p, parent_ops %p.\n", Impl, parent, parent_ops);
 
     if (Impl == SURFACE_OPENGL && !This->adapter)
@@ -642,4 +848,7 @@
     struct wined3d_rendertarget_view *object;
 
+    TRACE("iface %p, resource %p, parent %p, rendertarget_view %p.\n",
+            iface, resource, parent, rendertarget_view);
+
     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
     if (!object)
@@ -649,10 +858,7 @@
     }
 
-    object->vtbl = &wined3d_rendertarget_view_vtbl;
-    object->refcount = 1;
-    IWineD3DResource_AddRef(resource);
-    object->resource = resource;
-    object->parent = parent;
-
+    wined3d_rendertarget_view_init(object, resource, parent);
+
+    TRACE("Created render target view %p.\n", object);
     *rendertarget_view = (IWineD3DRendertargetView *)object;
 
@@ -794,102 +1000,31 @@
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_CreateQuery(IWineD3DDevice *iface, WINED3DQUERYTYPE Type, IWineD3DQuery **ppQuery, IUnknown* parent) {
-    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
-    const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
-    IWineD3DQueryImpl *object; /*NOTE: impl ref allowed since this is a create function */
-    HRESULT hr = WINED3DERR_NOTAVAILABLE;
-    const IWineD3DQueryVtbl *vtable;
-
-    /* Just a check to see if we support this type of query */
-    switch(Type) {
-    case WINED3DQUERYTYPE_OCCLUSION:
-        TRACE("(%p) occlusion query\n", This);
-        if (gl_info->supported[ARB_OCCLUSION_QUERY])
-            hr = WINED3D_OK;
-        else
-            WARN("Unsupported in local OpenGL implementation: ARB_OCCLUSION_QUERY/NV_OCCLUSION_QUERY\n");
-
-        vtable = &IWineD3DOcclusionQuery_Vtbl;
-        break;
-
-    case WINED3DQUERYTYPE_EVENT:
-        if (!gl_info->supported[NV_FENCE] && !gl_info->supported[APPLE_FENCE])
-        {
-            /* Half-Life 2 needs this query. It does not render the main menu correctly otherwise
-             * Pretend to support it, faking this query does not do much harm except potentially lowering performance
-             */
-            FIXME("(%p) Event query: Unimplemented, but pretending to be supported\n", This);
-        }
-        vtable = &IWineD3DEventQuery_Vtbl;
-        hr = WINED3D_OK;
-        break;
-
-    case WINED3DQUERYTYPE_VCACHE:
-    case WINED3DQUERYTYPE_RESOURCEMANAGER:
-    case WINED3DQUERYTYPE_VERTEXSTATS:
-    case WINED3DQUERYTYPE_TIMESTAMP:
-    case WINED3DQUERYTYPE_TIMESTAMPDISJOINT:
-    case WINED3DQUERYTYPE_TIMESTAMPFREQ:
-    case WINED3DQUERYTYPE_PIPELINETIMINGS:
-    case WINED3DQUERYTYPE_INTERFACETIMINGS:
-    case WINED3DQUERYTYPE_VERTEXTIMINGS:
-    case WINED3DQUERYTYPE_PIXELTIMINGS:
-    case WINED3DQUERYTYPE_BANDWIDTHTIMINGS:
-    case WINED3DQUERYTYPE_CACHEUTILIZATION:
-    default:
-        /* Use the base Query vtable until we have a special one for each query */
-        vtable = &IWineD3DQuery_Vtbl;
-        FIXME("(%p) Unhandled query type %d\n", This, Type);
-    }
-    if(NULL == ppQuery || hr != WINED3D_OK) {
+static HRESULT WINAPI IWineD3DDeviceImpl_CreateQuery(IWineD3DDevice *iface,
+        WINED3DQUERYTYPE type, IWineD3DQuery **query, IUnknown *parent)
+{
+    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
+    IWineD3DQueryImpl *object;
+    HRESULT hr;
+
+    TRACE("iface %p, type %#x, query %p, parent %p.\n", iface, type, query, parent);
+
+    object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+    if (!object)
+    {
+        ERR("Failed to allocate query memory.\n");
+        return E_OUTOFMEMORY;
+    }
+
+    hr = query_init(object, This, type, parent);
+    if (FAILED(hr))
+    {
+        WARN("Failed to initialize query, hr %#x.\n", hr);
+        HeapFree(GetProcessHeap(), 0, object);
         return hr;
     }
 
-    object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
-    if(!object)
-    {
-        ERR("Out of memory\n");
-        *ppQuery = NULL;
-        return WINED3DERR_OUTOFVIDEOMEMORY;
-    }
-
-    object->lpVtbl = vtable;
-    object->type = Type;
-    object->state = QUERY_CREATED;
-    object->device = This;
-    object->parent = parent;
-    object->ref = 1;
-
-    *ppQuery = (IWineD3DQuery *)object;
-
-    /* allocated the 'extended' data based on the type of query requested */
-    switch(Type){
-    case WINED3DQUERYTYPE_OCCLUSION:
-        object->extendedData = HeapAlloc(GetProcessHeap(), 0, sizeof(struct wined3d_occlusion_query));
-        ((struct wined3d_occlusion_query *)object->extendedData)->context = NULL;
-        break;
-
-    case WINED3DQUERYTYPE_EVENT:
-        object->extendedData = HeapAlloc(GetProcessHeap(), 0, sizeof(struct wined3d_event_query));
-        ((struct wined3d_event_query *)object->extendedData)->context = NULL;
-        break;
-
-    case WINED3DQUERYTYPE_VCACHE:
-    case WINED3DQUERYTYPE_RESOURCEMANAGER:
-    case WINED3DQUERYTYPE_VERTEXSTATS:
-    case WINED3DQUERYTYPE_TIMESTAMP:
-    case WINED3DQUERYTYPE_TIMESTAMPDISJOINT:
-    case WINED3DQUERYTYPE_TIMESTAMPFREQ:
-    case WINED3DQUERYTYPE_PIPELINETIMINGS:
-    case WINED3DQUERYTYPE_INTERFACETIMINGS:
-    case WINED3DQUERYTYPE_VERTEXTIMINGS:
-    case WINED3DQUERYTYPE_PIXELTIMINGS:
-    case WINED3DQUERYTYPE_BANDWIDTHTIMINGS:
-    case WINED3DQUERYTYPE_CACHEUTILIZATION:
-    default:
-        object->extendedData = 0;
-        FIXME("(%p) Unhandled query type %d\n",This , Type);
-    }
-    TRACE("(%p) : Created Query %p\n", This, object);
+    TRACE("Created query %p.\n", object);
+    *query = (IWineD3DQuery *)object;
+
     return WINED3D_OK;
 }
@@ -983,9 +1118,37 @@
 }
 
+struct wined3d_fvf_convert_state
+{
+    const struct wined3d_gl_info *gl_info;
+    WINED3DVERTEXELEMENT *elements;
+    UINT offset;
+    UINT idx;
+};
+
+static void append_decl_element(struct wined3d_fvf_convert_state *state,
+        WINED3DFORMAT format, WINED3DDECLUSAGE usage, UINT usage_idx)
+{
+    WINED3DVERTEXELEMENT *elements = state->elements;
+    const struct wined3d_format_desc *format_desc;
+    UINT offset = state->offset;
+    UINT idx = state->idx;
+
+    elements[idx].format = format;
+    elements[idx].input_slot = 0;
+    elements[idx].offset = offset;
+    elements[idx].output_slot = 0;
+    elements[idx].method = WINED3DDECLMETHOD_DEFAULT;
+    elements[idx].usage = usage;
+    elements[idx].usage_idx = usage_idx;
+
+    format_desc = getFormatDescEntry(format, state->gl_info);
+    state->offset += format_desc->component_count * format_desc->component_size;
+    ++state->idx;
+}
+
 static unsigned int ConvertFvfToDeclaration(IWineD3DDeviceImpl *This, /* For the GL info, which has the type table */
-                                            DWORD fvf, WINED3DVERTEXELEMENT** ppVertexElements) {
-
-    unsigned int idx, idx2;
-    unsigned int offset;
+        DWORD fvf, WINED3DVERTEXELEMENT **ppVertexElements)
+{
+    const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
     BOOL has_pos = (fvf & WINED3DFVF_POSITION_MASK) != 0;
     BOOL has_blend = (fvf & WINED3DFVF_XYZB5) > WINED3DFVF_XYZRHW;
@@ -1001,7 +1164,7 @@
     DWORD num_textures = (fvf & WINED3DFVF_TEXCOUNT_MASK) >> WINED3DFVF_TEXCOUNT_SHIFT;
     DWORD texcoords = (fvf & 0xFFFF0000) >> 16;
-    WINED3DVERTEXELEMENT *elements = NULL;
-
+    struct wined3d_fvf_convert_state state;
     unsigned int size;
+    unsigned int idx;
     DWORD num_blends = 1 + (((fvf & WINED3DFVF_XYZB5) - WINED3DFVF_XYZB1) >> 1);
     if (has_blend_idx) num_blends--;
@@ -1011,110 +1174,82 @@
            has_psize + has_diffuse + has_specular + num_textures;
 
-    /* convert the declaration */
-    elements = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WINED3DVERTEXELEMENT));
-    if (!elements) return ~0U;
-
-    idx = 0;
-    if (has_pos) {
-        if (!has_blend && (fvf & WINED3DFVF_XYZRHW)) {
-            elements[idx].format = WINED3DFMT_R32G32B32A32_FLOAT;
-            elements[idx].usage = WINED3DDECLUSAGE_POSITIONT;
-        }
-        else if ((fvf & WINED3DFVF_XYZW) == WINED3DFVF_XYZW) {
-            elements[idx].format = WINED3DFMT_R32G32B32A32_FLOAT;
-            elements[idx].usage = WINED3DDECLUSAGE_POSITION;
-        }
-        else {
-            elements[idx].format = WINED3DFMT_R32G32B32_FLOAT;
-            elements[idx].usage = WINED3DDECLUSAGE_POSITION;
-        }
-        elements[idx].usage_idx = 0;
-        idx++;
-    }
-    if (has_blend && (num_blends > 0)) {
-        if (((fvf & WINED3DFVF_XYZB5) == WINED3DFVF_XYZB2) && (fvf & WINED3DFVF_LASTBETA_D3DCOLOR))
-            elements[idx].format = WINED3DFMT_B8G8R8A8_UNORM;
-        else {
-            switch(num_blends) {
-                case 1: elements[idx].format = WINED3DFMT_R32_FLOAT; break;
-                case 2: elements[idx].format = WINED3DFMT_R32G32_FLOAT; break;
-                case 3: elements[idx].format = WINED3DFMT_R32G32B32_FLOAT; break;
-                case 4: elements[idx].format = WINED3DFMT_R32G32B32A32_FLOAT; break;
+    state.gl_info = gl_info;
+    state.elements = HeapAlloc(GetProcessHeap(), 0, size * sizeof(*state.elements));
+    if (!state.elements) return ~0U;
+    state.offset = 0;
+    state.idx = 0;
+
+    if (has_pos)
+    {
+        if (!has_blend && (fvf & WINED3DFVF_XYZRHW))
+            append_decl_element(&state, WINED3DFMT_R32G32B32A32_FLOAT, WINED3DDECLUSAGE_POSITIONT, 0);
+        else if ((fvf & WINED3DFVF_XYZW) == WINED3DFVF_XYZW)
+            append_decl_element(&state, WINED3DFMT_R32G32B32A32_FLOAT, WINED3DDECLUSAGE_POSITION, 0);
+        else
+            append_decl_element(&state, WINED3DFMT_R32G32B32_FLOAT, WINED3DDECLUSAGE_POSITION, 0);
+    }
+
+    if (has_blend && (num_blends > 0))
+    {
+        if ((fvf & WINED3DFVF_XYZB5) == WINED3DFVF_XYZB2 && (fvf & WINED3DFVF_LASTBETA_D3DCOLOR))
+            append_decl_element(&state, WINED3DFMT_B8G8R8A8_UNORM, WINED3DDECLUSAGE_BLENDWEIGHT, 0);
+        else
+        {
+            switch (num_blends)
+            {
+                case 1:
+                    append_decl_element(&state, WINED3DFMT_R32_FLOAT, WINED3DDECLUSAGE_BLENDWEIGHT, 0);
+                    break;
+                case 2:
+                    append_decl_element(&state, WINED3DFMT_R32G32_FLOAT, WINED3DDECLUSAGE_BLENDWEIGHT, 0);
+                    break;
+                case 3:
+                    append_decl_element(&state, WINED3DFMT_R32G32B32_FLOAT, WINED3DDECLUSAGE_BLENDWEIGHT, 0);
+                    break;
+                case 4:
+                    append_decl_element(&state, WINED3DFMT_R32G32B32A32_FLOAT, WINED3DDECLUSAGE_BLENDWEIGHT, 0);
+                    break;
                 default:
                     ERR("Unexpected amount of blend values: %u\n", num_blends);
             }
         }
-        elements[idx].usage = WINED3DDECLUSAGE_BLENDWEIGHT;
-        elements[idx].usage_idx = 0;
-        idx++;
-    }
-    if (has_blend_idx) {
-        if (fvf & WINED3DFVF_LASTBETA_UBYTE4 ||
-            (((fvf & WINED3DFVF_XYZB5) == WINED3DFVF_XYZB2) && (fvf & WINED3DFVF_LASTBETA_D3DCOLOR)))
-            elements[idx].format = WINED3DFMT_R8G8B8A8_UINT;
+    }
+
+    if (has_blend_idx)
+    {
+        if ((fvf & WINED3DFVF_LASTBETA_UBYTE4)
+                || ((fvf & WINED3DFVF_XYZB5) == WINED3DFVF_XYZB2 && (fvf & WINED3DFVF_LASTBETA_D3DCOLOR)))
+            append_decl_element(&state, WINED3DFMT_R8G8B8A8_UINT, WINED3DDECLUSAGE_BLENDINDICES, 0);
         else if (fvf & WINED3DFVF_LASTBETA_D3DCOLOR)
-            elements[idx].format = WINED3DFMT_B8G8R8A8_UNORM;
+            append_decl_element(&state, WINED3DFMT_B8G8R8A8_UNORM, WINED3DDECLUSAGE_BLENDINDICES, 0);
         else
-            elements[idx].format = WINED3DFMT_R32_FLOAT;
-        elements[idx].usage = WINED3DDECLUSAGE_BLENDINDICES;
-        elements[idx].usage_idx = 0;
-        idx++;
-    }
-    if (has_normal) {
-        elements[idx].format = WINED3DFMT_R32G32B32_FLOAT;
-        elements[idx].usage = WINED3DDECLUSAGE_NORMAL;
-        elements[idx].usage_idx = 0;
-        idx++;
-    }
-    if (has_psize) {
-        elements[idx].format = WINED3DFMT_R32_FLOAT;
-        elements[idx].usage = WINED3DDECLUSAGE_PSIZE;
-        elements[idx].usage_idx = 0;
-        idx++;
-    }
-    if (has_diffuse) {
-        elements[idx].format = WINED3DFMT_B8G8R8A8_UNORM;
-        elements[idx].usage = WINED3DDECLUSAGE_COLOR;
-        elements[idx].usage_idx = 0;
-        idx++;
-    }
-    if (has_specular) {
-        elements[idx].format = WINED3DFMT_B8G8R8A8_UNORM;
-        elements[idx].usage = WINED3DDECLUSAGE_COLOR;
-        elements[idx].usage_idx = 1;
-        idx++;
-    }
-    for (idx2 = 0; idx2 < num_textures; idx2++) {
-        unsigned int numcoords = (texcoords >> (idx2*2)) & 0x03;
-        switch (numcoords) {
+            append_decl_element(&state, WINED3DFMT_R32_FLOAT, WINED3DDECLUSAGE_BLENDINDICES, 0);
+    }
+
+    if (has_normal) append_decl_element(&state, WINED3DFMT_R32G32B32_FLOAT, WINED3DDECLUSAGE_NORMAL, 0);
+    if (has_psize) append_decl_element(&state, WINED3DFMT_R32_FLOAT, WINED3DDECLUSAGE_PSIZE, 0);
+    if (has_diffuse) append_decl_element(&state, WINED3DFMT_B8G8R8A8_UNORM, WINED3DDECLUSAGE_COLOR, 0);
+    if (has_specular) append_decl_element(&state, WINED3DFMT_B8G8R8A8_UNORM, WINED3DDECLUSAGE_COLOR, 1);
+
+    for (idx = 0; idx < num_textures; ++idx)
+    {
+        switch ((texcoords >> (idx * 2)) & 0x03)
+        {
             case WINED3DFVF_TEXTUREFORMAT1:
-                elements[idx].format = WINED3DFMT_R32_FLOAT;
+                append_decl_element(&state, WINED3DFMT_R32_FLOAT, WINED3DDECLUSAGE_TEXCOORD, idx);
                 break;
             case WINED3DFVF_TEXTUREFORMAT2:
-                elements[idx].format = WINED3DFMT_R32G32_FLOAT;
+                append_decl_element(&state, WINED3DFMT_R32G32_FLOAT, WINED3DDECLUSAGE_TEXCOORD, idx);
                 break;
             case WINED3DFVF_TEXTUREFORMAT3:
-                elements[idx].format = WINED3DFMT_R32G32B32_FLOAT;
+                append_decl_element(&state, WINED3DFMT_R32G32B32_FLOAT, WINED3DDECLUSAGE_TEXCOORD, idx);
                 break;
             case WINED3DFVF_TEXTUREFORMAT4:
-                elements[idx].format = WINED3DFMT_R32G32B32A32_FLOAT;
+                append_decl_element(&state, WINED3DFMT_R32G32B32A32_FLOAT, WINED3DDECLUSAGE_TEXCOORD, idx);
                 break;
         }
-        elements[idx].usage = WINED3DDECLUSAGE_TEXCOORD;
-        elements[idx].usage_idx = idx2;
-        idx++;
-    }
-
-    /* Now compute offsets, and initialize the rest of the fields */
-    for (idx = 0, offset = 0; idx < size; ++idx)
-    {
-        const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(elements[idx].format, &This->adapter->gl_info);
-        elements[idx].input_slot = 0;
-        elements[idx].method = WINED3DDECLMETHOD_DEFAULT;
-        elements[idx].offset = offset;
-        offset += format_desc->component_count * format_desc->component_size;
-    }
-
-    *ppVertexElements = elements;
+    }
+
+    *ppVertexElements = state.elements;
     return size;
 }
@@ -1235,33 +1370,25 @@
     IWineD3DPaletteImpl *object;
     HRESULT hr;
-    TRACE("(%p)->(%x, %p, %p, %p)\n", This, Flags, PalEnt, Palette, Parent);
-
-    /* Create the new object */
-    object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IWineD3DPaletteImpl));
-    if(!object) {
-        ERR("Out of memory when allocating memory for a IWineD3DPalette implementation\n");
+
+    TRACE("iface %p, flags %#x, entries %p, palette %p, parent %p.\n",
+            iface, Flags, PalEnt, Palette, Parent);
+
+    object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+    if (!object)
+    {
+        ERR("Failed to allocate palette memory.\n");
         return E_OUTOFMEMORY;
     }
 
-    object->lpVtbl = &IWineD3DPalette_Vtbl;
-    object->ref = 1;
-    object->Flags = Flags;
-    object->parent = Parent;
-    object->device = This;
-    object->palNumEntries = IWineD3DPaletteImpl_Size(Flags);
-    object->hpal = CreatePalette((const LOGPALETTE*)&(object->palVersion));
-
-    if(!object->hpal) {
-        HeapFree( GetProcessHeap(), 0, object);
-        return E_OUTOFMEMORY;
-    }
-
-    hr = IWineD3DPalette_SetEntries((IWineD3DPalette *) object, 0, 0, IWineD3DPaletteImpl_Size(Flags), PalEnt);
-    if(FAILED(hr)) {
-        IWineD3DPalette_Release((IWineD3DPalette *) object);
+    hr = wined3d_palette_init(object, This, Flags, PalEnt, Parent);
+    if (FAILED(hr))
+    {
+        WARN("Failed to initialize palette, hr %#x.\n", hr);
+        HeapFree(GetProcessHeap(), 0, object);
         return hr;
     }
 
-    *Palette = (IWineD3DPalette *) object;
+    TRACE("Created palette %p.\n", object);
+    *Palette = (IWineD3DPalette *)object;
 
     return WINED3D_OK;
@@ -1382,4 +1509,28 @@
 }
 
+static HRESULT WINAPI IWineD3DDeviceImpl_AcquireFocusWindow(IWineD3DDevice *iface, HWND window)
+{
+    IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)iface;
+
+    if (!wined3d_register_window(window, device))
+    {
+        ERR("Failed to register window %p.\n", window);
+        return E_FAIL;
+    }
+
+    device->focus_window = window;
+    SetForegroundWindow(window);
+
+    return WINED3D_OK;
+}
+
+static void WINAPI IWineD3DDeviceImpl_ReleaseFocusWindow(IWineD3DDevice *iface)
+{
+    IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)iface;
+
+    if (device->focus_window) wined3d_unregister_window(device->focus_window);
+    device->focus_window = NULL;
+}
+
 static HRESULT WINAPI IWineD3DDeviceImpl_Init3D(IWineD3DDevice *iface,
         WINED3DPRESENT_PARAMETERS *pPresentationParameters)
@@ -1397,15 +1548,4 @@
     if(This->d3d_initialized) return WINED3DERR_INVALIDCALL;
     if(!This->adapter->opengl) return WINED3DERR_INVALIDCALL;
-
-    if (!pPresentationParameters->Windowed)
-    {
-        This->focus_window = This->createParms.hFocusWindow;
-        if (!This->focus_window) This->focus_window = pPresentationParameters->hDeviceWindow;
-        if (!wined3d_register_window(This->focus_window, This))
-        {
-            ERR("Failed to register window %p.\n", This->focus_window);
-            return E_FAIL;
-        }
-    }
 
     TRACE("(%p) : Creating stateblock\n", This);
@@ -1462,6 +1602,4 @@
     }
 
-    if (This->focus_window) SetFocus(This->focus_window);
-
     /* Setup the implicit swapchain. This also initializes a context. */
     TRACE("Creating implicit swapchain\n");
@@ -1534,8 +1672,4 @@
         case ORM_FBO:
             This->offscreenBuffer = GL_COLOR_ATTACHMENT0;
-            break;
-
-        case ORM_PBUFFER:
-            This->offscreenBuffer = GL_BACK;
             break;
 
@@ -1598,5 +1732,4 @@
         This->shader_backend->shader_free_private(iface);
     }
-    if (This->focus_window) wined3d_unregister_window(This->focus_window);
     return hr;
 }
@@ -1672,15 +1805,4 @@
         }
     }
-
-    /* Delete the palette conversion shader if it is around */
-    if(This->paletteConversionShader) {
-        ENTER_GL();
-        GL_EXTCALL(glDeleteProgramsARB(1, &This->paletteConversionShader));
-        LEAVE_GL();
-        This->paletteConversionShader = 0;
-    }
-
-    /* Delete the pbuffer context if there is any */
-    if(This->pbufferContext) context_destroy(This, This->pbufferContext);
 
     /* Delete the mouse cursor texture */
@@ -1750,7 +1872,6 @@
 
     TRACE("Releasing the render target at %p\n", This->render_targets[0]);
-    if(IWineD3DSurface_Release(This->render_targets[0]) >0){
-          /* This check is a bit silly, it should be in swapchain_release FIXME("(%p) Something's still holding the renderTarget\n",This); */
-    }
+    IWineD3DSurface_Release(This->render_targets[0]);
+
     TRACE("Setting rendertarget to NULL\n");
     This->render_targets[0] = NULL;
@@ -1788,6 +1909,4 @@
 
     This->d3d_initialized = FALSE;
-
-    if (This->focus_window) wined3d_unregister_window(This->focus_window);
 
     return WINED3D_OK;
@@ -1828,6 +1947,6 @@
     DEVMODEW devmode;
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
+    const struct wined3d_format_desc *format_desc = getFormatDescEntry(pMode->Format, &This->adapter->gl_info);
     LONG ret;
-    const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(pMode->Format, &This->adapter->gl_info);
     RECT clip_rc;
 
@@ -2943,5 +3062,5 @@
             iface, dstData, start, count);
 
-    if (dstData == NULL || ((signed int) MAX_CONST_I - (signed int) start) <= (signed int) 0)
+    if (dstData == NULL || ((signed int) MAX_CONST_I - (signed int) start) <= 0)
         return WINED3DERR_INVALIDCALL;
 
@@ -3064,5 +3183,6 @@
 }
 
-static void device_map_fixed_function_samplers(IWineD3DDeviceImpl *This) {
+static void device_map_fixed_function_samplers(IWineD3DDeviceImpl *This, const struct wined3d_gl_info *gl_info)
+{
     unsigned int i, tex;
     WORD ffu_map;
@@ -3071,6 +3191,7 @@
     ffu_map = This->fixed_function_usage_map;
 
-    if (This->max_ffp_textures == This->max_ffp_texture_stages ||
-            This->stateBlock->lowest_disabled_stage <= This->max_ffp_textures) {
+    if (This->max_ffp_textures == gl_info->limits.texture_stages
+            || This->stateBlock->lowest_disabled_stage <= This->max_ffp_textures)
+    {
         for (i = 0; ffu_map; ffu_map >>= 1, ++i)
         {
@@ -3102,5 +3223,6 @@
 }
 
-static void device_map_psamplers(IWineD3DDeviceImpl *This) {
+static void device_map_psamplers(IWineD3DDeviceImpl *This, const struct wined3d_gl_info *gl_info)
+{
     const WINED3DSAMPLER_TEXTURE_TYPE *sampler_type =
             ((IWineD3DPixelShaderImpl *)This->stateBlock->pixelShader)->baseShader.reg_maps.sampler_type;
@@ -3112,5 +3234,6 @@
             device_map_stage(This, i, i);
             IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(i));
-            if (i < MAX_TEXTURES) {
+            if (i < gl_info->limits.texture_stages)
+            {
                 markTextureStagesDirty(This, i);
             }
@@ -3143,9 +3266,10 @@
 }
 
-static void device_map_vsamplers(IWineD3DDeviceImpl *This, BOOL ps) {
+static void device_map_vsamplers(IWineD3DDeviceImpl *This, BOOL ps, const struct wined3d_gl_info *gl_info)
+{
     const WINED3DSAMPLER_TEXTURE_TYPE *vshader_sampler_type =
             ((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->baseShader.reg_maps.sampler_type;
     const WINED3DSAMPLER_TEXTURE_TYPE *pshader_sampler_type = NULL;
-    int start = min(MAX_COMBINED_SAMPLERS, This->adapter->gl_info.limits.combined_samplers) - 1;
+    int start = min(MAX_COMBINED_SAMPLERS, gl_info->limits.combined_samplers) - 1;
     int i;
 
@@ -3184,5 +3308,7 @@
 }
 
-void IWineD3DDeviceImpl_FindTexUnitMap(IWineD3DDeviceImpl *This) {
+void IWineD3DDeviceImpl_FindTexUnitMap(IWineD3DDeviceImpl *This)
+{
+    const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
     BOOL vs = use_vs(This->stateBlock);
     BOOL ps = use_ps(This->stateBlock);
@@ -3194,13 +3320,8 @@
      * to be reset. Because of that try to work with a 1:1 mapping as much as possible
      */
-    if (ps) {
-        device_map_psamplers(This);
-    } else {
-        device_map_fixed_function_samplers(This);
-    }
-
-    if (vs) {
-        device_map_vsamplers(This, ps);
-    }
+    if (ps) device_map_psamplers(This, gl_info);
+    else device_map_fixed_function_samplers(This, gl_info);
+
+    if (vs) device_map_vsamplers(This, ps, gl_info);
 }
 
@@ -3816,9 +3937,12 @@
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
     DWORD oldValue = This->updateStateBlock->textureState[Stage][Type];
+    const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
 
     TRACE("(%p) : Stage=%d, Type=%s(%d), Value=%d\n", This, Stage, debug_d3dtexturestate(Type), Type, Value);
 
-    if (Stage >= MAX_TEXTURES) {
-        WARN("Attempting to set stage %u which is higher than the max stage %u, ignoring\n", Stage, MAX_TEXTURES - 1);
+    if (Stage >= gl_info->limits.texture_stages)
+    {
+        WARN("Attempting to set stage %u which is higher than the max stage %u, ignoring.\n",
+                Stage, gl_info->limits.texture_stages - 1);
         return WINED3D_OK;
     }
@@ -3901,4 +4025,5 @@
 {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
+    const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
     IWineD3DBaseTexture *prev;
 
@@ -3959,5 +4084,5 @@
         }
 
-        if (!prev && stage < MAX_TEXTURES)
+        if (!prev && stage < gl_info->limits.texture_stages)
         {
             /* The source arguments for color and alpha ops have different
@@ -3978,5 +4103,5 @@
         IWineD3DBaseTexture_Release(prev);
 
-        if (!texture && stage < MAX_TEXTURES)
+        if (!texture && stage < gl_info->limits.texture_stages)
         {
             IWineD3DDeviceImpl_MarkStateDirty(This, STATE_TEXTURESTAGE(stage, WINED3DTSS_COLOROP));
@@ -4205,16 +4330,42 @@
 }
 
+static BOOL is_full_clear(IWineD3DSurfaceImpl *target, const WINED3DVIEWPORT *viewport,
+        const RECT *scissor_rect, const WINED3DRECT *clear_rect)
+{
+    /* partial viewport*/
+    if (viewport->X != 0 || viewport->Y != 0
+            || viewport->Width < target->currentDesc.Width
+            || viewport->Height < target->currentDesc.Height)
+        return FALSE;
+
+    /* partial scissor rect */
+    if (scissor_rect && (scissor_rect->left > 0 || scissor_rect->top > 0
+            || scissor_rect->right < target->currentDesc.Width
+            || scissor_rect->bottom < target->currentDesc.Height))
+        return FALSE;
+
+    /* partial clear rect */
+    if (clear_rect && (clear_rect->x1 > 0 || clear_rect->y1 > 0
+            || clear_rect->x2 < target->currentDesc.Width
+            || clear_rect->y2 < target->currentDesc.Height))
+        return FALSE;
+
+    return TRUE;
+}
+
 /* Not called from the VTable (internal subroutine) */
-HRESULT IWineD3DDeviceImpl_ClearSurface(IWineD3DDeviceImpl *This,  IWineD3DSurfaceImpl *target, DWORD Count,
-                                        CONST WINED3DRECT* pRects, DWORD Flags, WINED3DCOLOR Color,
-                                        float Z, DWORD Stencil) {
+HRESULT IWineD3DDeviceImpl_ClearSurface(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *target, DWORD Count,
+        const WINED3DRECT *pRects, DWORD Flags, WINED3DCOLOR Color, float Z, DWORD Stencil)
+{
+    IWineD3DStateBlockImpl *stateblock = This->stateBlock;
+    const RECT *scissor_rect = stateblock->renderState[WINED3DRS_SCISSORTESTENABLE] ? &stateblock->scissorRect : NULL;
+    const WINED3DRECT *clear_rect = (Count > 0 && pRects) ? pRects : NULL;
+    const WINED3DVIEWPORT *vp = &stateblock->viewport;
     GLbitfield     glMask = 0;
     unsigned int   i;
     WINED3DRECT curRect;
     RECT vp_rect;
-    const WINED3DVIEWPORT *vp = &This->stateBlock->viewport;
     UINT drawable_width, drawable_height;
     IWineD3DSurfaceImpl *depth_stencil = (IWineD3DSurfaceImpl *) This->stencilBufferTarget;
-    IWineD3DSwapChainImpl *swapchain = NULL;
     struct wined3d_context *context;
 
@@ -4228,30 +4379,40 @@
      * checking all this if the dest surface is in the drawable anyway.
      */
-    if((Flags & WINED3DCLEAR_TARGET) && !(target->Flags & SFLAG_INDRAWABLE)) {
-        while(1) {
-            if(vp->X != 0 || vp->Y != 0 ||
-               vp->Width < target->currentDesc.Width || vp->Height < target->currentDesc.Height) {
-                IWineD3DSurface_LoadLocation((IWineD3DSurface *) target, SFLAG_INDRAWABLE, NULL);
-                break;
-            }
-            if(This->stateBlock->renderState[WINED3DRS_SCISSORTESTENABLE] && (
-               This->stateBlock->scissorRect.left > 0 || This->stateBlock->scissorRect.top > 0 ||
-               This->stateBlock->scissorRect.right < target->currentDesc.Width ||
-               This->stateBlock->scissorRect.bottom < target->currentDesc.Height)) {
-                IWineD3DSurface_LoadLocation((IWineD3DSurface *) target, SFLAG_INDRAWABLE, NULL);
-                break;
-            }
-            if(Count > 0 && pRects && (
-               pRects[0].x1 > 0 || pRects[0].y1 > 0 ||
-               pRects[0].x2 < target->currentDesc.Width ||
-               pRects[0].y2 < target->currentDesc.Height)) {
-                IWineD3DSurface_LoadLocation((IWineD3DSurface *) target, SFLAG_INDRAWABLE, NULL);
-                break;
-            }
-            break;
-        }
+    if (Flags & WINED3DCLEAR_TARGET && !(target->Flags & SFLAG_INDRAWABLE))
+    {
+        if (!is_full_clear(target, vp, scissor_rect, clear_rect))
+            IWineD3DSurface_LoadLocation((IWineD3DSurface *)target, SFLAG_INDRAWABLE, NULL);
     }
 
     context = context_acquire(This, (IWineD3DSurface *)target, CTXUSAGE_CLEAR);
+    if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
+    {
+        if (!surface_is_offscreen((IWineD3DSurface *)target))
+        {
+            TRACE("Surface %p is onscreen\n", target);
+
+            ENTER_GL();
+            context_bind_fbo(context, GL_FRAMEBUFFER, NULL);
+            context_set_draw_buffer(context, surface_get_gl_buffer((IWineD3DSurface *)target));
+            LEAVE_GL();
+        }
+        else
+        {
+            TRACE("Surface %p is offscreen\n", target);
+
+            ENTER_GL();
+            context_bind_fbo(context, GL_FRAMEBUFFER, &context->dst_fbo);
+            context_attach_surface_fbo(context, GL_FRAMEBUFFER, 0, target);
+            context_attach_depth_stencil_fbo(context, GL_FRAMEBUFFER, depth_stencil, TRUE);
+            LEAVE_GL();
+        }
+    }
+
+    if (!context->valid)
+    {
+        context_release(context);
+        WARN("Invalid context, skipping clear.\n");
+        return WINED3D_OK;
+    }
 
     target->get_drawable_size(context, &drawable_width, &drawable_height);
@@ -4260,47 +4421,40 @@
 
     /* Only set the values up once, as they are not changing */
-    if (Flags & WINED3DCLEAR_STENCIL) {
+    if (Flags & WINED3DCLEAR_STENCIL)
+    {
+        if (context->gl_info->supported[EXT_STENCIL_TWO_SIDE])
+        {
+            glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT);
+            IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_TWOSIDEDSTENCILMODE));
+        }
+        glStencilMask(~0U);
+        IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_STENCILWRITEMASK));
         glClearStencil(Stencil);
         checkGLcall("glClearStencil");
         glMask = glMask | GL_STENCIL_BUFFER_BIT;
-        glStencilMask(0xFFFFFFFF);
-    }
-
-    if (Flags & WINED3DCLEAR_ZBUFFER) {
+    }
+
+    if (Flags & WINED3DCLEAR_ZBUFFER)
+    {
         DWORD location = context->render_offscreen ? SFLAG_DS_OFFSCREEN : SFLAG_DS_ONSCREEN;
+        if (!(depth_stencil->Flags & location) && !is_full_clear(depth_stencil, vp, scissor_rect, clear_rect))
+            surface_load_ds_location(This->stencilBufferTarget, context, location);
+
         glDepthMask(GL_TRUE);
+        IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_ZWRITEENABLE));
         glClearDepth(Z);
         checkGLcall("glClearDepth");
         glMask = glMask | GL_DEPTH_BUFFER_BIT;
-        IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_ZWRITEENABLE));
-
-        if (vp->X != 0 || vp->Y != 0 ||
-                vp->Width < depth_stencil->currentDesc.Width || vp->Height < depth_stencil->currentDesc.Height) {
-            surface_load_ds_location(This->stencilBufferTarget, context, location);
-        }
-        else if (This->stateBlock->renderState[WINED3DRS_SCISSORTESTENABLE] && (
-                This->stateBlock->scissorRect.left > 0 || This->stateBlock->scissorRect.top > 0 ||
-                This->stateBlock->scissorRect.right < depth_stencil->currentDesc.Width ||
-                This->stateBlock->scissorRect.bottom < depth_stencil->currentDesc.Height)) {
-            surface_load_ds_location(This->stencilBufferTarget, context, location);
-        }
-        else if (Count > 0 && pRects && (
-                pRects[0].x1 > 0 || pRects[0].y1 > 0 ||
-                pRects[0].x2 < depth_stencil->currentDesc.Width ||
-                pRects[0].y2 < depth_stencil->currentDesc.Height)) {
-            surface_load_ds_location(This->stencilBufferTarget, context, location);
-        }
-    }
-
-    if (Flags & WINED3DCLEAR_TARGET) {
-        TRACE("Clearing screen with glClear to color %x\n", Color);
-        glClearColor(D3DCOLOR_R(Color),
-                     D3DCOLOR_G(Color),
-                     D3DCOLOR_B(Color),
-                     D3DCOLOR_A(Color));
+    }
+
+    if (Flags & WINED3DCLEAR_TARGET)
+    {
+        glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+        IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_COLORWRITEENABLE));
+        IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_COLORWRITEENABLE1));
+        IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_COLORWRITEENABLE2));
+        IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_COLORWRITEENABLE3));
+        glClearColor(D3DCOLOR_R(Color), D3DCOLOR_G(Color), D3DCOLOR_B(Color), D3DCOLOR_A(Color));
         checkGLcall("glClearColor");
-
-        /* Clear ALL colors! */
-        glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
         glMask = glMask | GL_COLOR_BUFFER_BIT;
     }
@@ -4362,18 +4516,6 @@
     }
 
-    /* Restore the old values (why..?) */
-    if (Flags & WINED3DCLEAR_STENCIL) {
-        glStencilMask(This->stateBlock->renderState[WINED3DRS_STENCILWRITEMASK]);
-    }
-    if (Flags & WINED3DCLEAR_TARGET) {
-        DWORD mask = This->stateBlock->renderState[WINED3DRS_COLORWRITEENABLE];
-        glColorMask(mask & WINED3DCOLORWRITEENABLE_RED ? GL_TRUE : GL_FALSE,
-                    mask & WINED3DCOLORWRITEENABLE_GREEN ? GL_TRUE : GL_FALSE,
-                    mask & WINED3DCOLORWRITEENABLE_BLUE  ? GL_TRUE : GL_FALSE,
-                    mask & WINED3DCOLORWRITEENABLE_ALPHA ? GL_TRUE : GL_FALSE);
-
-        /* Dirtify the target surface for now. If the surface is locked regularly, and an up to date sysmem copy exists,
-         * it is most likely more efficient to perform a clear on the sysmem copy too instead of downloading it
-         */
+    if (Flags & WINED3DCLEAR_TARGET)
+    {
         IWineD3DSurface_ModifyLocation((IWineD3DSurface *)target, SFLAG_INDRAWABLE, TRUE);
     }
@@ -4386,10 +4528,7 @@
     LEAVE_GL();
 
-    if (SUCCEEDED(IWineD3DSurface_GetContainer((IWineD3DSurface *)target, &IID_IWineD3DSwapChain, (void **)&swapchain))) {
-        if (target == (IWineD3DSurfaceImpl*) swapchain->frontBuffer) {
-            wglFlush();
-        }
-        IWineD3DSwapChain_Release((IWineD3DSwapChain *) swapchain);
-    }
+    if (wined3d_settings.strict_draw_ordering || ((target->Flags & SFLAG_SWAPCHAIN)
+            && ((IWineD3DSwapChainImpl *)target->container)->frontBuffer == (IWineD3DSurface *)target))
+        wglFlush(); /* Flush to ensure ordering across contexts. */
 
     context_release(context);
@@ -5044,67 +5183,52 @@
 }
 
-static HRESULT  WINAPI  IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface, IWineD3DSurface *pSourceSurface, CONST RECT* pSourceRect, IWineD3DSurface *pDestinationSurface, CONST POINT* pDestPoint) {
-    IWineD3DDeviceImpl  *This         = (IWineD3DDeviceImpl *) iface;
-    /** TODO: remove casts to IWineD3DSurfaceImpl
-     *       NOTE: move code to surface to accomplish this
-      ****************************************/
-    IWineD3DSurfaceImpl *pSrcSurface  = (IWineD3DSurfaceImpl *)pSourceSurface;
-    IWineD3DSurfaceImpl *dst_impl = (IWineD3DSurfaceImpl *)pDestinationSurface;
-    int srcWidth, srcHeight;
-    unsigned int  srcSurfaceWidth, srcSurfaceHeight, destSurfaceWidth, destSurfaceHeight;
-    WINED3DFORMAT destFormat, srcFormat;
-    UINT          destSize;
-    int srcLeft, destLeft, destTop;
-    WINED3DPOOL       srcPool, destPool;
-    int offset    = 0;
-    int rowoffset = 0; /* how many bytes to add onto the end of a row to wraparound to the beginning of the next */
-    const struct GlPixelFormatDesc *src_format_desc, *dst_format_desc;
-    GLenum dummy;
+static HRESULT WINAPI IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface,
+        IWineD3DSurface *src_surface, const RECT *src_rect,
+        IWineD3DSurface *dst_surface, const POINT *dst_point)
+{
+    IWineD3DSurfaceImpl *src_impl = (IWineD3DSurfaceImpl *)src_surface;
+    IWineD3DSurfaceImpl *dst_impl = (IWineD3DSurfaceImpl *)dst_surface;
+    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
+    const struct wined3d_format_desc *src_format;
+    const struct wined3d_format_desc *dst_format;
+    struct wined3d_context *context;
+    const unsigned char *data;
+    UINT update_w, update_h;
+    CONVERT_TYPES convert;
+    UINT src_w, src_h;
+    UINT dst_x, dst_y;
     DWORD sampler;
-    int bpp;
-    CONVERT_TYPES convert = NO_CONVERSION;
-    struct wined3d_context *context;
-
-    WINED3DSURFACE_DESC  winedesc;
-
-    TRACE("(%p) : Source (%p)  Rect (%p) Destination (%p) Point(%p)\n", This, pSourceSurface, pSourceRect, pDestinationSurface, pDestPoint);
-
-    IWineD3DSurface_GetDesc(pSourceSurface, &winedesc);
-    srcSurfaceWidth = winedesc.width;
-    srcSurfaceHeight = winedesc.height;
-    srcPool = winedesc.pool;
-    srcFormat = winedesc.format;
-
-    IWineD3DSurface_GetDesc(pDestinationSurface, &winedesc);
-    destSurfaceWidth = winedesc.width;
-    destSurfaceHeight = winedesc.height;
-    destPool = winedesc.pool;
-    destFormat = winedesc.format;
-    destSize = winedesc.size;
-
-    if(srcPool != WINED3DPOOL_SYSTEMMEM  || destPool != WINED3DPOOL_DEFAULT){
-        WARN("source %p must be SYSTEMMEM and dest %p must be DEFAULT, returning WINED3DERR_INVALIDCALL\n", pSourceSurface, pDestinationSurface);
+    struct wined3d_format_desc dummy_desc;
+
+    TRACE("iface %p, src_surface %p, src_rect %s, dst_surface %p, dst_point %s",
+            iface, src_surface, wine_dbgstr_rect(src_rect),
+            dst_surface, wine_dbgstr_point(dst_point));
+
+    if (src_impl->resource.pool != WINED3DPOOL_SYSTEMMEM || dst_impl->resource.pool != WINED3DPOOL_DEFAULT)
+    {
+        WARN("source %p must be SYSTEMMEM and dest %p must be DEFAULT, returning WINED3DERR_INVALIDCALL\n",
+                src_surface, dst_surface);
         return WINED3DERR_INVALIDCALL;
     }
 
-    /* This call loads the opengl surface directly, instead of copying the surface to the
-     * destination's sysmem copy. If surface conversion is needed, use BltFast instead to
-     * copy in sysmem and use regular surface loading.
-     */
-    d3dfmt_get_conv(dst_impl, FALSE, TRUE, &dummy, &dummy, &dummy, &convert, &bpp, FALSE);
-    if(convert != NO_CONVERSION) {
-        return IWineD3DSurface_BltFast(pDestinationSurface,
-                                        pDestPoint  ? pDestPoint->x : 0,
-                                        pDestPoint  ? pDestPoint->y : 0,
-                                        pSourceSurface, pSourceRect, 0);
-    }
-
-    if (destFormat == WINED3DFMT_UNKNOWN) {
-        TRACE("(%p) : Converting destination surface from WINED3DFMT_UNKNOWN to the source format\n", This);
-        IWineD3DSurface_SetFormat(pDestinationSurface, srcFormat);
-
-        /* Get the update surface description */
-        IWineD3DSurface_GetDesc(pDestinationSurface, &winedesc);
-    }
+    src_format = src_impl->resource.format_desc;
+    dst_format = dst_impl->resource.format_desc;
+
+    if (src_format->format != dst_format->format)
+    {
+        WARN("Source and destination surfaces should have the same format.\n");
+        return WINED3DERR_INVALIDCALL;
+    }
+
+    dst_x = dst_point ? dst_point->x : 0;
+    dst_y = dst_point ? dst_point->y : 0;
+
+    /* This call loads the OpenGL surface directly, instead of copying the
+     * surface to the destination's sysmem copy. If surface conversion is
+     * needed, use BltFast instead to copy in sysmem and use regular surface
+     * loading. */
+    d3dfmt_get_conv(dst_impl, FALSE, TRUE, &dummy_desc, &convert);
+    if (convert != NO_CONVERSION)
+        return IWineD3DSurface_BltFast(dst_surface, dst_x, dst_y, src_surface, src_rect, 0);
 
     context = context_acquire(This, NULL, CTXUSAGE_RESOURCELOAD);
@@ -5116,90 +5240,77 @@
 
     /* Make sure the surface is loaded and up to date */
-    surface_internal_preload(pDestinationSurface, SRGB_RGB);
-    IWineD3DSurface_BindTexture(pDestinationSurface, FALSE);
-
-    src_format_desc = ((IWineD3DSurfaceImpl *)pSrcSurface)->resource.format_desc;
-    dst_format_desc = dst_impl->resource.format_desc;
-
-    /* this needs to be done in lines if the sourceRect != the sourceWidth */
-    srcWidth   = pSourceRect ? pSourceRect->right - pSourceRect->left   : srcSurfaceWidth;
-    srcHeight  = pSourceRect ? pSourceRect->bottom - pSourceRect->top   : srcSurfaceHeight;
-    srcLeft    = pSourceRect ? pSourceRect->left : 0;
-    destLeft   = pDestPoint  ? pDestPoint->x : 0;
-    destTop    = pDestPoint  ? pDestPoint->y : 0;
-
-
-    /* This function doesn't support compressed textures
-    the pitch is just bytesPerPixel * width */
-    if(srcWidth != srcSurfaceWidth  || srcLeft ){
-        rowoffset = srcSurfaceWidth * src_format_desc->byte_count;
-        offset   += srcLeft * src_format_desc->byte_count;
-        /* TODO: do we ever get 3bpp?, would a shift and an add be quicker than a mul (well maybe a cycle or two) */
-    }
-    /* TODO DXT formats */
-
-    if(pSourceRect != NULL && pSourceRect->top != 0){
-       offset +=  pSourceRect->top * srcSurfaceWidth * src_format_desc->byte_count;
-    }
-    TRACE("(%p) glTexSubImage2D, level %d, left %d, top %d, width %d, height %d, fmt %#x, type %#x, memory %p+%#x\n",
-            This, dst_impl->texture_level, destLeft, destTop, srcWidth, srcHeight, dst_format_desc->glFormat,
-            dst_format_desc->glType, IWineD3DSurface_GetData(pSourceSurface), offset);
-
-    /* Sanity check */
-    if (IWineD3DSurface_GetData(pSourceSurface) == NULL) {
-
-        /* need to lock the surface to get the data */
-        FIXME("Surfaces has no allocated memory, but should be an in memory only surface\n");
-    }
+    surface_internal_preload(dst_surface, SRGB_RGB);
+    IWineD3DSurface_BindTexture(dst_surface, FALSE);
+
+    src_w = src_impl->currentDesc.Width;
+    src_h = src_impl->currentDesc.Height;
+    update_w = src_rect ? src_rect->right - src_rect->left : src_w;
+    update_h = src_rect ? src_rect->bottom - src_rect->top : src_h;
+
+    data = IWineD3DSurface_GetData(src_surface);
+    if (!data) ERR("Source surface has no allocated memory, but should be a sysmem surface.\n");
 
     ENTER_GL();
 
-    /* TODO: Cube and volume support */
-    if(rowoffset != 0){
-        /* not a whole row so we have to do it a line at a time */
-        int j;
-
-        /* hopefully using pointer addition will be quicker than using a point + j * rowoffset */
-        const unsigned char* data =((const unsigned char *)IWineD3DSurface_GetData(pSourceSurface)) + offset;
-
-        for (j = destTop; j < (srcHeight + destTop); ++j)
+    if (dst_format->Flags & WINED3DFMT_FLAG_COMPRESSED)
+    {
+        UINT row_length = (update_w / src_format->block_width) * src_format->block_byte_count;
+        UINT row_count = update_h / src_format->block_height;
+        UINT src_pitch = IWineD3DSurface_GetPitch(src_surface);
+
+        if (src_rect)
         {
-            glTexSubImage2D(dst_impl->texture_target, dst_impl->texture_level, destLeft, j,
-                    srcWidth, 1, dst_format_desc->glFormat, dst_format_desc->glType,data);
-            data += rowoffset;
-        }
-
-    } else { /* Full width, so just write out the whole texture */
-        const unsigned char* data = ((const unsigned char *)IWineD3DSurface_GetData(pSourceSurface)) + offset;
-
-        if (dst_format_desc->Flags & WINED3DFMT_FLAG_COMPRESSED)
+            data += (src_rect->top / src_format->block_height) * src_pitch;
+            data += (src_rect->left / src_format->block_width) * src_format->block_byte_count;
+        }
+
+        TRACE("glCompressedTexSubImage2DARB, target %#x, level %d, x %d, y %d, w %d, h %d, "
+                "format %#x, image_size %#x, data %p.\n", dst_impl->texture_target, dst_impl->texture_level,
+                dst_x, dst_y, update_w, update_h, dst_format->glFormat, row_count * row_length, data);
+
+        if (row_length == src_pitch)
         {
-            if (destSurfaceHeight != srcHeight || destSurfaceWidth != srcWidth)
-            {
-                /* FIXME: The easy way to do this is to lock the destination, and copy the bits across. */
-                FIXME("Updating part of a compressed texture is not supported.\n");
-            }
-            if (destFormat != srcFormat)
-            {
-                FIXME("Updating mixed format compressed textures is not supported.\n");
-            }
-            else
-            {
-                GL_EXTCALL(glCompressedTexImage2DARB(dst_impl->texture_target, dst_impl->texture_level,
-                        dst_format_desc->glInternal, srcWidth, srcHeight, 0, destSize, data));
-            }
+            GL_EXTCALL(glCompressedTexSubImage2DARB(dst_impl->texture_target, dst_impl->texture_level,
+                    dst_x, dst_y, update_w, update_h, dst_format->glInternal, row_count * row_length, data));
         }
         else
         {
-            glTexSubImage2D(dst_impl->texture_target, dst_impl->texture_level, destLeft, destTop,
-                    srcWidth, srcHeight, dst_format_desc->glFormat, dst_format_desc->glType, data);
-        }
-     }
-    checkGLcall("glTexSubImage2D");
+            UINT row, y;
+
+            /* glCompressedTexSubImage2DARB() ignores pixel store state, so we
+             * can't use the unpack row length like below. */
+            for (row = 0, y = dst_y; row < row_count; ++row)
+            {
+                GL_EXTCALL(glCompressedTexSubImage2DARB(dst_impl->texture_target, dst_impl->texture_level,
+                        dst_x, y, update_w, src_format->block_height, dst_format->glInternal, row_length, data));
+                y += src_format->block_height;
+                data += src_pitch;
+            }
+        }
+        checkGLcall("glCompressedTexSubImage2DARB");
+    }
+    else
+    {
+        if (src_rect)
+        {
+            data += src_rect->top * src_w * src_format->byte_count;
+            data += src_rect->left * src_format->byte_count;
+        }
+
+        TRACE("glTexSubImage2D, target %#x, level %d, x %d, y %d, w %d, h %d, format %#x, type %#x, data %p.\n",
+                dst_impl->texture_target, dst_impl->texture_level, dst_x, dst_y,
+                update_w, update_h, dst_format->glFormat, dst_format->glType, data);
+
+        glPixelStorei(GL_UNPACK_ROW_LENGTH, src_w);
+        glTexSubImage2D(dst_impl->texture_target, dst_impl->texture_level, dst_x, dst_y,
+                update_w, update_h, dst_format->glFormat, dst_format->glType, data);
+        glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+        checkGLcall("glTexSubImage2D");
+    }
 
     LEAVE_GL();
     context_release(context);
 
-    IWineD3DSurface_ModifyLocation(pDestinationSurface, SFLAG_INTEXTURE, TRUE);
+    IWineD3DSurface_ModifyLocation(dst_surface, SFLAG_INTEXTURE, TRUE);
     sampler = This->rev_tex_unit_map[0];
     if (sampler != WINED3D_UNMAPPED_STAGE)
@@ -5331,17 +5442,4 @@
 }
 
-static IWineD3DSwapChain *get_swapchain(IWineD3DSurface *target) {
-    HRESULT hr;
-    IWineD3DSwapChain *swapchain;
-
-    hr = IWineD3DSurface_GetContainer(target, &IID_IWineD3DSwapChain, (void **)&swapchain);
-    if (SUCCEEDED(hr)) {
-        IWineD3DSwapChain_Release((IUnknown *)swapchain);
-        return swapchain;
-    }
-
-    return NULL;
-}
-
 static void color_fill_fbo(IWineD3DDevice *iface, IWineD3DSurface *surface,
         const WINED3DRECT *rect, const float color[4])
@@ -5349,4 +5447,7 @@
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
     struct wined3d_context *context;
+
+    if (rect) IWineD3DSurface_LoadLocation(surface, SFLAG_INDRAWABLE, NULL);
+    IWineD3DSurface_ModifyLocation(surface, SFLAG_INDRAWABLE, TRUE);
 
     if (!surface_is_offscreen(surface))
@@ -5366,5 +5467,5 @@
         ENTER_GL();
         context_bind_fbo(context, GL_FRAMEBUFFER, &context->dst_fbo);
-        context_attach_surface_fbo(context, GL_FRAMEBUFFER, 0, surface);
+        context_attach_surface_fbo(context, GL_FRAMEBUFFER, 0, (IWineD3DSurfaceImpl *)surface);
         context_attach_depth_stencil_fbo(context, GL_FRAMEBUFFER, NULL, FALSE);
     }
@@ -5390,4 +5491,7 @@
     glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
     IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_COLORWRITEENABLE));
+    IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_COLORWRITEENABLE1));
+    IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_COLORWRITEENABLE2));
+    IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_COLORWRITEENABLE3));
 
     glClearColor(color[0], color[1], color[2], color[3]);
@@ -5396,113 +5500,8 @@
 
     LEAVE_GL();
+
+    if (wined3d_settings.strict_draw_ordering) wglFlush(); /* Flush to ensure ordering across contexts. */
+
     context_release(context);
-}
-
-static inline DWORD argb_to_fmt(DWORD color, WINED3DFORMAT destfmt) {
-    unsigned int r, g, b, a;
-    DWORD ret;
-
-    if (destfmt == WINED3DFMT_B8G8R8A8_UNORM
-            || destfmt == WINED3DFMT_B8G8R8X8_UNORM
-            || destfmt == WINED3DFMT_B8G8R8_UNORM)
-        return color;
-
-    TRACE("Converting color %08x to format %s\n", color, debug_d3dformat(destfmt));
-
-    a = (color & 0xff000000) >> 24;
-    r = (color & 0x00ff0000) >> 16;
-    g = (color & 0x0000ff00) >>  8;
-    b = (color & 0x000000ff) >>  0;
-
-    switch(destfmt)
-    {
-        case WINED3DFMT_B5G6R5_UNORM:
-            if(r == 0xff && g == 0xff && b == 0xff) return 0xffff;
-            r = (r * 32) / 256;
-            g = (g * 64) / 256;
-            b = (b * 32) / 256;
-            ret  = r << 11;
-            ret |= g << 5;
-            ret |= b;
-            TRACE("Returning %08x\n", ret);
-            return ret;
-
-        case WINED3DFMT_B5G5R5X1_UNORM:
-        case WINED3DFMT_B5G5R5A1_UNORM:
-            a = (a *  2) / 256;
-            r = (r * 32) / 256;
-            g = (g * 32) / 256;
-            b = (b * 32) / 256;
-            ret  = a << 15;
-            ret |= r << 10;
-            ret |= g <<  5;
-            ret |= b <<  0;
-            TRACE("Returning %08x\n", ret);
-            return ret;
-
-        case WINED3DFMT_A8_UNORM:
-            TRACE("Returning %08x\n", a);
-            return a;
-
-        case WINED3DFMT_B4G4R4X4_UNORM:
-        case WINED3DFMT_B4G4R4A4_UNORM:
-            a = (a * 16) / 256;
-            r = (r * 16) / 256;
-            g = (g * 16) / 256;
-            b = (b * 16) / 256;
-            ret  = a << 12;
-            ret |= r <<  8;
-            ret |= g <<  4;
-            ret |= b <<  0;
-            TRACE("Returning %08x\n", ret);
-            return ret;
-
-        case WINED3DFMT_B2G3R3_UNORM:
-            r = (r * 8) / 256;
-            g = (g * 8) / 256;
-            b = (b * 4) / 256;
-            ret  = r <<  5;
-            ret |= g <<  2;
-            ret |= b <<  0;
-            TRACE("Returning %08x\n", ret);
-            return ret;
-
-        case WINED3DFMT_R8G8B8X8_UNORM:
-        case WINED3DFMT_R8G8B8A8_UNORM:
-            ret  = a << 24;
-            ret |= b << 16;
-            ret |= g <<  8;
-            ret |= r <<  0;
-            TRACE("Returning %08x\n", ret);
-            return ret;
-
-        case WINED3DFMT_B10G10R10A2_UNORM:
-            a = (a *    4) / 256;
-            r = (r * 1024) / 256;
-            g = (g * 1024) / 256;
-            b = (b * 1024) / 256;
-            ret  = a << 30;
-            ret |= r << 20;
-            ret |= g << 10;
-            ret |= b <<  0;
-            TRACE("Returning %08x\n", ret);
-            return ret;
-
-        case WINED3DFMT_R10G10B10A2_UNORM:
-            a = (a *    4) / 256;
-            r = (r * 1024) / 256;
-            g = (g * 1024) / 256;
-            b = (b * 1024) / 256;
-            ret  = a << 30;
-            ret |= b << 20;
-            ret |= g << 10;
-            ret |= r <<  0;
-            TRACE("Returning %08x\n", ret);
-            return ret;
-
-        default:
-            FIXME("Add a COLORFILL conversion for format %s\n", debug_d3dformat(destfmt));
-            return 0;
-    }
 }
 
@@ -5528,5 +5527,5 @@
         memset(&BltFx, 0, sizeof(BltFx));
         BltFx.dwSize = sizeof(BltFx);
-        BltFx.u5.dwFillColor = argb_to_fmt(color, surface->resource.format_desc->format);
+        BltFx.u5.dwFillColor = color_convert_argb_to_fmt(color, surface->resource.format_desc->format);
         return IWineD3DSurface_Blt(pSurface, (const RECT *)pRect, NULL, NULL,
                 WINEDDBLT_COLORFILL, &BltFx, WINED3DTEXF_POINT);
@@ -5576,5 +5575,5 @@
         memset(&BltFx, 0, sizeof(BltFx));
         BltFx.dwSize = sizeof(BltFx);
-        BltFx.u5.dwFillColor = argb_to_fmt(c, ((IWineD3DSurfaceImpl *)surface)->resource.format_desc->format);
+        BltFx.u5.dwFillColor = color_convert_argb_to_fmt(c, ((IWineD3DSurfaceImpl *)surface)->resource.format_desc->format);
         hr = IWineD3DSurface_Blt(surface, NULL, NULL, NULL, WINEDDBLT_COLORFILL, &BltFx, WINED3DTEXF_POINT);
         if (FAILED(hr))
@@ -5607,99 +5606,95 @@
 
 static HRESULT WINAPI IWineD3DDeviceImpl_SetFrontBackBuffers(IWineD3DDevice *iface,
-        IWineD3DSurface *Front, IWineD3DSurface *Back)
-{
-    IWineD3DSurfaceImpl *FrontImpl = (IWineD3DSurfaceImpl *) Front;
-    IWineD3DSurfaceImpl *BackImpl = (IWineD3DSurfaceImpl *) Back;
-    IWineD3DSwapChainImpl *Swapchain;
+        IWineD3DSurface *front, IWineD3DSurface *back)
+{
+    IWineD3DSurfaceImpl *front_impl = (IWineD3DSurfaceImpl *)front;
+    IWineD3DSurfaceImpl *back_impl = (IWineD3DSurfaceImpl *)back;
+    IWineD3DSwapChainImpl *swapchain;
     HRESULT hr;
 
-    TRACE("iface %p, front %p, back %p.\n", iface, Front, Back);
-
-    hr = IWineD3DDevice_GetSwapChain(iface, 0, (IWineD3DSwapChain **) &Swapchain);
-    if(hr != WINED3D_OK) {
-        ERR("Can't get the swapchain\n");
+    TRACE("iface %p, front %p, back %p.\n", iface, front, back);
+
+    if (FAILED(hr = IWineD3DDevice_GetSwapChain(iface, 0, (IWineD3DSwapChain **)&swapchain)))
+    {
+        ERR("Failed to get the swapchain, hr %#x.\n", hr);
         return hr;
     }
 
-    /* Make sure to release the swapchain */
-    IWineD3DSwapChain_Release((IWineD3DSwapChain *) Swapchain);
-
-    if(FrontImpl && !(FrontImpl->resource.usage & WINED3DUSAGE_RENDERTARGET) ) {
-        ERR("Trying to set a front buffer which doesn't have WINED3DUSAGE_RENDERTARGET usage\n");
+    if (front_impl && !(front_impl->resource.usage & WINED3DUSAGE_RENDERTARGET))
+    {
+        ERR("Trying to set a front buffer which doesn't have WINED3DUSAGE_RENDERTARGET usage.\n");
+        IWineD3DSwapChain_Release((IWineD3DSwapChain *)swapchain);
         return WINED3DERR_INVALIDCALL;
     }
-    else if(BackImpl && !(BackImpl->resource.usage & WINED3DUSAGE_RENDERTARGET)) {
-        ERR("Trying to set a back buffer which doesn't have WINED3DUSAGE_RENDERTARGET usage\n");
-        return WINED3DERR_INVALIDCALL;
-    }
-
-    if(Swapchain->frontBuffer != Front) {
-        TRACE("Changing the front buffer from %p to %p\n", Swapchain->frontBuffer, Front);
-
-        if(Swapchain->frontBuffer)
+
+    if (back_impl)
+    {
+        if (!(back_impl->resource.usage & WINED3DUSAGE_RENDERTARGET))
         {
-            IWineD3DSurface_SetContainer(Swapchain->frontBuffer, NULL);
-            ((IWineD3DSurfaceImpl *)Swapchain->frontBuffer)->Flags &= ~SFLAG_SWAPCHAIN;
-        }
-        Swapchain->frontBuffer = Front;
-
-        if(Swapchain->frontBuffer) {
-            IWineD3DSurface_SetContainer(Swapchain->frontBuffer, (IWineD3DBase *) Swapchain);
-            ((IWineD3DSurfaceImpl *)Swapchain->frontBuffer)->Flags |= SFLAG_SWAPCHAIN;
-        }
-    }
-
-    if(Back && !Swapchain->backBuffer) {
-        /* We need memory for the back buffer array - only one back buffer this way */
-        Swapchain->backBuffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IWineD3DSurface *));
-        if(!Swapchain->backBuffer) {
-            ERR("Out of memory\n");
-            return E_OUTOFMEMORY;
-        }
-    }
-
-    if(Swapchain->backBuffer[0] != Back) {
-        TRACE("Changing the back buffer from %p to %p\n", Swapchain->backBuffer, Back);
-
-        /* What to do about the context here in the case of multithreading? Not sure.
-         * This function is called by IDirect3D7::CreateDevice so in theory its initialization code
-         */
-        WARN("No active context?\n");
-
-        ENTER_GL();
-        if(!Swapchain->backBuffer[0]) {
-            /* GL was told to draw to the front buffer at creation,
-             * undo that
-             */
-            glDrawBuffer(GL_BACK);
-            checkGLcall("glDrawBuffer(GL_BACK)");
-            /* Set the backbuffer count to 1 because other code uses it to fing the back buffers */
-            Swapchain->presentParms.BackBufferCount = 1;
-        } else if (!Back) {
-            /* That makes problems - disable for now */
-            /* glDrawBuffer(GL_FRONT); */
-            checkGLcall("glDrawBuffer(GL_FRONT)");
-            /* We have lost our back buffer, set this to 0 to avoid confusing other code */
-            Swapchain->presentParms.BackBufferCount = 0;
-        }
-        LEAVE_GL();
-
-        if(Swapchain->backBuffer[0])
+            ERR("Trying to set a back buffer which doesn't have WINED3DUSAGE_RENDERTARGET usage.\n");
+            IWineD3DSwapChain_Release((IWineD3DSwapChain *)swapchain);
+            return WINED3DERR_INVALIDCALL;
+        }
+
+        if (!swapchain->backBuffer)
         {
-            IWineD3DSurface_SetContainer(Swapchain->backBuffer[0], NULL);
-            ((IWineD3DSurfaceImpl *)Swapchain->backBuffer[0])->Flags &= ~SFLAG_SWAPCHAIN;
-        }
-        Swapchain->backBuffer[0] = Back;
-
-        if(Swapchain->backBuffer[0]) {
-            IWineD3DSurface_SetContainer(Swapchain->backBuffer[0], (IWineD3DBase *) Swapchain);
-            ((IWineD3DSurfaceImpl *)Swapchain->backBuffer[0])->Flags |= SFLAG_SWAPCHAIN;
-        } else {
-            HeapFree(GetProcessHeap(), 0, Swapchain->backBuffer);
-            Swapchain->backBuffer = NULL;
-        }
-
-    }
-
+            swapchain->backBuffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*swapchain->backBuffer));
+            if (!swapchain->backBuffer)
+            {
+                ERR("Failed to allocate back buffer array memory.\n");
+                IWineD3DSwapChain_Release((IWineD3DSwapChain *)swapchain);
+                return E_OUTOFMEMORY;
+            }
+        }
+    }
+
+    if (swapchain->frontBuffer != front)
+    {
+        TRACE("Changing the front buffer from %p to %p.\n", swapchain->frontBuffer, front);
+
+        if (swapchain->frontBuffer)
+        {
+            IWineD3DSurface_SetContainer(swapchain->frontBuffer, NULL);
+            ((IWineD3DSurfaceImpl *)swapchain->frontBuffer)->Flags &= ~SFLAG_SWAPCHAIN;
+        }
+        swapchain->frontBuffer = front;
+
+        if (front)
+        {
+            IWineD3DSurface_SetContainer(front, (IWineD3DBase *)swapchain);
+            front_impl->Flags |= SFLAG_SWAPCHAIN;
+        }
+    }
+
+    if (swapchain->backBuffer[0] != back)
+    {
+        TRACE("Changing the back buffer from %p to %p.\n", swapchain->backBuffer[0], back);
+
+        if (swapchain->backBuffer[0])
+        {
+            IWineD3DSurface_SetContainer(swapchain->backBuffer[0], NULL);
+            ((IWineD3DSurfaceImpl *)swapchain->backBuffer[0])->Flags &= ~SFLAG_SWAPCHAIN;
+        }
+        swapchain->backBuffer[0] = back;
+
+        if (back)
+        {
+            swapchain->presentParms.BackBufferWidth = back_impl->currentDesc.Width;
+            swapchain->presentParms.BackBufferHeight = back_impl->currentDesc.Height;
+            swapchain->presentParms.BackBufferFormat = back_impl->resource.format_desc->format;
+            swapchain->presentParms.BackBufferCount = 1;
+
+            IWineD3DSurface_SetContainer(back, (IWineD3DBase *)swapchain);
+            back_impl->Flags |= SFLAG_SWAPCHAIN;
+        }
+        else
+        {
+            swapchain->presentParms.BackBufferCount = 0;
+            HeapFree(GetProcessHeap(), 0, swapchain->backBuffer);
+            swapchain->backBuffer = NULL;
+        }
+    }
+
+    IWineD3DSwapChain_Release((IWineD3DSwapChain *)swapchain);
     return WINED3D_OK;
 }
@@ -5719,19 +5714,22 @@
 }
 
-void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED3DRECT *src_rect,
-        IWineD3DSurface *dst_surface, WINED3DRECT *dst_rect, const WINED3DTEXTUREFILTERTYPE filter, BOOL flip)
+void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, const RECT *src_rect_in,
+        IWineD3DSurface *dst_surface, const RECT *dst_rect_in, const WINED3DTEXTUREFILTERTYPE filter)
 {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
     GLbitfield mask = GL_COLOR_BUFFER_BIT; /* TODO: Support blitting depth/stencil surfaces */
-    IWineD3DSwapChain *src_swapchain, *dst_swapchain;
     const struct wined3d_gl_info *gl_info;
     struct wined3d_context *context;
     GLenum gl_filter;
     POINT offset = {0, 0};
-
-    TRACE("(%p) : src_surface %p, src_rect %p, dst_surface %p, dst_rect %p, filter %s (0x%08x), flip %u\n",
-            This, src_surface, src_rect, dst_surface, dst_rect, debug_d3dtexturefiltertype(filter), filter, flip);
-    TRACE("src_rect [%u, %u]->[%u, %u]\n", src_rect->x1, src_rect->y1, src_rect->x2, src_rect->y2);
-    TRACE("dst_rect [%u, %u]->[%u, %u]\n", dst_rect->x1, dst_rect->y1, dst_rect->x2, dst_rect->y2);
+    RECT src_rect, dst_rect;
+
+    TRACE("(%p) : src_surface %p, src_rect_in %p, dst_surface %p, dst_rect_in %p, filter %s (0x%08x)\n",
+            This, src_surface, src_rect_in, dst_surface, dst_rect_in, debug_d3dtexturefiltertype(filter), filter);
+    TRACE("src_rect_in %s\n", wine_dbgstr_rect(src_rect_in));
+    TRACE("dst_rect_in %s\n", wine_dbgstr_rect(dst_rect_in));
+
+    src_rect = *src_rect_in;
+    dst_rect = *dst_rect_in;
 
     switch (filter) {
@@ -5748,12 +5746,21 @@
     }
 
-    /* Attach src surface to src fbo */
-    src_swapchain = get_swapchain(src_surface);
-    dst_swapchain = get_swapchain(dst_surface);
-
-    if (src_swapchain) context = context_acquire(This, src_surface, CTXUSAGE_RESOURCELOAD);
-    else if (dst_swapchain) context = context_acquire(This, dst_surface, CTXUSAGE_RESOURCELOAD);
+    /* Make sure the drawables are up-to-date. Note that loading the
+     * destination surface isn't strictly required if we overwrite the
+     * entire surface. */
+    IWineD3DSurface_LoadLocation(src_surface, SFLAG_INDRAWABLE, NULL);
+    IWineD3DSurface_LoadLocation(dst_surface, SFLAG_INDRAWABLE, NULL);
+
+    if (!surface_is_offscreen(src_surface)) context = context_acquire(This, src_surface, CTXUSAGE_RESOURCELOAD);
+    else if (!surface_is_offscreen(dst_surface)) context = context_acquire(This, dst_surface, CTXUSAGE_RESOURCELOAD);
     else context = context_acquire(This, NULL, CTXUSAGE_RESOURCELOAD);
 
+    if (!context->valid)
+    {
+        context_release(context);
+        WARN("Invalid context, skipping blit.\n");
+        return;
+    }
+
     gl_info = context->gl_info;
 
@@ -5763,20 +5770,17 @@
 
         TRACE("Source surface %p is onscreen\n", src_surface);
-        /* Make sure the drawable is up to date. In the offscreen case
-         * attach_surface_fbo() implicitly takes care of this. */
-        IWineD3DSurface_LoadLocation(src_surface, SFLAG_INDRAWABLE, NULL);
 
         if(buffer == GL_FRONT) {
             RECT windowsize;
             UINT h;
-            ClientToScreen(((IWineD3DSwapChainImpl *)src_swapchain)->win_handle, &offset);
-            GetClientRect(((IWineD3DSwapChainImpl *)src_swapchain)->win_handle, &windowsize);
+            ClientToScreen(context->win_handle, &offset);
+            GetClientRect(context->win_handle, &windowsize);
             h = windowsize.bottom - windowsize.top;
-            src_rect->x1 -= offset.x; src_rect->x2 -=offset.x;
-            src_rect->y1 =  offset.y + h - src_rect->y1;
-            src_rect->y2 =  offset.y + h - src_rect->y2;
+            src_rect.left -= offset.x; src_rect.right -=offset.x;
+            src_rect.top =  offset.y + h - src_rect.top;
+            src_rect.bottom =  offset.y + h - src_rect.bottom;
         } else {
-            src_rect->y1 = ((IWineD3DSurfaceImpl *)src_surface)->currentDesc.Height - src_rect->y1;
-            src_rect->y2 = ((IWineD3DSurfaceImpl *)src_surface)->currentDesc.Height - src_rect->y2;
+            src_rect.top = ((IWineD3DSurfaceImpl *)src_surface)->currentDesc.Height - src_rect.top;
+            src_rect.bottom = ((IWineD3DSurfaceImpl *)src_surface)->currentDesc.Height - src_rect.bottom;
         }
 
@@ -5789,5 +5793,5 @@
         ENTER_GL();
         context_bind_fbo(context, GL_READ_FRAMEBUFFER, &context->src_fbo);
-        context_attach_surface_fbo(context, GL_READ_FRAMEBUFFER, 0, src_surface);
+        context_attach_surface_fbo(context, GL_READ_FRAMEBUFFER, 0, (IWineD3DSurfaceImpl *)src_surface);
         glReadBuffer(GL_COLOR_ATTACHMENT0);
         checkGLcall("glReadBuffer()");
@@ -5802,21 +5806,18 @@
 
         TRACE("Destination surface %p is onscreen\n", dst_surface);
-        /* Make sure the drawable is up to date. In the offscreen case
-         * attach_surface_fbo() implicitly takes care of this. */
-        IWineD3DSurface_LoadLocation(dst_surface, SFLAG_INDRAWABLE, NULL);
 
         if(buffer == GL_FRONT) {
             RECT windowsize;
             UINT h;
-            ClientToScreen(((IWineD3DSwapChainImpl *)dst_swapchain)->win_handle, &offset);
-            GetClientRect(((IWineD3DSwapChainImpl *)dst_swapchain)->win_handle, &windowsize);
+            ClientToScreen(context->win_handle, &offset);
+            GetClientRect(context->win_handle, &windowsize);
             h = windowsize.bottom - windowsize.top;
-            dst_rect->x1 -= offset.x; dst_rect->x2 -=offset.x;
-            dst_rect->y1 =  offset.y + h - dst_rect->y1;
-            dst_rect->y2 =  offset.y + h - dst_rect->y2;
+            dst_rect.left -= offset.x; dst_rect.right -=offset.x;
+            dst_rect.top =  offset.y + h - dst_rect.top;
+            dst_rect.bottom =  offset.y + h - dst_rect.bottom;
         } else {
             /* Screen coords = window coords, surface height = window height */
-            dst_rect->y1 = ((IWineD3DSurfaceImpl *)dst_surface)->currentDesc.Height - dst_rect->y1;
-            dst_rect->y2 = ((IWineD3DSurfaceImpl *)dst_surface)->currentDesc.Height - dst_rect->y2;
+            dst_rect.top = ((IWineD3DSurfaceImpl *)dst_surface)->currentDesc.Height - dst_rect.top;
+            dst_rect.bottom = ((IWineD3DSurfaceImpl *)dst_surface)->currentDesc.Height - dst_rect.bottom;
         }
 
@@ -5831,5 +5832,5 @@
         ENTER_GL();
         context_bind_fbo(context, GL_DRAW_FRAMEBUFFER, &context->dst_fbo);
-        context_attach_surface_fbo(context, GL_DRAW_FRAMEBUFFER, 0, dst_surface);
+        context_attach_surface_fbo(context, GL_DRAW_FRAMEBUFFER, 0, (IWineD3DSurfaceImpl *)dst_surface);
         context_set_draw_buffer(context, GL_COLOR_ATTACHMENT0);
         context_attach_depth_stencil_fbo(context, GL_DRAW_FRAMEBUFFER, NULL, FALSE);
@@ -5838,15 +5839,12 @@
     IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_SCISSORTESTENABLE));
 
-    if (flip) {
-        gl_info->fbo_ops.glBlitFramebuffer(src_rect->x1, src_rect->y1, src_rect->x2, src_rect->y2,
-                dst_rect->x1, dst_rect->y2, dst_rect->x2, dst_rect->y1, mask, gl_filter);
-        checkGLcall("glBlitFramebuffer()");
-    } else {
-        gl_info->fbo_ops.glBlitFramebuffer(src_rect->x1, src_rect->y1, src_rect->x2, src_rect->y2,
-                dst_rect->x1, dst_rect->y1, dst_rect->x2, dst_rect->y2, mask, gl_filter);
-        checkGLcall("glBlitFramebuffer()");
-    }
+    gl_info->fbo_ops.glBlitFramebuffer(src_rect.left, src_rect.top, src_rect.right, src_rect.bottom,
+            dst_rect.left, dst_rect.top, dst_rect.right, dst_rect.bottom, mask, gl_filter);
+    checkGLcall("glBlitFramebuffer()");
 
     LEAVE_GL();
+
+    if (wined3d_settings.strict_draw_ordering) wglFlush(); /* Flush to ensure ordering across contexts. */
+
     context_release(context);
 
@@ -6014,13 +6012,13 @@
             {
                 const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
-                const struct GlPixelFormatDesc *glDesc = getFormatDescEntry(WINED3DFMT_B8G8R8A8_UNORM, gl_info);
+                const struct wined3d_format_desc *format_desc = getFormatDescEntry(WINED3DFMT_B8G8R8A8_UNORM, gl_info);
                 struct wined3d_context *context;
                 char *mem, *bits = rect.pBits;
-                GLint intfmt = glDesc->glInternal;
-                GLint format = glDesc->glFormat;
-                GLint type = glDesc->glType;
+                GLint intfmt = format_desc->glInternal;
+                GLint format = format_desc->glFormat;
+                GLint type = format_desc->glType;
                 INT height = This->cursorHeight;
                 INT width = This->cursorWidth;
-                INT bpp = glDesc->byte_count;
+                INT bpp = format_desc->byte_count;
                 DWORD sampler;
                 INT i;
@@ -6207,8 +6205,4 @@
         while (surface->pow2Height < pPresentationParameters->BackBufferHeight) surface->pow2Height <<= 1;
     }
-    surface->glRect.left = 0;
-    surface->glRect.top = 0;
-    surface->glRect.right = surface->pow2Width;
-    surface->glRect.bottom = surface->pow2Height;
 
     if (surface->texture_name)
@@ -6276,7 +6270,7 @@
 }
 
-void delete_opengl_contexts(IWineD3DDevice *iface, IWineD3DSwapChain *swapchain_iface) {
+static void delete_opengl_contexts(IWineD3DDevice *iface, IWineD3DSwapChainImpl *swapchain)
+{
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
-    IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *) swapchain_iface;
     const struct wined3d_gl_info *gl_info;
     struct wined3d_context *context;
@@ -6320,7 +6314,7 @@
 }
 
-HRESULT create_primary_opengl_context(IWineD3DDevice *iface, IWineD3DSwapChain *swapchain_iface) {
+static HRESULT create_primary_opengl_context(IWineD3DDevice *iface, IWineD3DSwapChainImpl *swapchain)
+{
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
-    IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *) swapchain_iface;
     struct wined3d_context *context;
     HRESULT hr;
@@ -6336,6 +6330,5 @@
 
     target = (IWineD3DSurfaceImpl *)(swapchain->backBuffer ? swapchain->backBuffer[0] : swapchain->frontBuffer);
-    context = context_create(This, target, swapchain->win_handle, FALSE, &swapchain->presentParms);
-    if (!context)
+    if (!(context = context_create(swapchain, target, swapchain->ds_format)))
     {
         WARN("Failed to create context.\n");
@@ -6480,5 +6473,5 @@
     IWineD3DStateBlock_Release((IWineD3DStateBlock *)This->stateBlock);
 
-    delete_opengl_contexts(iface, (IWineD3DSwapChain *) swapchain);
+    delete_opengl_contexts(iface, swapchain);
 
     if(pPresentationParameters->Windowed) {
@@ -6532,11 +6525,11 @@
     }
 
-    if((pPresentationParameters->Windowed && !swapchain->presentParms.Windowed) ||
-       (swapchain->presentParms.Windowed && !pPresentationParameters->Windowed) ||
-        DisplayModeChanged) {
-
+    if (!pPresentationParameters->Windowed != !swapchain->presentParms.Windowed
+            || DisplayModeChanged)
+    {
         IWineD3DDevice_SetDisplayMode(iface, 0, &mode);
 
-        if(swapchain->win_handle && !pPresentationParameters->Windowed) {
+        if (!pPresentationParameters->Windowed)
+        {
             if(swapchain->presentParms.Windowed) {
                 /* switch from windowed to fs */
@@ -6545,9 +6538,11 @@
             } else {
                 /* Fullscreen -> fullscreen mode change */
-                MoveWindow(swapchain->win_handle, 0, 0,
+                MoveWindow(swapchain->device_window, 0, 0,
                            pPresentationParameters->BackBufferWidth, pPresentationParameters->BackBufferHeight,
                            TRUE);
             }
-        } else if(swapchain->win_handle && !swapchain->presentParms.Windowed) {
+        }
+        else if (!swapchain->presentParms.Windowed)
+        {
             /* Fullscreen -> windowed switch */
             swapchain_restore_fullscreen_window(swapchain);
@@ -6606,5 +6601,5 @@
     }
 
-    hr = create_primary_opengl_context(iface, (IWineD3DSwapChain *) swapchain);
+    hr = create_primary_opengl_context(iface, swapchain);
     IWineD3DSwapChain_Release((IWineD3DSwapChain *) swapchain);
 
@@ -6792,4 +6787,26 @@
     }
     return WINED3D_OK;
+}
+
+static HRESULT WINAPI IWineD3DDeviceImpl_GetSurfaceFromDC(IWineD3DDevice *iface, HDC dc, IWineD3DSurface **surface)
+{
+    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
+    IWineD3DResourceImpl *resource;
+
+    LIST_FOR_EACH_ENTRY(resource, &This->resources, IWineD3DResourceImpl, resource.resource_list_entry)
+    {
+        WINED3DRESOURCETYPE type = IWineD3DResource_GetType((IWineD3DResource *)resource);
+        if (type == WINED3DRTYPE_SURFACE)
+        {
+            if (((IWineD3DSurfaceImpl *)resource)->hDC == dc)
+            {
+                TRACE("Found surface %p for dc %p.\n", resource, dc);
+                *surface = (IWineD3DSurface *)resource;
+                return WINED3D_OK;
+            }
+        }
+    }
+
+    return WINED3DERR_INVALIDCALL;
 }
 
@@ -6942,5 +6959,8 @@
     IWineD3DDeviceImpl_GetFrontBufferData,
     /*** object tracking ***/
-    IWineD3DDeviceImpl_EnumResources
+    IWineD3DDeviceImpl_EnumResources,
+    IWineD3DDeviceImpl_GetSurfaceFromDC,
+    IWineD3DDeviceImpl_AcquireFocusWindow,
+    IWineD3DDeviceImpl_ReleaseFocusWindow,
 };
 
@@ -6992,8 +7012,8 @@
 
     select_shader_mode(&adapter->gl_info, &device->ps_selected_mode, &device->vs_selected_mode);
-    device->shader_backend = select_shader_backend(adapter, device_type);
+    device->shader_backend = adapter->shader_backend;
 
     memset(&shader_caps, 0, sizeof(shader_caps));
-    device->shader_backend->shader_get_caps(device_type, &adapter->gl_info, &shader_caps);
+    device->shader_backend->shader_get_caps(&adapter->gl_info, &shader_caps);
     device->d3d_vshader_constantF = shader_caps.MaxVertexShaderConst;
     device->d3d_pshader_constantF = shader_caps.MaxPixelShaderConst;
@@ -7001,9 +7021,8 @@
 
     memset(&ffp_caps, 0, sizeof(ffp_caps));
-    fragment_pipeline = select_fragment_implementation(adapter, device_type);
+    fragment_pipeline = adapter->fragment_pipe;
     device->frag_pipe = fragment_pipeline;
-    fragment_pipeline->get_caps(device_type, &adapter->gl_info, &ffp_caps);
+    fragment_pipeline->get_caps(&adapter->gl_info, &ffp_caps);
     device->max_ffp_textures = ffp_caps.MaxSimultaneousTextures;
-    device->max_ffp_texture_stages = ffp_caps.MaxTextureBlendStages;
 
     hr = compile_state_table(device->StateTable, device->multistate_funcs, &adapter->gl_info,
@@ -7016,5 +7035,5 @@
     }
 
-    device->blitter = select_blit_implementation(adapter, device_type);
+    device->blitter = adapter->blitter;
 
     return WINED3D_OK;
@@ -7040,12 +7059,4 @@
 }
 
-void get_drawable_size_pbuffer(struct wined3d_context *context, UINT *width, UINT *height)
-{
-    IWineD3DDeviceImpl *device = ((IWineD3DSurfaceImpl *)context->current_rt)->resource.device;
-    /* The drawable size of a pbuffer render target is the current pbuffer size. */
-    *width = device->pbufferWidth;
-    *height = device->pbufferHeight;
-}
-
 void get_drawable_size_fbo(struct wined3d_context *context, UINT *width, UINT *height)
 {
@@ -7058,11 +7069,10 @@
 void get_drawable_size_backbuffer(struct wined3d_context *context, UINT *width, UINT *height)
 {
-    IWineD3DSurfaceImpl *surface = (IWineD3DSurfaceImpl *)context->surface;
+    IWineD3DSwapChainImpl *swapchain = context->swapchain;
     /* The drawable size of a backbuffer / aux buffer offscreen target is the size of the
      * current context's drawable, which is the size of the back buffer of the swapchain
-     * the active context belongs to. The back buffer of the swapchain is stored as the
-     * surface the context belongs to. */
-    *width = surface->currentDesc.Width;
-    *height = surface->currentDesc.Height;
+     * the active context belongs to. */
+    *width = swapchain->presentParms.BackBufferWidth;
+    *height = swapchain->presentParms.BackBufferHeight;
 }
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/directx.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/directx.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/directx.c	(revision 28475)
@@ -34,4 +34,5 @@
 
 #include "config.h"
+#include <stdio.h>
 #include "wined3d_private.h"
 
@@ -40,4 +41,5 @@
 
 #define GLINFO_LOCATION (*gl_info)
+#define WINE_DEFAULT_VIDMEM (64 * 1024 * 1024)
 
 /* The d3d device ID */
@@ -53,15 +55,8 @@
     {"GL_APPLE_client_storage",             APPLE_CLIENT_STORAGE,           0                           },
     {"GL_APPLE_fence",                      APPLE_FENCE,                    0                           },
+    {"GL_APPLE_float_pixels",               APPLE_FLOAT_PIXELS,             0                           },
+    {"GL_APPLE_flush_buffer_range",         APPLE_FLUSH_BUFFER_RANGE,       0                           },
     {"GL_APPLE_flush_render",               APPLE_FLUSH_RENDER,             0                           },
     {"GL_APPLE_ycbcr_422",                  APPLE_YCBCR_422,                0                           },
-    {"GL_APPLE_float_pixels",               APPLE_FLOAT_PIXELS,             0                           },
-    {"GL_APPLE_flush_buffer_range",         APPLE_FLUSH_BUFFER_RANGE,       0                           },
-
-    /* ATI */
-    {"GL_ATI_separate_stencil",             ATI_SEPARATE_STENCIL,           0                           },
-    {"GL_ATI_texture_env_combine3",         ATI_TEXTURE_ENV_COMBINE3,       0                           },
-    {"GL_ATI_texture_mirror_once",          ATI_TEXTURE_MIRROR_ONCE,        0                           },
-    {"GL_ATI_fragment_shader",              ATI_FRAGMENT_SHADER,            0                           },
-    {"GL_ATI_texture_compression_3dc",      ATI_TEXTURE_COMPRESSION_3DC,    0                           },
 
     /* ARB */
@@ -76,5 +71,7 @@
     {"GL_ARB_geometry_shader4",             ARB_GEOMETRY_SHADER4,           0                           },
     {"GL_ARB_half_float_pixel",             ARB_HALF_FLOAT_PIXEL,           0                           },
+    {"GL_ARB_half_float_vertex",            ARB_HALF_FLOAT_VERTEX,          0                           },
     {"GL_ARB_imaging",                      ARB_IMAGING,                    0                           },
+    {"GL_ARB_map_buffer_range",             ARB_MAP_BUFFER_RANGE,           0                           },
     {"GL_ARB_multisample",                  ARB_MULTISAMPLE,                0                           }, /* needs GLX_ARB_MULTISAMPLE as well */
     {"GL_ARB_multitexture",                 ARB_MULTITEXTURE,               0                           },
@@ -84,4 +81,8 @@
     {"GL_ARB_point_sprite",                 ARB_POINT_SPRITE,               0                           },
     {"GL_ARB_provoking_vertex",             ARB_PROVOKING_VERTEX,           0                           },
+    {"GL_ARB_shader_objects",               ARB_SHADER_OBJECTS,             0                           },
+    {"GL_ARB_shader_texture_lod",           ARB_SHADER_TEXTURE_LOD,         0                           },
+    {"GL_ARB_shading_language_100",         ARB_SHADING_LANGUAGE_100,       0                           },
+    {"GL_ARB_sync",                         ARB_SYNC,                       0                           },
     {"GL_ARB_texture_border_clamp",         ARB_TEXTURE_BORDER_CLAMP,       0                           },
     {"GL_ARB_texture_compression",          ARB_TEXTURE_COMPRESSION,        0                           },
@@ -95,21 +96,29 @@
     {"GL_ARB_texture_rectangle",            ARB_TEXTURE_RECTANGLE,          0                           },
     {"GL_ARB_texture_rg",                   ARB_TEXTURE_RG,                 0                           },
+    {"GL_ARB_vertex_array_bgra",            ARB_VERTEX_ARRAY_BGRA,          0                           },
     {"GL_ARB_vertex_blend",                 ARB_VERTEX_BLEND,               0                           },
     {"GL_ARB_vertex_buffer_object",         ARB_VERTEX_BUFFER_OBJECT,       0                           },
     {"GL_ARB_vertex_program",               ARB_VERTEX_PROGRAM,             0                           },
     {"GL_ARB_vertex_shader",                ARB_VERTEX_SHADER,              0                           },
-    {"GL_ARB_shader_objects",               ARB_SHADER_OBJECTS,             0                           },
-    {"GL_ARB_shader_texture_lod",           ARB_SHADER_TEXTURE_LOD,         0                           },
-    {"GL_ARB_half_float_vertex",            ARB_HALF_FLOAT_VERTEX,          0                           },
+
+    /* ATI */
+    {"GL_ATI_fragment_shader",              ATI_FRAGMENT_SHADER,            0                           },
+    {"GL_ATI_separate_stencil",             ATI_SEPARATE_STENCIL,           0                           },
+    {"GL_ATI_texture_compression_3dc",      ATI_TEXTURE_COMPRESSION_3DC,    0                           },
+    {"GL_ATI_texture_env_combine3",         ATI_TEXTURE_ENV_COMBINE3,       0                           },
+    {"GL_ATI_texture_mirror_once",          ATI_TEXTURE_MIRROR_ONCE,        0                           },
 
     /* EXT */
     {"GL_EXT_blend_color",                  EXT_BLEND_COLOR,                0                           },
-    {"GL_EXT_blend_minmax",                 EXT_BLEND_MINMAX,               0                           },
     {"GL_EXT_blend_equation_separate",      EXT_BLEND_EQUATION_SEPARATE,    0                           },
     {"GL_EXT_blend_func_separate",          EXT_BLEND_FUNC_SEPARATE,        0                           },
+    {"GL_EXT_blend_minmax",                 EXT_BLEND_MINMAX,               0                           },
+    {"GL_EXT_draw_buffers2",                EXT_DRAW_BUFFERS2,              0                           },
     {"GL_EXT_fog_coord",                    EXT_FOG_COORD,                  0                           },
     {"GL_EXT_framebuffer_blit",             EXT_FRAMEBUFFER_BLIT,           0                           },
     {"GL_EXT_framebuffer_multisample",      EXT_FRAMEBUFFER_MULTISAMPLE,    0                           },
     {"GL_EXT_framebuffer_object",           EXT_FRAMEBUFFER_OBJECT,         0                           },
+    {"GL_EXT_gpu_program_parameters",       EXT_GPU_PROGRAM_PARAMETERS,     0                           },
+    {"GL_EXT_gpu_shader4",                  EXT_GPU_SHADER4,                0                           },
     {"GL_EXT_packed_depth_stencil",         EXT_PACKED_DEPTH_STENCIL,       0                           },
     {"GL_EXT_paletted_texture",             EXT_PALETTED_TEXTURE,           0                           },
@@ -120,24 +129,23 @@
     {"GL_EXT_stencil_wrap",                 EXT_STENCIL_WRAP,               0                           },
     {"GL_EXT_texture3D",                    EXT_TEXTURE3D,                  MAKEDWORD_VERSION(1, 2)     },
+    {"GL_EXT_texture_compression_rgtc",     EXT_TEXTURE_COMPRESSION_RGTC,   0                           },
     {"GL_EXT_texture_compression_s3tc",     EXT_TEXTURE_COMPRESSION_S3TC,   0                           },
-    {"GL_EXT_texture_compression_rgtc",     EXT_TEXTURE_COMPRESSION_RGTC,   0                           },
     {"GL_EXT_texture_env_add",              EXT_TEXTURE_ENV_ADD,            0                           },
     {"GL_EXT_texture_env_combine",          EXT_TEXTURE_ENV_COMBINE,        0                           },
     {"GL_EXT_texture_env_dot3",             EXT_TEXTURE_ENV_DOT3,           0                           },
+    {"GL_EXT_texture_filter_anisotropic",   EXT_TEXTURE_FILTER_ANISOTROPIC, 0                           },
+    {"GL_EXT_texture_lod_bias",             EXT_TEXTURE_LOD_BIAS,           0                           },
     {"GL_EXT_texture_sRGB",                 EXT_TEXTURE_SRGB,               0                           },
-    {"GL_EXT_texture_swizzle",              EXT_TEXTURE_SWIZZLE,            0                           },
-    {"GL_EXT_texture_filter_anisotropic",   EXT_TEXTURE_FILTER_ANISOTROPIC, 0                           },
-    {"GL_EXT_texture_lod",                  EXT_TEXTURE_LOD,                0                           },
-    {"GL_EXT_texture_lod_bias",             EXT_TEXTURE_LOD_BIAS,           0                           },
     {"GL_EXT_vertex_array_bgra",            EXT_VERTEX_ARRAY_BGRA,          0                           },
-    {"GL_EXT_vertex_shader",                EXT_VERTEX_SHADER,              0                           },
-    {"GL_EXT_gpu_program_parameters",       EXT_GPU_PROGRAM_PARAMETERS,     0                           },
 
     /* NV */
-    {"GL_NV_half_float",                    NV_HALF_FLOAT,                  0                           },
+    {"GL_NV_depth_clamp",                   NV_DEPTH_CLAMP,                 0                           },
     {"GL_NV_fence",                         NV_FENCE,                       0                           },
     {"GL_NV_fog_distance",                  NV_FOG_DISTANCE,                0                           },
     {"GL_NV_fragment_program",              NV_FRAGMENT_PROGRAM,            0                           },
     {"GL_NV_fragment_program2",             NV_FRAGMENT_PROGRAM2,           0                           },
+    {"GL_NV_fragment_program_option",       NV_FRAGMENT_PROGRAM_OPTION,     0                           },
+    {"GL_NV_half_float",                    NV_HALF_FLOAT,                  0                           },
+    {"GL_NV_light_max_exponent",            NV_LIGHT_MAX_EXPONENT,          0                           },
     {"GL_NV_register_combiners",            NV_REGISTER_COMBINERS,          0                           },
     {"GL_NV_register_combiners2",           NV_REGISTER_COMBINERS2,         0                           },
@@ -146,6 +154,4 @@
     {"GL_NV_texture_shader",                NV_TEXTURE_SHADER,              0                           },
     {"GL_NV_texture_shader2",               NV_TEXTURE_SHADER2,             0                           },
-    {"GL_NV_texture_shader3",               NV_TEXTURE_SHADER3,             0                           },
-    {"GL_NV_occlusion_query",               NV_OCCLUSION_QUERY,             0                           },
     {"GL_NV_vertex_program",                NV_VERTEX_PROGRAM,              0                           },
     {"GL_NV_vertex_program1_1",             NV_VERTEX_PROGRAM1_1,           0                           },
@@ -153,7 +159,4 @@
     {"GL_NV_vertex_program2_option",        NV_VERTEX_PROGRAM2_OPTION,      0                           },
     {"GL_NV_vertex_program3",               NV_VERTEX_PROGRAM3,             0                           },
-    {"GL_NV_fragment_program_option",       NV_FRAGMENT_PROGRAM_OPTION,     0                           },
-    {"GL_NV_depth_clamp",                   NV_DEPTH_CLAMP,                 0                           },
-    {"GL_NV_light_max_exponent",            NV_LIGHT_MAX_EXPONENT,          0                           },
 
     /* SGI */
@@ -445,7 +448,7 @@
 
 static BOOL match_ati_r300_to_500(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
-        enum wined3d_pci_vendor vendor, enum wined3d_pci_device device)
-{
-    if (vendor != VENDOR_ATI) return FALSE;
+        enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
+{
+    if (card_vendor != HW_VENDOR_ATI) return FALSE;
     if (device == CARD_ATI_RADEON_9500) return TRUE;
     if (device == CARD_ATI_RADEON_X700) return TRUE;
@@ -455,7 +458,7 @@
 
 static BOOL match_geforce5(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
-        enum wined3d_pci_vendor vendor, enum wined3d_pci_device device)
-{
-    if (vendor == VENDOR_NVIDIA)
+        enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
+{
+    if (card_vendor == HW_VENDOR_NVIDIA)
     {
         if (device == CARD_NVIDIA_GEFORCEFX_5800 || device == CARD_NVIDIA_GEFORCEFX_5600)
@@ -468,5 +471,5 @@
 
 static BOOL match_apple(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
-        enum wined3d_pci_vendor vendor, enum wined3d_pci_device device)
+        enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
 {
     /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
@@ -480,16 +483,13 @@
      * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
      * the chance that other implementations support them is rather small since Win32 QuickTime uses
-     * DirectDraw, not OpenGL. */
-    if (gl_info->supported[APPLE_FENCE]
-            && gl_info->supported[APPLE_CLIENT_STORAGE]
-            && gl_info->supported[APPLE_FLUSH_RENDER]
-            && gl_info->supported[APPLE_YCBCR_422])
+     * DirectDraw, not OpenGL.
+     *
+     * This test has been moved into wined3d_guess_gl_vendor()
+     */
+    if (gl_vendor == GL_VENDOR_APPLE)
     {
         return TRUE;
     }
-    else
-    {
-        return FALSE;
-    }
+    return FALSE;
 }
 
@@ -564,14 +564,14 @@
 
 static BOOL match_apple_intel(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
-        enum wined3d_pci_vendor vendor, enum wined3d_pci_device device)
-{
-    return vendor == VENDOR_INTEL && match_apple(gl_info, gl_renderer, vendor, device);
+        enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
+{
+    return (card_vendor == HW_VENDOR_INTEL) && (gl_vendor == GL_VENDOR_APPLE);
 }
 
 static BOOL match_apple_nonr500ati(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
-        enum wined3d_pci_vendor vendor, enum wined3d_pci_device device)
-{
-    if (!match_apple(gl_info, gl_renderer, vendor, device)) return FALSE;
-    if (vendor != VENDOR_ATI) return FALSE;
+        enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
+{
+    if (gl_vendor != GL_VENDOR_APPLE) return FALSE;
+    if (card_vendor != HW_VENDOR_ATI) return FALSE;
     if (device == CARD_ATI_RADEON_X1600) return FALSE;
     return TRUE;
@@ -579,14 +579,12 @@
 
 static BOOL match_fglrx(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
-        enum wined3d_pci_vendor vendor, enum wined3d_pci_device device)
-{
-    if (vendor != VENDOR_ATI) return FALSE;
-    if (match_apple(gl_info, gl_renderer, vendor, device)) return FALSE;
-    if (strstr(gl_renderer, "DRI")) return FALSE; /* Filter out Mesa DRI drivers. */
-    return TRUE;
+        enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
+{
+    return gl_vendor == GL_VENDOR_FGLRX;
+
 }
 
 static BOOL match_dx10_capable(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
-        enum wined3d_pci_vendor vendor, enum wined3d_pci_device device)
+        enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
 {
     /* DX9 cards support 40 single float varyings in hardware, most drivers report 32. ATI misreports
@@ -602,5 +600,5 @@
 /* A GL context is provided by the caller */
 static BOOL match_allows_spec_alpha(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
-        enum wined3d_pci_vendor vendor, enum wined3d_pci_device device)
+        enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
 {
     GLenum error;
@@ -629,7 +627,7 @@
 
 static BOOL match_apple_nvts(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
-        enum wined3d_pci_vendor vendor, enum wined3d_pci_device device)
-{
-    if (!match_apple(gl_info, gl_renderer, vendor, device)) return FALSE;
+        enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
+{
+    if (!match_apple(gl_info, gl_renderer, gl_vendor, card_vendor, device)) return FALSE;
     return gl_info->supported[NV_TEXTURE_SHADER];
 }
@@ -637,5 +635,5 @@
 /* A GL context is provided by the caller */
 static BOOL match_broken_nv_clip(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
-        enum wined3d_pci_vendor vendor, enum wined3d_pci_device device)
+        enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
 {
     GLuint prog;
@@ -680,4 +678,59 @@
     LEAVE_GL();
     return ret;
+}
+
+/* Context activation is done by the caller. */
+static BOOL match_fbo_tex_update(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
+        enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
+{
+    char data[4 * 4 * 4];
+    GLuint tex, fbo;
+    GLenum status;
+
+    if (wined3d_settings.offscreen_rendering_mode != ORM_FBO) return FALSE;
+
+    memset(data, 0xcc, sizeof(data));
+
+    ENTER_GL();
+
+    glGenTextures(1, &tex);
+    glBindTexture(GL_TEXTURE_2D, tex);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 4, 4, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
+    checkGLcall("glTexImage2D");
+
+    gl_info->fbo_ops.glGenFramebuffers(1, &fbo);
+    gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
+    gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);
+    checkGLcall("glFramebufferTexture2D");
+
+    status = gl_info->fbo_ops.glCheckFramebufferStatus(GL_FRAMEBUFFER);
+    if (status != GL_FRAMEBUFFER_COMPLETE) ERR("FBO status %#x\n", status);
+    checkGLcall("glCheckFramebufferStatus");
+
+    memset(data, 0x11, sizeof(data));
+    glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
+    checkGLcall("glTexSubImage2D");
+
+    glClearColor(0.996, 0.729, 0.745, 0.792);
+    glClear(GL_COLOR_BUFFER_BIT);
+    checkGLcall("glClear");
+
+    glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
+    checkGLcall("glGetTexImage");
+
+    gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
+    gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, 0);
+    glBindTexture(GL_TEXTURE_2D, 0);
+    checkGLcall("glBindTexture");
+
+    gl_info->fbo_ops.glDeleteFramebuffers(1, &fbo);
+    glDeleteTextures(1, &tex);
+    checkGLcall("glDeleteTextures");
+
+    LEAVE_GL();
+
+    return *(DWORD *)data == 0x11111111;
 }
 
@@ -803,5 +856,4 @@
     gl_info->supported[NV_TEXTURE_SHADER] = FALSE;
     gl_info->supported[NV_TEXTURE_SHADER2] = FALSE;
-    gl_info->supported[NV_TEXTURE_SHADER3] = FALSE;
 }
 
@@ -811,8 +863,13 @@
 }
 
+static void quirk_fbo_tex_update(struct wined3d_gl_info *gl_info)
+{
+    gl_info->quirks |= WINED3D_QUIRK_FBO_TEX_UPDATE;
+}
+
 struct driver_quirk
 {
     BOOL (*match)(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
-            enum wined3d_pci_vendor vendor, enum wined3d_pci_device device);
+            enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device);
     void (*apply)(struct wined3d_gl_info *gl_info);
     const char *description;
@@ -889,4 +946,9 @@
         quirk_disable_nvvp_clip,
         "Apple NV_vertex_program clip bug quirk"
+    },
+    {
+        match_fbo_tex_update,
+        quirk_fbo_tex_update,
+        "FBO rebind for attachment updates"
     },
 };
@@ -933,49 +995,49 @@
      *
      * All version numbers used below are from the Linux nvidia drivers. */
-    {VENDOR_NVIDIA,     CARD_NVIDIA_RIVA_TNT,           "NVIDIA RIVA TNT",                  1,  8,  6      },
-    {VENDOR_NVIDIA,     CARD_NVIDIA_RIVA_TNT2,          "NVIDIA RIVA TNT2/TNT2 Pro",        1,  8,  6      },
-    {VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE,            "NVIDIA GeForce 256",               1,  8,  6      },
-    {VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE2_MX,        "NVIDIA GeForce2 MX/MX 400",        6,  4,  3      },
-    {VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE2,           "NVIDIA GeForce2 GTS/GeForce2 Pro", 1,  8,  6      },
-    {VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE3,           "NVIDIA GeForce3",                  6,  10, 9371   },
-    {VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE4_MX,        "NVIDIA GeForce4 MX 460",           6,  10, 9371   },
-    {VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE4_TI4200,    "NVIDIA GeForce4 Ti 4200",          6,  10, 9371   },
-    {VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCEFX_5200,     "NVIDIA GeForce FX 5200",           15, 11, 7516   },
-    {VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCEFX_5600,     "NVIDIA GeForce FX 5600",           15, 11, 7516   },
-    {VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCEFX_5800,     "NVIDIA GeForce FX 5800",           15, 11, 7516   },
-    {VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_6200,       "NVIDIA GeForce 6200",              15, 11, 8618   },
-    {VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_6600GT,     "NVIDIA GeForce 6600 GT",           15, 11, 8618   },
-    {VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_6800,       "NVIDIA GeForce 6800",              15, 11, 8618   },
-    {VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_7300,       "NVIDIA GeForce Go 7300",           15, 11, 8585   },
-    {VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_7400,       "NVIDIA GeForce Go 7400",           15, 11, 8585   },
-    {VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_7600,       "NVIDIA GeForce 7600 GT",           15, 11, 8618   },
-    {VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_7800GT,     "NVIDIA GeForce 7800 GT",           15, 11, 8618   },
-    {VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_8300GS,     "NVIDIA GeForce 8300 GS",           15, 11, 8618   },
-    {VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_8600GT,     "NVIDIA GeForce 8600 GT",           15, 11, 8618   },
-    {VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_8600MGT,    "NVIDIA GeForce 8600M GT",          15, 11, 8585   },
-    {VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_8800GTS,    "NVIDIA GeForce 8800 GTS",          15, 11, 8618   },
-    {VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_9200,       "NVIDIA GeForce 9200",              15, 11, 8618   },
-    {VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_9400GT,     "NVIDIA GeForce 9400 GT",           15, 11, 8618   },
-    {VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_9500GT,     "NVIDIA GeForce 9500 GT",           15, 11, 8618   },
-    {VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_9600GT,     "NVIDIA GeForce 9600 GT",           15, 11, 8618   },
-    {VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_9800GT,     "NVIDIA GeForce 9800 GT",           15, 11, 8618   },
-    {VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_GTX260,     "NVIDIA GeForce GTX 260",           15, 11, 8618   },
-    {VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_GTX275,     "NVIDIA GeForce GTX 275",           15, 11, 8618   },
-    {VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_GTX280,     "NVIDIA GeForce GTX 280",           15, 11, 8618   },
-    {VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_GT240,      "NVIDIA GeForce GT 240",            15, 11, 8618   },
+    {HW_VENDOR_NVIDIA,     CARD_NVIDIA_RIVA_TNT,           "NVIDIA RIVA TNT",                  1,  8,  6      },
+    {HW_VENDOR_NVIDIA,     CARD_NVIDIA_RIVA_TNT2,          "NVIDIA RIVA TNT2/TNT2 Pro",        1,  8,  6      },
+    {HW_VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE,            "NVIDIA GeForce 256",               1,  8,  6      },
+    {HW_VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE2_MX,        "NVIDIA GeForce2 MX/MX 400",        6,  4,  3      },
+    {HW_VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE2,           "NVIDIA GeForce2 GTS/GeForce2 Pro", 1,  8,  6      },
+    {HW_VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE3,           "NVIDIA GeForce3",                  6,  10, 9371   },
+    {HW_VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE4_MX,        "NVIDIA GeForce4 MX 460",           6,  10, 9371   },
+    {HW_VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE4_TI4200,    "NVIDIA GeForce4 Ti 4200",          6,  10, 9371   },
+    {HW_VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCEFX_5200,     "NVIDIA GeForce FX 5200",           15, 11, 7516   },
+    {HW_VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCEFX_5600,     "NVIDIA GeForce FX 5600",           15, 11, 7516   },
+    {HW_VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCEFX_5800,     "NVIDIA GeForce FX 5800",           15, 11, 7516   },
+    {HW_VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_6200,       "NVIDIA GeForce 6200",              15, 11, 8618   },
+    {HW_VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_6600GT,     "NVIDIA GeForce 6600 GT",           15, 11, 8618   },
+    {HW_VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_6800,       "NVIDIA GeForce 6800",              15, 11, 8618   },
+    {HW_VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_7300,       "NVIDIA GeForce Go 7300",           15, 11, 8585   },
+    {HW_VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_7400,       "NVIDIA GeForce Go 7400",           15, 11, 8585   },
+    {HW_VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_7600,       "NVIDIA GeForce 7600 GT",           15, 11, 8618   },
+    {HW_VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_7800GT,     "NVIDIA GeForce 7800 GT",           15, 11, 8618   },
+    {HW_VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_8300GS,     "NVIDIA GeForce 8300 GS",           15, 11, 8618   },
+    {HW_VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_8600GT,     "NVIDIA GeForce 8600 GT",           15, 11, 8618   },
+    {HW_VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_8600MGT,    "NVIDIA GeForce 8600M GT",          15, 11, 8585   },
+    {HW_VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_8800GTS,    "NVIDIA GeForce 8800 GTS",          15, 11, 8618   },
+    {HW_VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_9200,       "NVIDIA GeForce 9200",              15, 11, 8618   },
+    {HW_VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_9400GT,     "NVIDIA GeForce 9400 GT",           15, 11, 8618   },
+    {HW_VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_9500GT,     "NVIDIA GeForce 9500 GT",           15, 11, 8618   },
+    {HW_VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_9600GT,     "NVIDIA GeForce 9600 GT",           15, 11, 8618   },
+    {HW_VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_9800GT,     "NVIDIA GeForce 9800 GT",           15, 11, 8618   },
+    {HW_VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_GTX260,     "NVIDIA GeForce GTX 260",           15, 11, 8618   },
+    {HW_VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_GTX275,     "NVIDIA GeForce GTX 275",           15, 11, 8618   },
+    {HW_VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_GTX280,     "NVIDIA GeForce GTX 280",           15, 11, 8618   },
+    {HW_VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_GT240,      "NVIDIA GeForce GT 240",            15, 11, 8618   },
 
     /* ATI cards. The driver versions are somewhat similar, but not quite the same. Let's hardcode. */
-    {VENDOR_ATI,        CARD_ATI_RADEON_9500,           "ATI Radeon 9500",                  14, 10, 6764    },
-    {VENDOR_ATI,        CARD_ATI_RADEON_X700,           "ATI Radeon X700 SE",               14, 10, 6764    },
-    {VENDOR_ATI,        CARD_ATI_RADEON_X1600,          "ATI Radeon X1600 Series",          14, 10, 6764    },
-    {VENDOR_ATI,        CARD_ATI_RADEON_HD2300,         "ATI Mobility Radeon HD 2300",      14, 10, 6764    },
-    {VENDOR_ATI,        CARD_ATI_RADEON_HD2600,         "ATI Mobility Radeon HD 2600",      14, 10, 6764    },
-    {VENDOR_ATI,        CARD_ATI_RADEON_HD2900,         "ATI Radeon HD 2900 XT",            14, 10, 6764    },
-    {VENDOR_ATI,        CARD_ATI_RADEON_HD4350,         "ATI Radeon HD 4350",               14, 10, 6764    },
-    {VENDOR_ATI,        CARD_ATI_RADEON_HD4600,         "ATI Radeon HD 4600 Series",        14, 10, 6764    },
-    {VENDOR_ATI,        CARD_ATI_RADEON_HD4700,         "ATI Radeon HD 4700 Series",        14, 10, 6764    },
-    {VENDOR_ATI,        CARD_ATI_RADEON_HD4800,         "ATI Radeon HD 4800 Series",        14, 10, 6764    },
-    {VENDOR_ATI,        CARD_ATI_RADEON_HD5700,         "ATI Radeon HD 5700 Series",        14, 10, 8681    },
-    {VENDOR_ATI,        CARD_ATI_RADEON_HD5800,         "ATI Radeon HD 5800 Series",        14, 10, 8681    },
+    {HW_VENDOR_ATI,        CARD_ATI_RADEON_9500,           "ATI Radeon 9500",                  14, 10, 6764    },
+    {HW_VENDOR_ATI,        CARD_ATI_RADEON_X700,           "ATI Radeon X700 SE",               14, 10, 6764    },
+    {HW_VENDOR_ATI,        CARD_ATI_RADEON_X1600,          "ATI Radeon X1600 Series",          14, 10, 6764    },
+    {HW_VENDOR_ATI,        CARD_ATI_RADEON_HD2350,         "ATI Mobility Radeon HD 2350",      14, 10, 6764    },
+    {HW_VENDOR_ATI,        CARD_ATI_RADEON_HD2600,         "ATI Mobility Radeon HD 2600",      14, 10, 6764    },
+    {HW_VENDOR_ATI,        CARD_ATI_RADEON_HD2900,         "ATI Radeon HD 2900 XT",            14, 10, 6764    },
+    {HW_VENDOR_ATI,        CARD_ATI_RADEON_HD4350,         "ATI Radeon HD 4350",               14, 10, 6764    },
+    {HW_VENDOR_ATI,        CARD_ATI_RADEON_HD4600,         "ATI Radeon HD 4600 Series",        14, 10, 6764    },
+    {HW_VENDOR_ATI,        CARD_ATI_RADEON_HD4700,         "ATI Radeon HD 4700 Series",        14, 10, 6764    },
+    {HW_VENDOR_ATI,        CARD_ATI_RADEON_HD4800,         "ATI Radeon HD 4800 Series",        14, 10, 6764    },
+    {HW_VENDOR_ATI,        CARD_ATI_RADEON_HD5700,         "ATI Radeon HD 5700 Series",        14, 10, 8681    },
+    {HW_VENDOR_ATI,        CARD_ATI_RADEON_HD5800,         "ATI Radeon HD 5800 Series",        14, 10, 8681    },
 
     /* TODO: Add information about legacy ATI hardware, Intel and other cards. */
@@ -1005,12 +1067,13 @@
     switch (vendor)
     {
-        case VENDOR_ATI:
+        case HW_VENDOR_ATI:
             driver_info->name = "ati2dvag.dll";
             break;
 
-        case VENDOR_NVIDIA:
+        case HW_VENDOR_NVIDIA:
             driver_info->name = "nv4_disp.dll";
             break;
 
+        case HW_VENDOR_INTEL:
         default:
             FIXME_(d3d_caps)("Unhandled vendor %04x.\n", vendor);
@@ -1087,5 +1150,5 @@
 /* Context activation is done by the caller. */
 static void fixup_extensions(struct wined3d_gl_info *gl_info, const char *gl_renderer,
-        enum wined3d_pci_vendor vendor, enum wined3d_pci_device device)
+        enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
 {
     unsigned int i;
@@ -1093,5 +1156,5 @@
     for (i = 0; i < (sizeof(quirk_table) / sizeof(*quirk_table)); ++i)
     {
-        if (!quirk_table[i].match(gl_info, gl_renderer, vendor, device)) continue;
+        if (!quirk_table[i].match(gl_info, gl_renderer, gl_vendor, card_vendor, device)) continue;
         TRACE_(d3d_caps)("Applying driver quirk \"%s\".\n", quirk_table[i].description);
         quirk_table[i].apply(gl_info);
@@ -1120,32 +1183,779 @@
 }
 
-static enum wined3d_pci_vendor wined3d_guess_vendor(const char *gl_vendor, const char *gl_renderer)
-{
-    if (strstr(gl_vendor, "NVIDIA"))
-        return VENDOR_NVIDIA;
-
-    if (strstr(gl_vendor, "ATI"))
-        return VENDOR_ATI;
-
-    if (strstr(gl_vendor, "Intel(R)")
+static enum wined3d_gl_vendor wined3d_guess_gl_vendor(struct wined3d_gl_info *gl_info, const char *gl_vendor_string, const char *gl_renderer)
+{
+
+    /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
+     * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
+     * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
+     *
+     * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
+     * aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
+     * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
+     * like client storage might be supported on other implementations too, but GL_APPLE_flush_render
+     * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
+     * the chance that other implementations support them is rather small since Win32 QuickTime uses
+     * DirectDraw, not OpenGL. */
+    if (gl_info->supported[APPLE_FENCE]
+            && gl_info->supported[APPLE_CLIENT_STORAGE]
+            && gl_info->supported[APPLE_FLUSH_RENDER]
+            && gl_info->supported[APPLE_YCBCR_422])
+        return GL_VENDOR_APPLE;
+
+    if (strstr(gl_vendor_string, "NVIDIA"))
+        return GL_VENDOR_NVIDIA;
+
+    if (strstr(gl_vendor_string, "ATI"))
+        return GL_VENDOR_FGLRX;
+
+    if (strstr(gl_vendor_string, "Intel(R)")
             || strstr(gl_renderer, "Intel(R)")
-            || strstr(gl_vendor, "Intel Inc."))
-        return VENDOR_INTEL;
-
-    if (strstr(gl_vendor, "Mesa")
-            || strstr(gl_vendor, "DRI R300 Project")
-            || strstr(gl_vendor, "Tungsten Graphics, Inc")
-            || strstr(gl_vendor, "VMware, Inc."))
-        return VENDOR_MESA;
-
-    FIXME_(d3d_caps)("Received unrecognized GL_VENDOR %s. Returning VENDOR_WINE.\n", debugstr_a(gl_vendor));
-
-    return VENDOR_WINE;
-}
+            || strstr(gl_vendor_string, "Intel Inc."))
+        return GL_VENDOR_INTEL;
+
+    if (strstr(gl_vendor_string, "Mesa")
+            || strstr(gl_vendor_string, "Advanced Micro Devices, Inc.")
+            || strstr(gl_vendor_string, "DRI R300 Project")
+            || strstr(gl_vendor_string, "X.Org R300 Project")
+            || strstr(gl_vendor_string, "Tungsten Graphics, Inc")
+            || strstr(gl_vendor_string, "VMware, Inc.")
+            || strstr(gl_renderer, "Mesa")
+            || strstr(gl_renderer, "Gallium"))
+        return GL_VENDOR_MESA;
+
+    FIXME_(d3d_caps)("Received unrecognized GL_VENDOR %s. Returning GL_VENDOR_UNKNOWN.\n",
+            debugstr_a(gl_vendor_string));
+
+    return GL_VENDOR_UNKNOWN;
+}
+
+static enum wined3d_pci_vendor wined3d_guess_card_vendor(const char *gl_vendor_string, const char *gl_renderer)
+{
+    if (strstr(gl_vendor_string, "NVIDIA"))
+        return HW_VENDOR_NVIDIA;
+
+    if (strstr(gl_vendor_string, "ATI")
+            || strstr(gl_vendor_string, "Advanced Micro Devices, Inc.")
+            || strstr(gl_vendor_string, "X.Org R300 Project")
+            || strstr(gl_vendor_string, "DRI R300 Project"))
+        return HW_VENDOR_ATI;
+
+    if (strstr(gl_vendor_string, "Intel(R)")
+            || strstr(gl_renderer, "Intel(R)")
+            || strstr(gl_vendor_string, "Intel Inc."))
+        return HW_VENDOR_INTEL;
+
+    if (strstr(gl_vendor_string, "Mesa")
+            || strstr(gl_vendor_string, "Tungsten Graphics, Inc")
+            || strstr(gl_vendor_string, "VMware, Inc."))
+        return HW_VENDOR_SOFTWARE;
+
+    FIXME_(d3d_caps)("Received unrecognized GL_VENDOR %s. Returning HW_VENDOR_NVIDIA.\n", debugstr_a(gl_vendor_string));
+
+    return HW_VENDOR_NVIDIA;
+}
+
+
+
+static enum wined3d_pci_device select_card_nvidia_binary(const struct wined3d_gl_info *gl_info,
+        const char *gl_renderer, unsigned int *vidmem)
+{
+    if (WINE_D3D10_CAPABLE(gl_info))
+    {
+        /* Geforce 200 - highend */
+        if (strstr(gl_renderer, "GTX 280")
+                || strstr(gl_renderer, "GTX 285")
+                || strstr(gl_renderer, "GTX 295"))
+        {
+            *vidmem = 1024;
+            return CARD_NVIDIA_GEFORCE_GTX280;
+        }
+
+        /* Geforce 200 - midend high */
+        if (strstr(gl_renderer, "GTX 275"))
+        {
+            *vidmem = 896;
+            return CARD_NVIDIA_GEFORCE_GTX275;
+        }
+
+        /* Geforce 200 - midend */
+        if (strstr(gl_renderer, "GTX 260"))
+        {
+            *vidmem = 1024;
+            return CARD_NVIDIA_GEFORCE_GTX260;
+        }
+        /* Geforce 200 - midend */
+        if (strstr(gl_renderer, "GT 240"))
+        {
+           *vidmem = 512;
+           return CARD_NVIDIA_GEFORCE_GT240;
+        }
+
+        /* Geforce9 - highend / Geforce 200 - midend (GTS 150/250 are based on the same core) */
+        if (strstr(gl_renderer, "9800")
+                || strstr(gl_renderer, "GTS 150")
+                || strstr(gl_renderer, "GTS 250"))
+        {
+            *vidmem = 512;
+            return CARD_NVIDIA_GEFORCE_9800GT;
+        }
+
+        /* Geforce9 - midend */
+        if (strstr(gl_renderer, "9600"))
+        {
+            *vidmem = 384; /* The 9600GSO has 384MB, the 9600GT has 512-1024MB */
+            return CARD_NVIDIA_GEFORCE_9600GT;
+        }
+
+        /* Geforce9 - midend low / Geforce 200 - low */
+        if (strstr(gl_renderer, "9500")
+                || strstr(gl_renderer, "GT 120")
+                || strstr(gl_renderer, "GT 130"))
+        {
+            *vidmem = 256; /* The 9500GT has 256-1024MB */
+            return CARD_NVIDIA_GEFORCE_9500GT;
+        }
+
+        /* Geforce9 - lowend */
+        if (strstr(gl_renderer, "9400"))
+        {
+            *vidmem = 256; /* The 9400GT has 256-1024MB */
+            return CARD_NVIDIA_GEFORCE_9400GT;
+        }
+
+        /* Geforce9 - lowend low */
+        if (strstr(gl_renderer, "9100")
+                || strstr(gl_renderer, "9200")
+                || strstr(gl_renderer, "9300")
+                || strstr(gl_renderer, "G 100"))
+        {
+            *vidmem = 256; /* The 9100-9300 cards have 256MB */
+            return CARD_NVIDIA_GEFORCE_9200;
+        }
+
+        /* Geforce8 - highend */
+        if (strstr(gl_renderer, "8800"))
+        {
+            *vidmem = 320; /* The 8800GTS uses 320MB, a 8800GTX can have 768MB */
+            return CARD_NVIDIA_GEFORCE_8800GTS;
+        }
+
+        /* Geforce8 - midend mobile */
+        if (strstr(gl_renderer, "8600 M"))
+        {
+            *vidmem = 512;
+            return CARD_NVIDIA_GEFORCE_8600MGT;
+        }
+
+        /* Geforce8 - midend */
+        if (strstr(gl_renderer, "8600")
+                || strstr(gl_renderer, "8700"))
+        {
+            *vidmem = 256;
+            return CARD_NVIDIA_GEFORCE_8600GT;
+        }
+
+        /* Geforce8 - lowend */
+        if (strstr(gl_renderer, "8100")
+                || strstr(gl_renderer, "8200")
+                || strstr(gl_renderer, "8300")
+                || strstr(gl_renderer, "8400")
+                || strstr(gl_renderer, "8500"))
+        {
+            *vidmem = 128; /* 128-256MB for a 8300, 256-512MB for a 8400 */
+            return CARD_NVIDIA_GEFORCE_8300GS;
+        }
+
+        /* Geforce8-compatible fall back if the GPU is not in the list yet */
+        *vidmem = 128;
+        return CARD_NVIDIA_GEFORCE_8300GS;
+    }
+
+    /* Both the GeforceFX, 6xxx and 7xxx series support D3D9. The last two types have more
+     * shader capabilities, so we use the shader capabilities to distinguish between FX and 6xxx/7xxx.
+     */
+    if (WINE_D3D9_CAPABLE(gl_info) && gl_info->supported[NV_VERTEX_PROGRAM3])
+    {
+        /* Geforce7 - highend */
+        if (strstr(gl_renderer, "7800")
+                || strstr(gl_renderer, "7900")
+                || strstr(gl_renderer, "7950")
+                || strstr(gl_renderer, "Quadro FX 4")
+                || strstr(gl_renderer, "Quadro FX 5"))
+        {
+            *vidmem = 256; /* A 7800GT uses 256MB while highend 7900 cards can use 512MB */
+            return CARD_NVIDIA_GEFORCE_7800GT;
+        }
+
+        /* Geforce7 midend */
+        if (strstr(gl_renderer, "7600")
+                || strstr(gl_renderer, "7700"))
+        {
+            *vidmem = 256; /* The 7600 uses 256-512MB */
+            return CARD_NVIDIA_GEFORCE_7600;
+        }
+
+        /* Geforce7 lower medium */
+        if (strstr(gl_renderer, "7400"))
+        {
+            *vidmem = 256; /* The 7400 uses 256-512MB */
+            return CARD_NVIDIA_GEFORCE_7400;
+        }
+
+        /* Geforce7 lowend */
+        if (strstr(gl_renderer, "7300"))
+        {
+            *vidmem = 256; /* Mac Pros with this card have 256 MB */
+            return CARD_NVIDIA_GEFORCE_7300;
+        }
+
+        /* Geforce6 highend */
+        if (strstr(gl_renderer, "6800"))
+        {
+            *vidmem = 128; /* The 6800 uses 128-256MB, the 7600 uses 256-512MB */
+            return CARD_NVIDIA_GEFORCE_6800;
+        }
+
+        /* Geforce6 - midend */
+        if (strstr(gl_renderer, "6600")
+                || strstr(gl_renderer, "6610")
+                || strstr(gl_renderer, "6700"))
+        {
+            *vidmem = 128; /* A 6600GT has 128-256MB */
+            return CARD_NVIDIA_GEFORCE_6600GT;
+        }
+
+        /* Geforce6/7 lowend */
+        *vidmem = 64; /* */
+        return CARD_NVIDIA_GEFORCE_6200; /* Geforce 6100/6150/6200/7300/7400/7500 */
+    }
+
+    if (WINE_D3D9_CAPABLE(gl_info))
+    {
+        /* GeforceFX - highend */
+        if (strstr(gl_renderer, "5800")
+                || strstr(gl_renderer, "5900")
+                || strstr(gl_renderer, "5950")
+                || strstr(gl_renderer, "Quadro FX"))
+        {
+            *vidmem = 256; /* 5800-5900 cards use 256MB */
+            return CARD_NVIDIA_GEFORCEFX_5800;
+        }
+
+        /* GeforceFX - midend */
+        if (strstr(gl_renderer, "5600")
+                || strstr(gl_renderer, "5650")
+                || strstr(gl_renderer, "5700")
+                || strstr(gl_renderer, "5750"))
+        {
+            *vidmem = 128; /* A 5600 uses 128-256MB */
+            return CARD_NVIDIA_GEFORCEFX_5600;
+        }
+
+        /* GeforceFX - lowend */
+        *vidmem = 64; /* Normal FX5200 cards use 64-256MB; laptop (non-standard) can have less */
+        return CARD_NVIDIA_GEFORCEFX_5200; /* GeforceFX 5100/5200/5250/5300/5500 */
+    }
+
+    if (WINE_D3D8_CAPABLE(gl_info))
+    {
+        if (strstr(gl_renderer, "GeForce4 Ti") || strstr(gl_renderer, "Quadro4"))
+        {
+            *vidmem = 64; /* Geforce4 Ti cards have 64-128MB */
+            return CARD_NVIDIA_GEFORCE4_TI4200; /* Geforce4 Ti4200/Ti4400/Ti4600/Ti4800, Quadro4 */
+        }
+
+        *vidmem = 64; /* Geforce3 cards have 64-128MB */
+        return CARD_NVIDIA_GEFORCE3; /* Geforce3 standard/Ti200/Ti500, Quadro DCC */
+    }
+
+    if (WINE_D3D7_CAPABLE(gl_info))
+    {
+        if (strstr(gl_renderer, "GeForce4 MX"))
+        {
+            /* Most Geforce4MX GPUs have at least 64MB of memory, some
+             * early models had 32MB but most have 64MB or even 128MB. */
+            *vidmem = 64;
+            return CARD_NVIDIA_GEFORCE4_MX; /* MX420/MX440/MX460/MX4000 */
+        }
+
+        if (strstr(gl_renderer, "GeForce2 MX") || strstr(gl_renderer, "Quadro2 MXR"))
+        {
+            *vidmem = 32; /* Geforce2MX GPUs have 32-64MB of video memory */
+            return CARD_NVIDIA_GEFORCE2_MX; /* Geforce2 standard/MX100/MX200/MX400, Quadro2 MXR */
+        }
+
+        if (strstr(gl_renderer, "GeForce2") || strstr(gl_renderer, "Quadro2"))
+        {
+            *vidmem = 32; /* Geforce2 GPUs have 32-64MB of video memory */
+            return CARD_NVIDIA_GEFORCE2; /* Geforce2 GTS/Pro/Ti/Ultra, Quadro2 */
+        }
+
+        /* Most Geforce1 cards have 32MB, there are also some rare 16
+         * and 64MB (Dell) models. */
+        *vidmem = 32;
+        return CARD_NVIDIA_GEFORCE; /* Geforce 256/DDR, Quadro */
+    }
+
+    if (strstr(gl_renderer, "TNT2"))
+    {
+        *vidmem = 32; /* Most TNT2 boards have 32MB, though there are 16MB boards too */
+        return CARD_NVIDIA_RIVA_TNT2; /* Riva TNT2 standard/M64/Pro/Ultra */
+    }
+
+    *vidmem = 16; /* Most TNT boards have 16MB, some rare models have 8MB */
+    return CARD_NVIDIA_RIVA_TNT; /* Riva TNT, Vanta */
+
+}
+
+static enum wined3d_pci_device select_card_ati_binary(const struct wined3d_gl_info *gl_info,
+        const char *gl_renderer, unsigned int *vidmem)
+{
+    /* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx
+     *
+     * Beware: renderer string do not match exact card model,
+     * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */
+    if (WINE_D3D10_CAPABLE(gl_info))
+    {
+        /* Radeon EG CYPRESS XT / PRO HD5800 - highend */
+        if (strstr(gl_renderer, "HD 5800")          /* Radeon EG CYPRESS HD58xx generic renderer string */
+                || strstr(gl_renderer, "HD 5850")   /* Radeon EG CYPRESS XT */
+                || strstr(gl_renderer, "HD 5870"))  /* Radeon EG CYPRESS PRO */
+        {
+            *vidmem = 1024; /* note: HD58xx cards use 1024MB  */
+            return CARD_ATI_RADEON_HD5800;
+        }
+
+        /* Radeon EG JUNIPER XT / LE HD5700 - midend */
+        if (strstr(gl_renderer, "HD 5700")          /* Radeon EG JUNIPER HD57xx generic renderer string */
+                || strstr(gl_renderer, "HD 5750")   /* Radeon EG JUNIPER LE */
+                || strstr(gl_renderer, "HD 5770"))  /* Radeon EG JUNIPER XT */
+        {
+            *vidmem = 512; /* note: HD5770 cards use 1024MB and HD5750 cards use 512MB or 1024MB  */
+            return CARD_ATI_RADEON_HD5700;
+        }
+
+        /* Radeon R7xx HD4800 - highend */
+        if (strstr(gl_renderer, "HD 4800")          /* Radeon RV7xx HD48xx generic renderer string */
+                || strstr(gl_renderer, "HD 4830")   /* Radeon RV770 */
+                || strstr(gl_renderer, "HD 4850")   /* Radeon RV770 */
+                || strstr(gl_renderer, "HD 4870")   /* Radeon RV770 */
+                || strstr(gl_renderer, "HD 4890"))  /* Radeon RV790 */
+        {
+            *vidmem = 512; /* note: HD4890 cards use 1024MB */
+            return CARD_ATI_RADEON_HD4800;
+        }
+
+        /* Radeon R740 HD4700 - midend */
+        if (strstr(gl_renderer, "HD 4700")          /* Radeon RV770 */
+                || strstr(gl_renderer, "HD 4770"))  /* Radeon RV740 */
+        {
+            *vidmem = 512;
+            return CARD_ATI_RADEON_HD4700;
+        }
+
+        /* Radeon R730 HD4600 - midend */
+        if (strstr(gl_renderer, "HD 4600")          /* Radeon RV730 */
+                || strstr(gl_renderer, "HD 4650")   /* Radeon RV730 */
+                || strstr(gl_renderer, "HD 4670"))  /* Radeon RV730 */
+        {
+            *vidmem = 512;
+            return CARD_ATI_RADEON_HD4600;
+        }
+
+        /* Radeon R710 HD4500/HD4350 - lowend */
+        if (strstr(gl_renderer, "HD 4350")          /* Radeon RV710 */
+                || strstr(gl_renderer, "HD 4550"))  /* Radeon RV710 */
+        {
+            *vidmem = 256;
+            return CARD_ATI_RADEON_HD4350;
+        }
+
+        /* Radeon R6xx HD2900/HD3800 - highend */
+        if (strstr(gl_renderer, "HD 2900")
+                || strstr(gl_renderer, "HD 3870")
+                || strstr(gl_renderer, "HD 3850"))
+        {
+            *vidmem = 512; /* HD2900/HD3800 uses 256-1024MB */
+            return CARD_ATI_RADEON_HD2900;
+        }
+
+        /* Radeon R6xx HD2600/HD3600 - midend; HD3830 is China-only midend */
+        if (strstr(gl_renderer, "HD 2600")
+                || strstr(gl_renderer, "HD 3830")
+                || strstr(gl_renderer, "HD 3690")
+                || strstr(gl_renderer, "HD 3650"))
+        {
+            *vidmem = 256; /* HD2600/HD3600 uses 256-512MB */
+            return CARD_ATI_RADEON_HD2600;
+        }
+
+        /* Radeon R6xx HD2350/HD2400/HD3400 - lowend
+         * Note HD2300=DX9, HD2350=DX10 */
+        if (strstr(gl_renderer, "HD 2350")
+                || strstr(gl_renderer, "HD 2400")
+                || strstr(gl_renderer, "HD 3470")
+                || strstr(gl_renderer, "HD 3450")
+                || strstr(gl_renderer, "HD 3430")
+                || strstr(gl_renderer, "HD 3400"))
+        {
+            *vidmem = 256; /* HD2350/2400 use 256MB, HD34xx use 256-512MB */
+            return CARD_ATI_RADEON_HD2350;
+        }
+
+        /* Radeon R6xx/R7xx integrated */
+        if (strstr(gl_renderer, "HD 3100")
+                || strstr(gl_renderer, "HD 3200")
+                || strstr(gl_renderer, "HD 3300"))
+        {
+            *vidmem = 128; /* 128MB */
+            return CARD_ATI_RADEON_HD3200;
+        }
+
+        /* Default for when no GPU has been found */
+        *vidmem = 128; /* 128MB */
+        return CARD_ATI_RADEON_HD3200;
+    }
+
+    if (WINE_D3D8_CAPABLE(gl_info))
+    {
+        /* Radeon R5xx */
+        if (strstr(gl_renderer, "X1600")
+                || strstr(gl_renderer, "X1650")
+                || strstr(gl_renderer, "X1800")
+                || strstr(gl_renderer, "X1900")
+                || strstr(gl_renderer, "X1950"))
+        {
+            *vidmem = 128; /* X1600 uses 128-256MB, >=X1800 uses 256MB */
+            return CARD_ATI_RADEON_X1600;
+        }
+
+        /* Radeon R4xx + X1300/X1400/X1450/X1550/X2300/X2500/HD2300 (lowend R5xx)
+         * Note X2300/X2500/HD2300 are R5xx GPUs with a 2xxx naming but they are still DX9-only */
+        if (strstr(gl_renderer, "X700")
+                || strstr(gl_renderer, "X800")
+                || strstr(gl_renderer, "X850")
+                || strstr(gl_renderer, "X1300")
+                || strstr(gl_renderer, "X1400")
+                || strstr(gl_renderer, "X1450")
+                || strstr(gl_renderer, "X1550")
+                || strstr(gl_renderer, "X2300")
+                || strstr(gl_renderer, "X2500")
+                || strstr(gl_renderer, "HD 2300")
+                )
+        {
+            *vidmem = 128; /* x700/x8*0 use 128-256MB, >=x1300 128-512MB */
+            return CARD_ATI_RADEON_X700;
+        }
+
+        /* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400MHz */
+        if (strstr(gl_renderer, "Radeon Xpress"))
+        {
+            *vidmem = 64; /* Shared RAM, BIOS configurable, 64-256M */
+            return CARD_ATI_RADEON_XPRESS_200M;
+        }
+
+        /* Radeon R3xx */
+        *vidmem = 64; /* Radeon 9500 uses 64MB, higher models use up to 256MB */
+        return CARD_ATI_RADEON_9500; /* Radeon 9500/9550/9600/9700/9800/X300/X550/X600 */
+    }
+
+    if (WINE_D3D8_CAPABLE(gl_info))
+    {
+        *vidmem = 64; /* 8500/9000 cards use mostly 64MB, though there are 32MB and 128MB models */
+        return CARD_ATI_RADEON_8500; /* Radeon 8500/9000/9100/9200/9300 */
+    }
+
+    if (WINE_D3D7_CAPABLE(gl_info))
+    {
+        *vidmem = 32; /* There are models with up to 64MB */
+        return CARD_ATI_RADEON_7200; /* Radeon 7000/7100/7200/7500 */
+    }
+
+    *vidmem = 16; /* There are 16-32MB models */
+    return CARD_ATI_RAGE_128PRO;
+
+}
+
+static enum wined3d_pci_device select_card_intel_binary(const struct wined3d_gl_info *gl_info,
+        const char *gl_renderer, unsigned int *vidmem)
+{
+    if (strstr(gl_renderer, "X3100"))
+    {
+        /* MacOS calls the card GMA X3100, Google findings also suggest the name GM965 */
+        *vidmem = 128;
+        return CARD_INTEL_X3100;
+    }
+
+    if (strstr(gl_renderer, "GMA 950") || strstr(gl_renderer, "945GM"))
+    {
+        /* MacOS calls the card GMA 950, but everywhere else the PCI ID is named 945GM */
+        *vidmem = 64;
+        return CARD_INTEL_I945GM;
+    }
+
+    if (strstr(gl_renderer, "915GM")) return CARD_INTEL_I915GM;
+    if (strstr(gl_renderer, "915G")) return CARD_INTEL_I915G;
+    if (strstr(gl_renderer, "865G")) return CARD_INTEL_I865G;
+    if (strstr(gl_renderer, "855G")) return CARD_INTEL_I855G;
+    if (strstr(gl_renderer, "830G")) return CARD_INTEL_I830G;
+    return CARD_INTEL_I915G;
+
+}
+
+static enum wined3d_pci_device select_card_ati_mesa(const struct wined3d_gl_info *gl_info,
+        const char *gl_renderer, unsigned int *vidmem)
+{
+    /* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx
+     *
+     * Beware: renderer string do not match exact card model,
+     * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */
+    if (strstr(gl_renderer, "Gallium"))
+    {
+        /* Radeon R7xx HD4800 - highend */
+        if (strstr(gl_renderer, "R700")          /* Radeon R7xx HD48xx generic renderer string */
+                || strstr(gl_renderer, "RV770")  /* Radeon RV770 */
+                || strstr(gl_renderer, "RV790"))  /* Radeon RV790 */
+        {
+            *vidmem = 512; /* note: HD4890 cards use 1024MB */
+            return CARD_ATI_RADEON_HD4800;
+        }
+
+        /* Radeon R740 HD4700 - midend */
+        if (strstr(gl_renderer, "RV740"))          /* Radeon RV740 */
+        {
+            *vidmem = 512;
+            return CARD_ATI_RADEON_HD4700;
+        }
+
+        /* Radeon R730 HD4600 - midend */
+        if (strstr(gl_renderer, "RV730"))        /* Radeon RV730 */
+        {
+            *vidmem = 512;
+            return CARD_ATI_RADEON_HD4600;
+        }
+
+        /* Radeon R710 HD4500/HD4350 - lowend */
+        if (strstr(gl_renderer, "RV710"))          /* Radeon RV710 */
+        {
+            *vidmem = 256;
+            return CARD_ATI_RADEON_HD4350;
+        }
+
+        /* Radeon R6xx HD2900/HD3800 - highend */
+        if (strstr(gl_renderer, "R600")
+                || strstr(gl_renderer, "RV670")
+                || strstr(gl_renderer, "R680"))
+        {
+            *vidmem = 512; /* HD2900/HD3800 uses 256-1024MB */
+            return CARD_ATI_RADEON_HD2900;
+        }
+
+        /* Radeon R6xx HD2600/HD3600 - midend; HD3830 is China-only midend */
+        if (strstr(gl_renderer, "RV630")
+                || strstr(gl_renderer, "RV635"))
+        {
+            *vidmem = 256; /* HD2600/HD3600 uses 256-512MB */
+            return CARD_ATI_RADEON_HD2600;
+        }
+
+        /* Radeon R6xx HD2350/HD2400/HD3400 - lowend */
+        if (strstr(gl_renderer, "RV610")
+                || strstr(gl_renderer, "RV620"))
+        {
+            *vidmem = 256; /* HD2350/2400 use 256MB, HD34xx use 256-512MB */
+            return CARD_ATI_RADEON_HD2350;
+        }
+
+        /* Radeon R6xx/R7xx integrated */
+        if (strstr(gl_renderer, "RS780")
+                || strstr(gl_renderer, "RS880"))
+        {
+            *vidmem = 128; /* 128MB */
+            return CARD_ATI_RADEON_HD3200;
+        }
+
+        /* Radeon R5xx */
+        if (strstr(gl_renderer, "RV530")
+                || strstr(gl_renderer, "RV535")
+                || strstr(gl_renderer, "RV560")
+                || strstr(gl_renderer, "R520")
+                || strstr(gl_renderer, "RV570")
+                || strstr(gl_renderer, "R580"))
+        {
+            *vidmem = 128; /* X1600 uses 128-256MB, >=X1800 uses 256MB */
+            return CARD_ATI_RADEON_X1600;
+        }
+
+        /* Radeon R4xx + X1300/X1400/X1450/X1550/X2300 (lowend R5xx) */
+        if (strstr(gl_renderer, "R410")
+                || strstr(gl_renderer, "R420")
+                || strstr(gl_renderer, "R423")
+                || strstr(gl_renderer, "R430")
+                || strstr(gl_renderer, "R480")
+                || strstr(gl_renderer, "R481")
+                || strstr(gl_renderer, "RV410")
+                || strstr(gl_renderer, "RV515")
+                || strstr(gl_renderer, "RV516"))
+        {
+            *vidmem = 128; /* x700/x8*0 use 128-256MB, >=x1300 128-512MB */
+            return CARD_ATI_RADEON_X700;
+        }
+
+        /* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400MHz */
+        if (strstr(gl_renderer, "RS400")
+                || strstr(gl_renderer, "RS480")
+                || strstr(gl_renderer, "RS482")
+                || strstr(gl_renderer, "RS485")
+                || strstr(gl_renderer, "RS600")
+                || strstr(gl_renderer, "RS690")
+                || strstr(gl_renderer, "RS740"))
+        {
+            *vidmem = 64; /* Shared RAM, BIOS configurable, 64-256M */
+            return CARD_ATI_RADEON_XPRESS_200M;
+        }
+
+        /* Radeon R3xx */
+        if (strstr(gl_renderer, "R300")
+                || strstr(gl_renderer, "RV350")
+                || strstr(gl_renderer, "RV351")
+                || strstr(gl_renderer, "RV360")
+                || strstr(gl_renderer, "RV370")
+                || strstr(gl_renderer, "R350")
+                || strstr(gl_renderer, "R360"))
+        {
+            *vidmem = 64; /* Radeon 9500 uses 64MB, higher models use up to 256MB */
+            return CARD_ATI_RADEON_9500; /* Radeon 9500/9550/9600/9700/9800/X300/X550/X600 */
+        }
+    }
+
+    if (WINE_D3D9_CAPABLE(gl_info))
+    {
+        /* Radeon R7xx HD4800 - highend */
+        if (strstr(gl_renderer, "(R700")          /* Radeon R7xx HD48xx generic renderer string */
+                || strstr(gl_renderer, "(RV770")  /* Radeon RV770 */
+                || strstr(gl_renderer, "(RV790"))  /* Radeon RV790 */
+        {
+            *vidmem = 512; /* note: HD4890 cards use 1024MB */
+            return CARD_ATI_RADEON_HD4800;
+        }
+
+        /* Radeon R740 HD4700 - midend */
+        if (strstr(gl_renderer, "(RV740"))          /* Radeon RV740 */
+        {
+            *vidmem = 512;
+            return CARD_ATI_RADEON_HD4700;
+        }
+
+        /* Radeon R730 HD4600 - midend */
+        if (strstr(gl_renderer, "(RV730"))        /* Radeon RV730 */
+        {
+            *vidmem = 512;
+            return CARD_ATI_RADEON_HD4600;
+        }
+
+        /* Radeon R710 HD4500/HD4350 - lowend */
+        if (strstr(gl_renderer, "(RV710"))          /* Radeon RV710 */
+        {
+            *vidmem = 256;
+            return CARD_ATI_RADEON_HD4350;
+        }
+
+        /* Radeon R6xx HD2900/HD3800 - highend */
+        if (strstr(gl_renderer, "(R600")
+                || strstr(gl_renderer, "(RV670")
+                || strstr(gl_renderer, "(R680"))
+        {
+            *vidmem = 512; /* HD2900/HD3800 uses 256-1024MB */
+            return CARD_ATI_RADEON_HD2900;
+        }
+
+        /* Radeon R6xx HD2600/HD3600 - midend; HD3830 is China-only midend */
+        if (strstr(gl_renderer, "(RV630")
+                || strstr(gl_renderer, "(RV635"))
+        {
+            *vidmem = 256; /* HD2600/HD3600 uses 256-512MB */
+            return CARD_ATI_RADEON_HD2600;
+        }
+
+        /* Radeon R6xx HD2300/HD2400/HD3400 - lowend */
+        if (strstr(gl_renderer, "(RV610")
+                || strstr(gl_renderer, "(RV620"))
+        {
+            *vidmem = 256; /* HD2350/2400 use 256MB, HD34xx use 256-512MB */
+            return CARD_ATI_RADEON_HD2350;
+        }
+
+        /* Radeon R6xx/R7xx integrated */
+        if (strstr(gl_renderer, "(RS780")
+                || strstr(gl_renderer, "(RS880"))
+        {
+            *vidmem = 128; /* 128MB */
+            return CARD_ATI_RADEON_HD3200;
+        }
+    }
+
+    if (WINE_D3D8_CAPABLE(gl_info))
+    {
+        *vidmem = 64; /* 8500/9000 cards use mostly 64MB, though there are 32MB and 128MB models */
+        return CARD_ATI_RADEON_8500; /* Radeon 8500/9000/9100/9200/9300 */
+    }
+
+    if (WINE_D3D7_CAPABLE(gl_info))
+    {
+        *vidmem = 32; /* There are models with up to 64MB */
+        return CARD_ATI_RADEON_7200; /* Radeon 7000/7100/7200/7500 */
+    }
+
+    *vidmem = 16; /* There are 16-32MB models */
+    return CARD_ATI_RAGE_128PRO;
+
+}
+
+static enum wined3d_pci_device select_card_nvidia_mesa(const struct wined3d_gl_info *gl_info,
+        const char *gl_renderer, unsigned int *vidmem)
+{
+    FIXME_(d3d_caps)("Card selection not handled for Mesa Nouveau driver\n");
+    if (WINE_D3D9_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCEFX_5600;
+    if (WINE_D3D8_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE3;
+    if (WINE_D3D7_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE;
+    if (WINE_D3D6_CAPABLE(gl_info)) return CARD_NVIDIA_RIVA_TNT;
+    return CARD_NVIDIA_RIVA_128;
+}
+
+static enum wined3d_pci_device select_card_intel_mesa(const struct wined3d_gl_info *gl_info,
+        const char *gl_renderer, unsigned int *vidmem)
+{
+    FIXME_(d3d_caps)("Card selection not handled for Mesa Intel driver\n");
+    return CARD_INTEL_I915G;
+}
+
+
+struct vendor_card_selection
+{
+    enum wined3d_gl_vendor gl_vendor;
+    enum wined3d_pci_vendor card_vendor;
+    const char *description;        /* Description of the card selector i.e. Apple OS/X Intel */
+    enum wined3d_pci_device (*select_card)(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
+            unsigned int *vidmem );
+};
+
+static const struct vendor_card_selection vendor_card_select_table[] =
+{
+    {GL_VENDOR_NVIDIA, HW_VENDOR_NVIDIA,  "Nvidia binary driver",     select_card_nvidia_binary},
+    {GL_VENDOR_APPLE,  HW_VENDOR_NVIDIA,  "Apple OSX NVidia binary driver",   select_card_nvidia_binary},
+    {GL_VENDOR_APPLE,  HW_VENDOR_ATI,     "Apple OSX AMD/ATI binary driver",  select_card_ati_binary},
+    {GL_VENDOR_APPLE,  HW_VENDOR_INTEL,   "Apple OSX Intel binary driver",    select_card_intel_binary},
+    {GL_VENDOR_FGLRX,  HW_VENDOR_ATI,     "AMD/ATI binary driver",    select_card_ati_binary},
+    {GL_VENDOR_MESA,   HW_VENDOR_ATI,     "Mesa AMD/ATI driver",      select_card_ati_mesa},
+    {GL_VENDOR_MESA,   HW_VENDOR_NVIDIA,  "Mesa Nouveau driver",      select_card_nvidia_mesa},
+    {GL_VENDOR_MESA,   HW_VENDOR_INTEL,   "Mesa Intel driver",        select_card_intel_mesa}
+};
+
 
 static enum wined3d_pci_device wined3d_guess_card(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
-        enum wined3d_pci_vendor *vendor, unsigned int *vidmem)
-{
-    /* Below is a list of Nvidia and ATI GPUs. Both vendors have dozens of
+        enum wined3d_gl_vendor *gl_vendor, enum wined3d_pci_vendor *card_vendor, unsigned int *vidmem)
+{
+    /* Above is a list of Nvidia and ATI GPUs. Both vendors have dozens of
      * different GPUs with roughly the same features. In most cases GPUs from a
      * certain family differ in clockspeeds, the amount of video memory and the
@@ -1202,442 +2012,76 @@
      * memory can be overruled using a registry setting. */
 
-    switch (*vendor)
-    {
-        case VENDOR_NVIDIA:
-            /* Both the GeforceFX, 6xxx and 7xxx series support D3D9. The last two types have more
-             * shader capabilities, so we use the shader capabilities to distinguish between FX and 6xxx/7xxx.
-             */
-            if (WINE_D3D9_CAPABLE(gl_info) && gl_info->supported[NV_VERTEX_PROGRAM3])
-            {
-                /* Geforce 200 - highend */
-                if (strstr(gl_renderer, "GTX 280")
-                        || strstr(gl_renderer, "GTX 285")
-                        || strstr(gl_renderer, "GTX 295"))
-                {
-                    *vidmem = 1024;
-                    return CARD_NVIDIA_GEFORCE_GTX280;
-                }
-
-                /* Geforce 200 - midend high */
-                if (strstr(gl_renderer, "GTX 275"))
-                {
-                    *vidmem = 896;
-                    return CARD_NVIDIA_GEFORCE_GTX275;
-                }
-
-                /* Geforce 200 - midend */
-                if (strstr(gl_renderer, "GTX 260"))
-                {
-                    *vidmem = 1024;
-                    return CARD_NVIDIA_GEFORCE_GTX260;
-                }
-                /* Geforce 200 - midend */
-                if (strstr(gl_renderer, "GT 240"))
-                {
-                   *vidmem = 512;
-                   return CARD_NVIDIA_GEFORCE_GT240;
-                }
-
-                /* Geforce9 - highend / Geforce 200 - midend (GTS 150/250 are based on the same core) */
-                if (strstr(gl_renderer, "9800")
-                        || strstr(gl_renderer, "GTS 150")
-                        || strstr(gl_renderer, "GTS 250"))
-                {
-                    *vidmem = 512;
-                    return CARD_NVIDIA_GEFORCE_9800GT;
-                }
-
-                /* Geforce9 - midend */
-                if (strstr(gl_renderer, "9600"))
-                {
-                    *vidmem = 384; /* The 9600GSO has 384MB, the 9600GT has 512-1024MB */
-                    return CARD_NVIDIA_GEFORCE_9600GT;
-                }
-
-                /* Geforce9 - midend low / Geforce 200 - low */
-                if (strstr(gl_renderer, "9500")
-                        || strstr(gl_renderer, "GT 120")
-                        || strstr(gl_renderer, "GT 130"))
-                {
-                    *vidmem = 256; /* The 9500GT has 256-1024MB */
-                    return CARD_NVIDIA_GEFORCE_9500GT;
-                }
-
-                /* Geforce9 - lowend */
-                if (strstr(gl_renderer, "9400"))
-                {
-                    *vidmem = 256; /* The 9400GT has 256-1024MB */
-                    return CARD_NVIDIA_GEFORCE_9400GT;
-                }
-
-                /* Geforce9 - lowend low */
-                if (strstr(gl_renderer, "9100")
-                        || strstr(gl_renderer, "9200")
-                        || strstr(gl_renderer, "9300")
-                        || strstr(gl_renderer, "G 100"))
-                {
-                    *vidmem = 256; /* The 9100-9300 cards have 256MB */
-                    return CARD_NVIDIA_GEFORCE_9200;
-                }
-
-                /* Geforce8 - highend */
-                if (strstr(gl_renderer, "8800"))
-                {
-                    *vidmem = 320; /* The 8800GTS uses 320MB, a 8800GTX can have 768MB */
-                    return CARD_NVIDIA_GEFORCE_8800GTS;
-                }
-
-                /* Geforce8 - midend mobile */
-                if (strstr(gl_renderer, "8600 M"))
-                {
-                    *vidmem = 512;
-                    return CARD_NVIDIA_GEFORCE_8600MGT;
-                }
-
-                /* Geforce8 - midend */
-                if (strstr(gl_renderer, "8600")
-                        || strstr(gl_renderer, "8700"))
-                {
-                    *vidmem = 256;
-                    return CARD_NVIDIA_GEFORCE_8600GT;
-                }
-
-                /* Geforce8 - lowend */
-                if (strstr(gl_renderer, "8100")
-                        || strstr(gl_renderer, "8200")
-                        || strstr(gl_renderer, "8300")
-                        || strstr(gl_renderer, "8400")
-                        || strstr(gl_renderer, "8500"))
-                {
-                    *vidmem = 128; /* 128-256MB for a 8300, 256-512MB for a 8400 */
-                    return CARD_NVIDIA_GEFORCE_8300GS;
-                }
-
-                /* Geforce7 - highend */
-                if (strstr(gl_renderer, "7800")
-                        || strstr(gl_renderer, "7900")
-                        || strstr(gl_renderer, "7950")
-                        || strstr(gl_renderer, "Quadro FX 4")
-                        || strstr(gl_renderer, "Quadro FX 5"))
-                {
-                    *vidmem = 256; /* A 7800GT uses 256MB while highend 7900 cards can use 512MB */
-                    return CARD_NVIDIA_GEFORCE_7800GT;
-                }
-
-                /* Geforce7 midend */
-                if (strstr(gl_renderer, "7600")
-                        || strstr(gl_renderer, "7700"))
-                {
-                    *vidmem = 256; /* The 7600 uses 256-512MB */
-                    return CARD_NVIDIA_GEFORCE_7600;
-                }
-
-                /* Geforce7 lower medium */
-                if (strstr(gl_renderer, "7400"))
-                {
-                    *vidmem = 256; /* The 7400 uses 256-512MB */
-                    return CARD_NVIDIA_GEFORCE_7400;
-                }
-
-                /* Geforce7 lowend */
-                if (strstr(gl_renderer, "7300"))
-                {
-                    *vidmem = 256; /* Mac Pros with this card have 256 MB */
-                    return CARD_NVIDIA_GEFORCE_7300;
-                }
-
-                /* Geforce6 highend */
-                if (strstr(gl_renderer, "6800"))
-                {
-                    *vidmem = 128; /* The 6800 uses 128-256MB, the 7600 uses 256-512MB */
-                    return CARD_NVIDIA_GEFORCE_6800;
-                }
-
-                /* Geforce6 - midend */
-                if (strstr(gl_renderer, "6600")
-                        || strstr(gl_renderer, "6610")
-                        || strstr(gl_renderer, "6700"))
-                {
-                    *vidmem = 128; /* A 6600GT has 128-256MB */
-                    return CARD_NVIDIA_GEFORCE_6600GT;
-                }
-
-                /* Geforce6/7 lowend */
-                *vidmem = 64; /* */
-                return CARD_NVIDIA_GEFORCE_6200; /* Geforce 6100/6150/6200/7300/7400/7500 */
-            }
-
-            if (WINE_D3D9_CAPABLE(gl_info))
-            {
-                /* GeforceFX - highend */
-                if (strstr(gl_renderer, "5800")
-                        || strstr(gl_renderer, "5900")
-                        || strstr(gl_renderer, "5950")
-                        || strstr(gl_renderer, "Quadro FX"))
-                {
-                    *vidmem = 256; /* 5800-5900 cards use 256MB */
-                    return CARD_NVIDIA_GEFORCEFX_5800;
-                }
-
-                /* GeforceFX - midend */
-                if (strstr(gl_renderer, "5600")
-                        || strstr(gl_renderer, "5650")
-                        || strstr(gl_renderer, "5700")
-                        || strstr(gl_renderer, "5750"))
-                {
-                    *vidmem = 128; /* A 5600 uses 128-256MB */
-                    return CARD_NVIDIA_GEFORCEFX_5600;
-                }
-
-                /* GeforceFX - lowend */
-                *vidmem = 64; /* Normal FX5200 cards use 64-256MB; laptop (non-standard) can have less */
-                return CARD_NVIDIA_GEFORCEFX_5200; /* GeforceFX 5100/5200/5250/5300/5500 */
-            }
-
-            if (WINE_D3D8_CAPABLE(gl_info))
-            {
-                if (strstr(gl_renderer, "GeForce4 Ti") || strstr(gl_renderer, "Quadro4"))
-                {
-                    *vidmem = 64; /* Geforce4 Ti cards have 64-128MB */
-                    return CARD_NVIDIA_GEFORCE4_TI4200; /* Geforce4 Ti4200/Ti4400/Ti4600/Ti4800, Quadro4 */
-                }
-
-                *vidmem = 64; /* Geforce3 cards have 64-128MB */
-                return CARD_NVIDIA_GEFORCE3; /* Geforce3 standard/Ti200/Ti500, Quadro DCC */
-            }
-
-            if (WINE_D3D7_CAPABLE(gl_info))
-            {
-                if (strstr(gl_renderer, "GeForce4 MX"))
-                {
-                    /* Most Geforce4MX GPUs have at least 64MB of memory, some
-                     * early models had 32MB but most have 64MB or even 128MB. */
-                    *vidmem = 64;
-                    return CARD_NVIDIA_GEFORCE4_MX; /* MX420/MX440/MX460/MX4000 */
-                }
-
-                if (strstr(gl_renderer, "GeForce2 MX") || strstr(gl_renderer, "Quadro2 MXR"))
-                {
-                    *vidmem = 32; /* Geforce2MX GPUs have 32-64MB of video memory */
-                    return CARD_NVIDIA_GEFORCE2_MX; /* Geforce2 standard/MX100/MX200/MX400, Quadro2 MXR */
-                }
-
-                if (strstr(gl_renderer, "GeForce2") || strstr(gl_renderer, "Quadro2"))
-                {
-                    *vidmem = 32; /* Geforce2 GPUs have 32-64MB of video memory */
-                    return CARD_NVIDIA_GEFORCE2; /* Geforce2 GTS/Pro/Ti/Ultra, Quadro2 */
-                }
-
-                /* Most Geforce1 cards have 32MB, there are also some rare 16
-                 * and 64MB (Dell) models. */
-                *vidmem = 32;
-                return CARD_NVIDIA_GEFORCE; /* Geforce 256/DDR, Quadro */
-            }
-
-            if (strstr(gl_renderer, "TNT2"))
-            {
-                *vidmem = 32; /* Most TNT2 boards have 32MB, though there are 16MB boards too */
-                return CARD_NVIDIA_RIVA_TNT2; /* Riva TNT2 standard/M64/Pro/Ultra */
-            }
-
-            *vidmem = 16; /* Most TNT boards have 16MB, some rare models have 8MB */
-            return CARD_NVIDIA_RIVA_TNT; /* Riva TNT, Vanta */
-
-        case VENDOR_ATI:
-            /* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx
-             *
-             * Beware: renderer string do not match exact card model,
-             * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */
-            if (WINE_D3D9_CAPABLE(gl_info))
-            {
-                /* Radeon EG CYPRESS XT / PRO HD5800 - highend */
-                if (strstr(gl_renderer, "HD 5800")          /* Radeon EG CYPRESS HD58xx generic renderer string */
-                        || strstr(gl_renderer, "HD 5850")   /* Radeon EG CYPRESS XT */
-                        || strstr(gl_renderer, "HD 5870"))  /* Radeon EG CYPRESS PRO */
-                {
-                    *vidmem = 1024; /* note: HD58xx cards use 1024MB  */
-                    return CARD_ATI_RADEON_HD5800;
-                }
-
-                /* Radeon EG JUNIPER XT / LE HD5700 - midend */
-                if (strstr(gl_renderer, "HD 5700")          /* Radeon EG JUNIPER HD57xx generic renderer string */
-                        || strstr(gl_renderer, "HD 5750")   /* Radeon EG JUNIPER LE */
-                        || strstr(gl_renderer, "HD 5770"))  /* Radeon EG JUNIPER XT */
-                {
-                    *vidmem = 512; /* note: HD5770 cards use 1024MB and HD5750 cards use 512MB or 1024MB  */
-                    return CARD_ATI_RADEON_HD5700;
-                }
-
-                /* Radeon R7xx HD4800 - highend */
-                if (strstr(gl_renderer, "HD 4800")          /* Radeon RV7xx HD48xx generic renderer string */
-                        || strstr(gl_renderer, "HD 4830")   /* Radeon RV770 */
-                        || strstr(gl_renderer, "HD 4850")   /* Radeon RV770 */
-                        || strstr(gl_renderer, "HD 4870")   /* Radeon RV770 */
-                        || strstr(gl_renderer, "HD 4890"))  /* Radeon RV790 */
-                {
-                    *vidmem = 512; /* note: HD4890 cards use 1024MB */
-                    return CARD_ATI_RADEON_HD4800;
-                }
-
-                /* Radeon R740 HD4700 - midend */
-                if (strstr(gl_renderer, "HD 4700")          /* Radeon RV770 */
-                        || strstr(gl_renderer, "HD 4770"))  /* Radeon RV740 */
-                {
-                    *vidmem = 512;
-                    return CARD_ATI_RADEON_HD4700;
-                }
-
-                /* Radeon R730 HD4600 - midend */
-                if (strstr(gl_renderer, "HD 4600")          /* Radeon RV730 */
-                        || strstr(gl_renderer, "HD 4650")   /* Radeon RV730 */
-                        || strstr(gl_renderer, "HD 4670"))  /* Radeon RV730 */
-                {
-                    *vidmem = 512;
-                    return CARD_ATI_RADEON_HD4600;
-                }
-
-                /* Radeon R710 HD4500/HD4350 - lowend */
-                if (strstr(gl_renderer, "HD 4350")          /* Radeon RV710 */
-                        || strstr(gl_renderer, "HD 4550"))  /* Radeon RV710 */
-                {
-                    *vidmem = 256;
-                    return CARD_ATI_RADEON_HD4350;
-                }
-
-                /* Radeon R6xx HD2900/HD3800 - highend */
-                if (strstr(gl_renderer, "HD 2900")
-                        || strstr(gl_renderer, "HD 3870")
-                        || strstr(gl_renderer, "HD 3850"))
-                {
-                    *vidmem = 512; /* HD2900/HD3800 uses 256-1024MB */
-                    return CARD_ATI_RADEON_HD2900;
-                }
-
-                /* Radeon R6xx HD2600/HD3600 - midend; HD3830 is China-only midend */
-                if (strstr(gl_renderer, "HD 2600")
-                        || strstr(gl_renderer, "HD 3830")
-                        || strstr(gl_renderer, "HD 3690")
-                        || strstr(gl_renderer, "HD 3650"))
-                {
-                    *vidmem = 256; /* HD2600/HD3600 uses 256-512MB */
-                    return CARD_ATI_RADEON_HD2600;
-                }
-
-                /* Radeon R6xx HD2300/HD2400/HD3400 - lowend */
-                if (strstr(gl_renderer, "HD 2300")
-                        || strstr(gl_renderer, "HD 2400")
-                        || strstr(gl_renderer, "HD 3470")
-                        || strstr(gl_renderer, "HD 3450")
-                        || strstr(gl_renderer, "HD 3430")
-                        || strstr(gl_renderer, "HD 3400"))
-                {
-                    *vidmem = 128; /* HD2300 uses at least 128MB, HD2400 uses 256MB */
-                    return CARD_ATI_RADEON_HD2300;
-                }
-
-                /* Radeon R6xx/R7xx integrated */
-                if (strstr(gl_renderer, "HD 3100")
-                        || strstr(gl_renderer, "HD 3200")
-                        || strstr(gl_renderer, "HD 3300"))
-                {
-                    *vidmem = 128; /* 128MB */
-                    return CARD_ATI_RADEON_HD3200;
-                }
-
-                /* Radeon R5xx */
-                if (strstr(gl_renderer, "X1600")
-                        || strstr(gl_renderer, "X1650")
-                        || strstr(gl_renderer, "X1800")
-                        || strstr(gl_renderer, "X1900")
-                        || strstr(gl_renderer, "X1950"))
-                {
-                    *vidmem = 128; /* X1600 uses 128-256MB, >=X1800 uses 256MB */
-                    return CARD_ATI_RADEON_X1600;
-                }
-
-                /* Radeon R4xx + X1300/X1400/X1450/X1550/X2300 (lowend R5xx) */
-                if (strstr(gl_renderer, "X700")
-                        || strstr(gl_renderer, "X800")
-                        || strstr(gl_renderer, "X850")
-                        || strstr(gl_renderer, "X1300")
-                        || strstr(gl_renderer, "X1400")
-                        || strstr(gl_renderer, "X1450")
-                        || strstr(gl_renderer, "X1550"))
-                {
-                    *vidmem = 128; /* x700/x8*0 use 128-256MB, >=x1300 128-512MB */
-                    return CARD_ATI_RADEON_X700;
-                }
-
-                /* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400MHz */
-                if (strstr(gl_renderer, "Radeon Xpress"))
-                {
-                    *vidmem = 64; /* Shared RAM, BIOS configurable, 64-256M */
-                    return CARD_ATI_RADEON_XPRESS_200M;
-                }
-
-                /* Radeon R3xx */
-                *vidmem = 64; /* Radeon 9500 uses 64MB, higher models use up to 256MB */
-                return CARD_ATI_RADEON_9500; /* Radeon 9500/9550/9600/9700/9800/X300/X550/X600 */
-            }
-
-            if (WINE_D3D8_CAPABLE(gl_info))
-            {
-                *vidmem = 64; /* 8500/9000 cards use mostly 64MB, though there are 32MB and 128MB models */
-                return CARD_ATI_RADEON_8500; /* Radeon 8500/9000/9100/9200/9300 */
-            }
-
-            if (WINE_D3D7_CAPABLE(gl_info))
-            {
-                *vidmem = 32; /* There are models with up to 64MB */
-                return CARD_ATI_RADEON_7200; /* Radeon 7000/7100/7200/7500 */
-            }
-
-            *vidmem = 16; /* There are 16-32MB models */
-            return CARD_ATI_RAGE_128PRO;
-
-        case VENDOR_INTEL:
-            if (strstr(gl_renderer, "X3100"))
-            {
-                /* MacOS calls the card GMA X3100, Google findings also suggest the name GM965 */
-                *vidmem = 128;
-                return CARD_INTEL_X3100;
-            }
-
-            if (strstr(gl_renderer, "GMA 950") || strstr(gl_renderer, "945GM"))
-            {
-                /* MacOS calls the card GMA 950, but everywhere else the PCI ID is named 945GM */
-                *vidmem = 64;
-                return CARD_INTEL_I945GM;
-            }
-
-            if (strstr(gl_renderer, "915GM")) return CARD_INTEL_I915GM;
-            if (strstr(gl_renderer, "915G")) return CARD_INTEL_I915G;
-            if (strstr(gl_renderer, "865G")) return CARD_INTEL_I865G;
-            if (strstr(gl_renderer, "855G")) return CARD_INTEL_I855G;
-            if (strstr(gl_renderer, "830G")) return CARD_INTEL_I830G;
-            return CARD_INTEL_I915G;
-
-        case VENDOR_MESA:
-        case VENDOR_WINE:
-        default:
-            /* Default to generic Nvidia hardware based on the supported OpenGL extensions. The choice
-             * for Nvidia was because the hardware and drivers they make are of good quality. This makes
-             * them a good generic choice. */
-            *vendor = VENDOR_NVIDIA;
-            if (WINE_D3D9_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCEFX_5600;
-            if (WINE_D3D8_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE3;
-            if (WINE_D3D7_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE;
-            if (WINE_D3D6_CAPABLE(gl_info)) return CARD_NVIDIA_RIVA_TNT;
-            return CARD_NVIDIA_RIVA_128;
-    }
+    int i;
+
+    for (i = 0; i < (sizeof(vendor_card_select_table) / sizeof(*vendor_card_select_table)); ++i)
+    {
+        if ((vendor_card_select_table[i].gl_vendor != *gl_vendor)
+            || (vendor_card_select_table[i].card_vendor != *card_vendor))
+                continue;
+        TRACE_(d3d_caps)("Applying card_selector \"%s\".\n", vendor_card_select_table[i].description);
+        return vendor_card_select_table[i].select_card(gl_info, gl_renderer, vidmem);
+    }
+
+    FIXME_(d3d_caps)("No card selector available for GL vendor %d and card vendor %04x.\n",
+                     *gl_vendor, *card_vendor);
+
+    /* Default to generic Nvidia hardware based on the supported OpenGL extensions. The choice
+     * for Nvidia was because the hardware and drivers they make are of good quality. This makes
+     * them a good generic choice. */
+    *card_vendor = HW_VENDOR_NVIDIA;
+    if (WINE_D3D9_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCEFX_5600;
+    if (WINE_D3D8_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE3;
+    if (WINE_D3D7_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE;
+    if (WINE_D3D6_CAPABLE(gl_info)) return CARD_NVIDIA_RIVA_TNT;
+    return CARD_NVIDIA_RIVA_128;
+}
+
+static const struct fragment_pipeline *select_fragment_implementation(struct wined3d_adapter *adapter)
+{
+    const struct wined3d_gl_info *gl_info = &adapter->gl_info;
+    int vs_selected_mode, ps_selected_mode;
+
+    select_shader_mode(gl_info, &ps_selected_mode, &vs_selected_mode);
+    if ((ps_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_GLSL)
+            && gl_info->supported[ARB_FRAGMENT_PROGRAM]) return &arbfp_fragment_pipeline;
+    else if (ps_selected_mode == SHADER_ATI) return &atifs_fragment_pipeline;
+    else if (gl_info->supported[NV_REGISTER_COMBINERS]
+            && gl_info->supported[NV_TEXTURE_SHADER2]) return &nvts_fragment_pipeline;
+    else if (gl_info->supported[NV_REGISTER_COMBINERS]) return &nvrc_fragment_pipeline;
+    else return &ffp_fragment_pipeline;
+}
+
+static const shader_backend_t *select_shader_backend(struct wined3d_adapter *adapter)
+{
+    int vs_selected_mode, ps_selected_mode;
+
+    select_shader_mode(&adapter->gl_info, &ps_selected_mode, &vs_selected_mode);
+    if (vs_selected_mode == SHADER_GLSL || ps_selected_mode == SHADER_GLSL) return &glsl_shader_backend;
+    if (vs_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_ARB) return &arb_program_shader_backend;
+    return &none_shader_backend;
+}
+
+static const struct blit_shader *select_blit_implementation(struct wined3d_adapter *adapter)
+{
+    const struct wined3d_gl_info *gl_info = &adapter->gl_info;
+    int vs_selected_mode, ps_selected_mode;
+
+    select_shader_mode(gl_info, &ps_selected_mode, &vs_selected_mode);
+    if ((ps_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_GLSL)
+            && gl_info->supported[ARB_FRAGMENT_PROGRAM]) return &arbfp_blit;
+    else return &ffp_blit;
 }
 
 /* Context activation is done by the caller. */
-static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_driver_info *driver_info, struct wined3d_gl_info *gl_info)
-{
+static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_adapter *adapter)
+{
+    struct wined3d_driver_info *driver_info = &adapter->driver_info;
+    struct wined3d_gl_info *gl_info = &adapter->gl_info;
     const char *GL_Extensions    = NULL;
     const char *WGL_Extensions   = NULL;
-    const char *gl_string        = NULL;
-    enum wined3d_pci_vendor vendor;
+    const char *gl_vendor_str, *gl_renderer_str, *gl_version_str;
+    struct fragment_caps fragment_caps;
+    enum wined3d_gl_vendor gl_vendor;
+    enum wined3d_pci_vendor card_vendor;
     enum wined3d_pci_device device;
     GLint       gl_max;
@@ -1646,5 +2090,4 @@
     HDC         hdc;
     unsigned int vidmem=0;
-    char *gl_renderer;
     DWORD gl_version;
     size_t len;
@@ -1654,7 +2097,7 @@
     ENTER_GL();
 
-    gl_string = (const char *)glGetString(GL_RENDERER);
-    TRACE_(d3d_caps)("GL_RENDERER: %s.\n", debugstr_a(gl_string));
-    if (!gl_string)
+    gl_renderer_str = (const char *)glGetString(GL_RENDERER);
+    TRACE_(d3d_caps)("GL_RENDERER: %s.\n", debugstr_a(gl_renderer_str));
+    if (!gl_renderer_str)
     {
         LEAVE_GL();
@@ -1663,37 +2106,23 @@
     }
 
-    len = strlen(gl_string) + 1;
-    gl_renderer = HeapAlloc(GetProcessHeap(), 0, len);
-    if (!gl_renderer)
-    {
-        LEAVE_GL();
-        ERR_(d3d_caps)("Failed to allocate gl_renderer memory.\n");
-        return FALSE;
-    }
-    memcpy(gl_renderer, gl_string, len);
-
-    gl_string = (const char *)glGetString(GL_VENDOR);
-    TRACE_(d3d_caps)("GL_VENDOR: %s.\n", debugstr_a(gl_string));
-    if (!gl_string)
+    gl_vendor_str = (const char *)glGetString(GL_VENDOR);
+    TRACE_(d3d_caps)("GL_VENDOR: %s.\n", debugstr_a(gl_vendor_str));
+    if (!gl_vendor_str)
     {
         LEAVE_GL();
         ERR_(d3d_caps)("Received a NULL GL_VENDOR.\n");
-        HeapFree(GetProcessHeap(), 0, gl_renderer);
         return FALSE;
     }
-    vendor = wined3d_guess_vendor(gl_string, gl_renderer);
-    TRACE_(d3d_caps)("found GL_VENDOR (%s)->(0x%04x)\n", debugstr_a(gl_string), vendor);
 
     /* Parse the GL_VERSION field into major and minor information */
-    gl_string = (const char *)glGetString(GL_VERSION);
-    TRACE_(d3d_caps)("GL_VERSION: %s.\n", debugstr_a(gl_string));
-    if (!gl_string)
+    gl_version_str = (const char *)glGetString(GL_VERSION);
+    TRACE_(d3d_caps)("GL_VERSION: %s.\n", debugstr_a(gl_version_str));
+    if (!gl_version_str)
     {
         LEAVE_GL();
         ERR_(d3d_caps)("Received a NULL GL_VERSION.\n");
-        HeapFree(GetProcessHeap(), 0, gl_renderer);
         return FALSE;
     }
-    gl_version = wined3d_parse_gl_version(gl_string);
+    gl_version = wined3d_parse_gl_version(gl_version_str);
 
     /*
@@ -1702,7 +2131,7 @@
      */
     memset(gl_info->supported, 0, sizeof(gl_info->supported));
+    gl_info->limits.blends = 1;
     gl_info->limits.buffers = 1;
     gl_info->limits.textures = 1;
-    gl_info->limits.texture_stages = 1;
     gl_info->limits.fragment_samplers = 1;
     gl_info->limits.vertex_samplers = 0;
@@ -1744,5 +2173,4 @@
         LEAVE_GL();
         ERR_(d3d_caps)("Received a NULL GL_EXTENSIONS.\n");
-        HeapFree(GetProcessHeap(), 0, gl_renderer);
         return FALSE;
     }
@@ -1841,4 +2269,10 @@
         }
     }
+    if (gl_info->supported[ARB_MAP_BUFFER_RANGE])
+    {
+        /* GL_ARB_map_buffer_range and GL_APPLE_flush_buffer_range provide the same
+         * functionality. Prefer the ARB extension */
+        gl_info->supported[APPLE_FLUSH_BUFFER_RANGE] = FALSE;
+    }
     if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
     {
@@ -1850,4 +2284,9 @@
         TRACE_(d3d_caps)(" IMPLIED: ARB_depth_clamp support (by NV_depth_clamp).\n");
         gl_info->supported[ARB_DEPTH_CLAMP] = TRUE;
+    }
+    if (!gl_info->supported[ARB_VERTEX_ARRAY_BGRA] && gl_info->supported[EXT_VERTEX_ARRAY_BGRA])
+    {
+        TRACE_(d3d_caps)(" IMPLIED: ARB_vertex_array_bgra support (by EXT_vertex_array_bgra).\n");
+        gl_info->supported[ARB_VERTEX_ARRAY_BGRA] = TRUE;
     }
     if (gl_info->supported[NV_TEXTURE_SHADER2])
@@ -1861,4 +2300,11 @@
         }
     }
+
+    if (gl_info->supported[NV_REGISTER_COMBINERS])
+    {
+        glGetIntegerv(GL_MAX_GENERAL_COMBINERS_NV, &gl_max);
+        gl_info->limits.general_combiners = gl_max;
+        TRACE_(d3d_caps)("Max general combiners: %d.\n", gl_max);
+    }
     if (gl_info->supported[ARB_DRAW_BUFFERS])
     {
@@ -1872,16 +2318,4 @@
         gl_info->limits.textures = min(MAX_TEXTURES, gl_max);
         TRACE_(d3d_caps)("Max textures: %d.\n", gl_info->limits.textures);
-
-        if (gl_info->supported[NV_REGISTER_COMBINERS])
-        {
-            GLint tmp;
-            glGetIntegerv(GL_MAX_GENERAL_COMBINERS_NV, &tmp);
-            gl_info->limits.texture_stages = min(MAX_TEXTURES, tmp);
-        }
-        else
-        {
-            gl_info->limits.texture_stages = min(MAX_TEXTURES, gl_max);
-        }
-        TRACE_(d3d_caps)("Max texture stages: %d.\n", gl_info->limits.texture_stages);
 
         if (gl_info->supported[ARB_FRAGMENT_PROGRAM])
@@ -2008,4 +2442,15 @@
         TRACE_(d3d_caps)("Max GLSL varyings: %u (%u 4 component varyings).\n", gl_max, gl_max / 4);
     }
+    if (gl_info->supported[ARB_SHADING_LANGUAGE_100])
+    {
+        const char *str = (const char *)glGetString(GL_SHADING_LANGUAGE_VERSION_ARB);
+        unsigned int major, minor;
+
+        TRACE_(d3d_caps)("GLSL version string: %s.\n", debugstr_a(str));
+
+        /* The format of the GLSL version string is "major.minor[.release] [vendor info]". */
+        sscanf(str, "%u.%u", &major, &minor);
+        gl_info->glsl_version = MAKEDWORD_VERSION(major, minor);
+    }
     if (gl_info->supported[NV_LIGHT_MAX_EXPONENT])
     {
@@ -2034,5 +2479,4 @@
         gl_info->supported[NV_TEXTURE_SHADER] = FALSE;
         gl_info->supported[NV_TEXTURE_SHADER2] = FALSE;
-        gl_info->supported[NV_TEXTURE_SHADER3] = FALSE;
     }
     if (gl_info->supported[NV_HALF_FLOAT])
@@ -2052,4 +2496,12 @@
 
     LEAVE_GL();
+
+    adapter->fragment_pipe = select_fragment_implementation(adapter);
+    adapter->shader_backend = select_shader_backend(adapter);
+    adapter->blitter = select_blit_implementation(adapter);
+
+    adapter->fragment_pipe->get_caps(gl_info, &fragment_caps);
+    gl_info->limits.texture_stages = fragment_caps.MaxTextureBlendStages;
+    TRACE_(d3d_caps)("Max texture stages: %u.\n", gl_info->limits.texture_stages);
 
     /* In some cases the number of texture stages can be larger than the number
@@ -2123,6 +2575,10 @@
     }
 
-    device = wined3d_guess_card(gl_info, gl_renderer, &vendor, &vidmem);
-    TRACE_(d3d_caps)("FOUND (fake) card: 0x%x (vendor id), 0x%x (device id)\n", vendor, device);
+    gl_vendor = wined3d_guess_gl_vendor(gl_info, gl_vendor_str, gl_renderer_str);
+    card_vendor = wined3d_guess_card_vendor(gl_vendor_str, gl_renderer_str);
+    TRACE_(d3d_caps)("found GL_VENDOR (%s)->(0x%04x/0x%04x)\n", debugstr_a(gl_vendor_str), gl_vendor, card_vendor);
+
+    device = wined3d_guess_card(gl_info, gl_renderer_str, &gl_vendor, &card_vendor, &vidmem);
+    TRACE_(d3d_caps)("FOUND (fake) card: 0x%x (vendor id), 0x%x (device id)\n", card_vendor, device);
 
     /* If we have an estimate use it, else default to 64MB;  */
@@ -2170,8 +2626,4 @@
                 TRACE_(d3d_caps)("- %s\n", debugstr_a(ThisExtn));
 
-                if (!strcmp(ThisExtn, "WGL_ARB_pbuffer")) {
-                    gl_info->supported[WGL_ARB_PBUFFER] = TRUE;
-                    TRACE_(d3d_caps)("FOUND: WGL_ARB_pbuffer support\n");
-                }
                 if (!strcmp(ThisExtn, "WGL_ARB_pixel_format")) {
                     gl_info->supported[WGL_ARB_PIXEL_FORMAT] = TRUE;
@@ -2186,9 +2638,8 @@
     }
 
-    fixup_extensions(gl_info, gl_renderer, vendor, device);
-    init_driver_info(driver_info, vendor, device);
+    fixup_extensions(gl_info, gl_renderer_str, gl_vendor, card_vendor, device);
+    init_driver_info(driver_info, card_vendor, device);
     add_gl_compat_wrappers(gl_info);
 
-    HeapFree(GetProcessHeap(), 0, gl_renderer);
     return TRUE;
 }
@@ -2239,5 +2690,5 @@
     /* TODO: Store modes per adapter and read it from the adapter structure */
     if (Adapter == 0) { /* Display */
-        const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(Format, &This->adapters[Adapter].gl_info);
+        const struct wined3d_format_desc *format_desc = getFormatDescEntry(Format, &This->adapters[Adapter].gl_info);
         UINT format_bits = format_desc->byte_count * CHAR_BIT;
         unsigned int i = 0;
@@ -2286,5 +2737,5 @@
     if (Adapter == 0)
     {
-        const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(Format, &This->adapters[Adapter].gl_info);
+        const struct wined3d_format_desc *format_desc = getFormatDescEntry(Format, &This->adapters[Adapter].gl_info);
         UINT format_bits = format_desc->byte_count * CHAR_BIT;
         DEVMODEW DevModeW;
@@ -2451,5 +2902,5 @@
 
 static BOOL IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(const struct wined3d_gl_info *gl_info,
-        const WineD3D_PixelFormat *cfg, const struct GlPixelFormatDesc *format_desc)
+        const WineD3D_PixelFormat *cfg, const struct wined3d_format_desc *format_desc)
 {
     short redSize, greenSize, blueSize, alphaSize, colorBits;
@@ -2458,4 +2909,7 @@
         return FALSE;
 
+    /* Float formats need FBOs. If FBOs are used this function isn't called */
+    if (format_desc->Flags & WINED3DFMT_FLAG_FLOAT) return FALSE;
+
     if(cfg->iPixelType == WGL_TYPE_RGBA_ARB) { /* Integer RGBA formats */
         if (!getColorBits(format_desc, &redSize, &greenSize, &blueSize, &alphaSize, &colorBits))
@@ -2478,27 +2932,12 @@
 
         return TRUE;
-    } else if(cfg->iPixelType == WGL_TYPE_RGBA_FLOAT_ARB) { /* Float RGBA formats; TODO: WGL_NV_float_buffer */
-        if (format_desc->format == WINED3DFMT_R16_FLOAT)
-            return (cfg->redSize == 16 && cfg->greenSize == 0 && cfg->blueSize == 0 && cfg->alphaSize == 0);
-        if (format_desc->format == WINED3DFMT_R16G16_FLOAT)
-            return (cfg->redSize == 16 && cfg->greenSize == 16 && cfg->blueSize == 0 && cfg->alphaSize == 0);
-        if (format_desc->format == WINED3DFMT_R16G16B16A16_FLOAT)
-            return (cfg->redSize == 16 && cfg->greenSize == 16 && cfg->blueSize == 16 && cfg->alphaSize == 16);
-        if (format_desc->format == WINED3DFMT_R32_FLOAT)
-            return (cfg->redSize == 32 && cfg->greenSize == 0 && cfg->blueSize == 0 && cfg->alphaSize == 0);
-        if (format_desc->format == WINED3DFMT_R32G32_FLOAT)
-            return (cfg->redSize == 32 && cfg->greenSize == 32 && cfg->blueSize == 0 && cfg->alphaSize == 0);
-        if (format_desc->format == WINED3DFMT_R32G32B32A32_FLOAT)
-            return (cfg->redSize == 32 && cfg->greenSize == 32 && cfg->blueSize == 32 && cfg->alphaSize == 32);
-    } else {
-        /* Probably a color index mode */
-        return FALSE;
-    }
-
+    }
+
+    /* Probably a RGBA_float or color index mode */
     return FALSE;
 }
 
 static BOOL IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt(const struct wined3d_gl_info *gl_info,
-        const WineD3D_PixelFormat *cfg, const struct GlPixelFormatDesc *format_desc)
+        const WineD3D_PixelFormat *cfg, const struct wined3d_format_desc *format_desc)
 {
     short depthSize, stencilSize;
@@ -2513,4 +2952,7 @@
         return FALSE;
     }
+
+    /* Float formats need FBOs. If FBOs are used this function isn't called */
+    if (format_desc->Flags & WINED3DFMT_FLAG_FLOAT) return FALSE;
 
     if ((format_desc->format == WINED3DFMT_D16_LOCKABLE) || (format_desc->format == WINED3DFMT_D32_FLOAT))
@@ -2539,6 +2981,6 @@
     const WineD3D_PixelFormat *cfgs;
     const struct wined3d_adapter *adapter;
-    const struct GlPixelFormatDesc *rt_format_desc;
-    const struct GlPixelFormatDesc *ds_format_desc;
+    const struct wined3d_format_desc *rt_format_desc;
+    const struct wined3d_format_desc *ds_format_desc;
     int it;
 
@@ -2558,13 +3000,24 @@
     rt_format_desc = getFormatDescEntry(RenderTargetFormat, &adapter->gl_info);
     ds_format_desc = getFormatDescEntry(DepthStencilFormat, &adapter->gl_info);
-    cfgs = adapter->cfgs;
-    nCfgs = adapter->nCfgs;
-    for (it = 0; it < nCfgs; ++it) {
-        if (IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(&adapter->gl_info, &cfgs[it], rt_format_desc))
-        {
-            if (IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt(&adapter->gl_info, &cfgs[it], ds_format_desc))
+    if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
+    {
+        if ((rt_format_desc->Flags & WINED3DFMT_FLAG_RENDERTARGET) &&
+            (ds_format_desc->Flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL))) {
+            TRACE_(d3d_caps)("(%p) : Formats matched\n", This);
+            return WINED3D_OK;
+        }
+    }
+    else
+    {
+        cfgs = adapter->cfgs;
+        nCfgs = adapter->nCfgs;
+        for (it = 0; it < nCfgs; ++it) {
+            if (IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(&adapter->gl_info, &cfgs[it], rt_format_desc))
             {
-                TRACE_(d3d_caps)("(%p) : Formats matched\n", This);
-                return WINED3D_OK;
+                if (IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt(&adapter->gl_info, &cfgs[it], ds_format_desc))
+                {
+                    TRACE_(d3d_caps)("(%p) : Formats matched\n", This);
+                    return WINED3D_OK;
+                }
             }
         }
@@ -2579,5 +3032,5 @@
 {
     IWineD3DImpl *This = (IWineD3DImpl *)iface;
-    const struct GlPixelFormatDesc *glDesc;
+    const struct wined3d_format_desc *glDesc;
     const struct wined3d_adapter *adapter;
 
@@ -2654,5 +3107,8 @@
             if(cfgs[i].blueSize != blueSize)
                 continue;
-            if(cfgs[i].alphaSize != alphaSize)
+            /* Not all drivers report alpha-less formats since they use 32-bit anyway, so accept alpha even if we didn't ask for it. */
+            if(alphaSize && cfgs[i].alphaSize != alphaSize)
+                continue;
+            if(cfgs[i].colorSize != (glDesc->byte_count << 3))
                 continue;
 
@@ -2756,8 +3212,6 @@
 /* Check if we support bumpmapping for a format */
 static BOOL CheckBumpMapCapability(struct wined3d_adapter *adapter,
-        WINED3DDEVTYPE DeviceType, const struct GlPixelFormatDesc *format_desc)
-{
-    const struct fragment_pipeline *fp;
-
+        WINED3DDEVTYPE DeviceType, const struct wined3d_format_desc *format_desc)
+{
     switch(format_desc->format)
     {
@@ -2770,6 +3224,5 @@
              * with the conversion. If we've got a GL extension giving native
              * support this will be an identity conversion. */
-            fp = select_fragment_implementation(adapter, DeviceType);
-            if (fp->color_fixup_supported(format_desc->color_fixup))
+            if (adapter->fragment_pipe->color_fixup_supported(format_desc->color_fixup))
             {
                 TRACE_(d3d_caps)("[OK]\n");
@@ -2787,5 +3240,5 @@
 /* Check if the given DisplayFormat + DepthStencilFormat combination is valid for the Adapter */
 static BOOL CheckDepthStencilCapability(struct wined3d_adapter *adapter,
-        const struct GlPixelFormatDesc *display_format_desc, const struct GlPixelFormatDesc *ds_format_desc)
+        const struct wined3d_format_desc *display_format_desc, const struct wined3d_format_desc *ds_format_desc)
 {
     int it=0;
@@ -2794,13 +3247,21 @@
     if (!(ds_format_desc->depth_size || ds_format_desc->stencil_size)) return FALSE;
 
-    /* Walk through all WGL pixel formats to find a match */
-    for (it = 0; it < adapter->nCfgs; ++it)
-    {
-        WineD3D_PixelFormat *cfg = &adapter->cfgs[it];
-        if (IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(&adapter->gl_info, cfg, display_format_desc))
-        {
-            if (IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt(&adapter->gl_info, cfg, ds_format_desc))
+    if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
+    {
+        /* With FBOs WGL limitations do not apply, but the format needs to be FBO attachable */
+        if (ds_format_desc->Flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)) return TRUE;
+    }
+    else
+    {
+        /* Walk through all WGL pixel formats to find a match */
+        for (it = 0; it < adapter->nCfgs; ++it)
+        {
+            WineD3D_PixelFormat *cfg = &adapter->cfgs[it];
+            if (IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(&adapter->gl_info, cfg, display_format_desc))
             {
-                return TRUE;
+                if (IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt(&adapter->gl_info, cfg, ds_format_desc))
+                {
+                    return TRUE;
+                }
             }
         }
@@ -2810,5 +3271,5 @@
 }
 
-static BOOL CheckFilterCapability(struct wined3d_adapter *adapter, const struct GlPixelFormatDesc *format_desc)
+static BOOL CheckFilterCapability(struct wined3d_adapter *adapter, const struct wined3d_format_desc *format_desc)
 {
     /* The flags entry of a format contains the filtering capability */
@@ -2820,9 +3281,8 @@
 /* Check the render target capabilities of a format */
 static BOOL CheckRenderTargetCapability(struct wined3d_adapter *adapter,
-        const struct GlPixelFormatDesc *adapter_format_desc, const struct GlPixelFormatDesc *check_format_desc)
+        const struct wined3d_format_desc *adapter_format_desc, const struct wined3d_format_desc *check_format_desc)
 {
     /* Filter out non-RT formats */
     if (!(check_format_desc->Flags & WINED3DFMT_FLAG_RENDERTARGET)) return FALSE;
-
     if(wined3d_settings.offscreen_rendering_mode == ORM_BACKBUFFER) {
         WineD3D_PixelFormat *cfgs = adapter->cfgs;
@@ -2853,21 +3313,7 @@
             }
         }
-    } else if(wined3d_settings.offscreen_rendering_mode == ORM_PBUFFER) {
-        /* We can probably use this function in FBO mode too on some drivers to get some basic indication of the capabilities. */
-        WineD3D_PixelFormat *cfgs = adapter->cfgs;
-        int it;
-
-        /* Check if there is a WGL pixel format matching the requirements, the pixel format should also be usable with pbuffers */
-        for (it = 0; it < adapter->nCfgs; ++it)
-        {
-            if (cfgs[it].pbufferDrawable && IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(&adapter->gl_info,
-                    &cfgs[it], check_format_desc))
-            {
-                TRACE_(d3d_caps)("iPixelFormat=%d is compatible with CheckFormat=%s\n",
-                        cfgs[it].iPixelFormat, debug_d3dformat(check_format_desc->format));
-                return TRUE;
-            }
-        }
-    } else if(wined3d_settings.offscreen_rendering_mode == ORM_FBO){
+    }
+    else if(wined3d_settings.offscreen_rendering_mode == ORM_FBO)
+    {
         /* For now return TRUE for FBOs until we have some proper checks.
          * Note that this function will only be called when the format is around for texturing. */
@@ -2877,5 +3323,5 @@
 }
 
-static BOOL CheckSrgbReadCapability(struct wined3d_adapter *adapter, const struct GlPixelFormatDesc *format_desc)
+static BOOL CheckSrgbReadCapability(struct wined3d_adapter *adapter, const struct wined3d_format_desc *format_desc)
 {
     const struct wined3d_gl_info *gl_info = &adapter->gl_info;
@@ -2911,5 +3357,5 @@
 
 static BOOL CheckSrgbWriteCapability(struct wined3d_adapter *adapter,
-        WINED3DDEVTYPE DeviceType, const struct GlPixelFormatDesc *format_desc)
+        WINED3DDEVTYPE DeviceType, const struct wined3d_format_desc *format_desc)
 {
     /* Only offer SRGB writing on X8R8G8B8/A8R8G8B8 when we use ARB or GLSL shaders as we are
@@ -2934,5 +3380,5 @@
 /* Check if a format support blending in combination with pixel shaders */
 static BOOL CheckPostPixelShaderBlendingCapability(struct wined3d_adapter *adapter,
-        const struct GlPixelFormatDesc *format_desc)
+        const struct wined3d_format_desc *format_desc)
 {
     /* The flags entry of a format contains the post pixel shader blending capability */
@@ -2942,5 +3388,5 @@
 }
 
-static BOOL CheckWrapAndMipCapability(struct wined3d_adapter *adapter, const struct GlPixelFormatDesc *format_desc)
+static BOOL CheckWrapAndMipCapability(struct wined3d_adapter *adapter, const struct wined3d_format_desc *format_desc)
 {
     /* OpenGL supports mipmapping on all formats basically. Wrapping is unsupported,
@@ -2958,9 +3404,7 @@
 /* Check if a texture format is supported on the given adapter */
 static BOOL CheckTextureCapability(struct wined3d_adapter *adapter,
-        WINED3DDEVTYPE DeviceType, const struct GlPixelFormatDesc *format_desc)
+        WINED3DDEVTYPE DeviceType, const struct wined3d_format_desc *format_desc)
 {
     const struct wined3d_gl_info *gl_info = &adapter->gl_info;
-    const shader_backend_t *shader_backend;
-    const struct fragment_pipeline *fp;
 
     switch (format_desc->format)
@@ -2991,10 +3435,10 @@
 
         /*****
-         *  supported: Palettized
+         *  Not supported: Palettized
+         *  Only some Geforce/Voodoo3/G400 cards offer 8-bit textures in case of <=Direct3D7.
+         *  Since it is not widely available, don't offer it. Further no Windows driver offers
+         *  WINED3DFMT_P8_UINT_A8_NORM, so don't offer it either.
          */
         case WINED3DFMT_P8_UINT:
-            TRACE_(d3d_caps)("[OK]\n");
-            return TRUE;
-        /* No Windows driver offers WINED3DFMT_P8_UINT_A8_UNORM, so don't offer it either */
         case WINED3DFMT_P8_UINT_A8_UNORM:
             return FALSE;
@@ -3040,6 +3484,5 @@
              * we've got a GL extension giving native support this will be an
              * identity conversion. */
-            shader_backend = select_shader_backend(adapter, DeviceType);
-            if (shader_backend->shader_color_fixup_supported(format_desc->color_fixup))
+            if (adapter->shader_backend->shader_color_fixup_supported(format_desc->color_fixup))
             {
                 TRACE_(d3d_caps)("[OK]\n");
@@ -3157,8 +3600,6 @@
                     || gl_info->supported[EXT_TEXTURE_COMPRESSION_RGTC])
             {
-                shader_backend = select_shader_backend(adapter, DeviceType);
-                fp = select_fragment_implementation(adapter, DeviceType);
-                if (shader_backend->shader_color_fixup_supported(format_desc->color_fixup)
-                        && fp->color_fixup_supported(format_desc->color_fixup))
+                if (adapter->shader_backend->shader_color_fixup_supported(format_desc->color_fixup)
+                        && adapter->fragment_pipe->color_fixup_supported(format_desc->color_fixup))
                 {
                     TRACE_(d3d_caps)("[OK]\n");
@@ -3193,9 +3634,9 @@
 }
 
-static BOOL CheckSurfaceCapability(struct wined3d_adapter *adapter, const struct GlPixelFormatDesc *adapter_format_desc,
-        WINED3DDEVTYPE DeviceType, const struct GlPixelFormatDesc *check_format_desc, WINED3DSURFTYPE SurfaceType)
-{
-    const struct blit_shader *blitter;
-
+static BOOL CheckSurfaceCapability(struct wined3d_adapter *adapter,
+        const struct wined3d_format_desc *adapter_format_desc,
+        WINED3DDEVTYPE DeviceType, const struct wined3d_format_desc *check_format_desc,
+        WINED3DSURFTYPE SurfaceType)
+{
     if(SurfaceType == SURFACE_GDI) {
         switch(check_format_desc->format)
@@ -3233,6 +3674,7 @@
 
     /* If opengl can't process the format natively, the blitter may be able to convert it */
-    blitter = select_blit_implementation(adapter, DeviceType);
-    if (blitter->color_fixup_supported(check_format_desc->color_fixup))
+    if (adapter->blitter->blit_supported(&adapter->gl_info, BLIT_OP_BLIT,
+                                         NULL, WINED3DPOOL_DEFAULT, 0, check_format_desc,
+                                         NULL, WINED3DPOOL_DEFAULT, 0, adapter_format_desc))
     {
         TRACE_(d3d_caps)("[OK]\n");
@@ -3245,5 +3687,6 @@
 }
 
-static BOOL CheckVertexTextureCapability(struct wined3d_adapter *adapter, const struct GlPixelFormatDesc *format_desc)
+static BOOL CheckVertexTextureCapability(struct wined3d_adapter *adapter,
+        const struct wined3d_format_desc *format_desc)
 {
     const struct wined3d_gl_info *gl_info = &adapter->gl_info;
@@ -3280,6 +3723,6 @@
     struct wined3d_adapter *adapter = &This->adapters[Adapter];
     const struct wined3d_gl_info *gl_info = &adapter->gl_info;
-    const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(CheckFormat, gl_info);
-    const struct GlPixelFormatDesc *adapter_format_desc = getFormatDescEntry(AdapterFormat, gl_info);
+    const struct wined3d_format_desc *format_desc = getFormatDescEntry(CheckFormat, gl_info);
+    const struct wined3d_format_desc *adapter_format_desc = getFormatDescEntry(AdapterFormat, gl_info);
     DWORD UsageCaps = 0;
 
@@ -3799,6 +4242,4 @@
     struct shader_caps shader_caps;
     struct fragment_caps fragment_caps;
-    const shader_backend_t *shader_backend;
-    const struct fragment_pipeline *frag_pipeline = NULL;
     DWORD ckey_caps, blit_caps, fx_caps;
 
@@ -3863,5 +4304,4 @@
                                     /* TODO:
                                         WINED3DPMISCCAPS_NULLREFERENCE
-                                        WINED3DPMISCCAPS_INDEPENDENTWRITEMASKS
                                         WINED3DPMISCCAPS_FOGANDSPECULARALPHA
                                         WINED3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS
@@ -3870,4 +4310,6 @@
     if (gl_info->supported[EXT_BLEND_EQUATION_SEPARATE] && gl_info->supported[EXT_BLEND_FUNC_SEPARATE])
         pCaps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_SEPARATEALPHABLEND;
+    if (gl_info->supported[EXT_DRAW_BUFFERS2])
+        pCaps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_INDEPENDENTWRITEMASKS;
 
     pCaps->RasterCaps              = WINED3DPRASTERCAPS_DITHER    |
@@ -4177,10 +4619,8 @@
 
     memset(&shader_caps, 0, sizeof(shader_caps));
-    shader_backend = select_shader_backend(adapter, DeviceType);
-    shader_backend->shader_get_caps(DeviceType, &adapter->gl_info, &shader_caps);
+    adapter->shader_backend->shader_get_caps(&adapter->gl_info, &shader_caps);
 
     memset(&fragment_caps, 0, sizeof(fragment_caps));
-    frag_pipeline = select_fragment_implementation(adapter, DeviceType);
-    frag_pipeline->get_caps(DeviceType, &adapter->gl_info, &fragment_caps);
+    adapter->fragment_pipe->get_caps(&adapter->gl_info, &fragment_caps);
 
     /* Add shader misc caps. Only some of them belong to the shader parts of the pipeline */
@@ -4620,5 +5060,5 @@
 }
 
-BOOL InitAdapters(IWineD3DImpl *This)
+static BOOL InitAdapters(IWineD3DImpl *This)
 {
     static HMODULE mod_gl;
@@ -4707,5 +5147,5 @@
         }
 
-        ret = IWineD3DImpl_FillGLCaps(&adapter->driver_info, &adapter->gl_info);
+        ret = IWineD3DImpl_FillGLCaps(adapter);
         if(!ret) {
             ERR("Failed to initialize gl caps for default adapter\n");
@@ -4739,6 +5179,6 @@
         {
             int attribute;
-            int attribs[10];
-            int values[10];
+            int attribs[11];
+            int values[11];
             int nAttribs = 0;
 
@@ -4752,4 +5192,5 @@
             attribs[nAttribs++] = WGL_BLUE_BITS_ARB;
             attribs[nAttribs++] = WGL_ALPHA_BITS_ARB;
+            attribs[nAttribs++] = WGL_COLOR_BITS_ARB;
             attribs[nAttribs++] = WGL_DEPTH_BITS_ARB;
             attribs[nAttribs++] = WGL_STENCIL_BITS_ARB;
@@ -4772,21 +5213,11 @@
                 cfgs->blueSize = values[2];
                 cfgs->alphaSize = values[3];
-                cfgs->depthSize = values[4];
-                cfgs->stencilSize = values[5];
-                cfgs->windowDrawable = values[6];
-                cfgs->iPixelType = values[7];
-                cfgs->doubleBuffer = values[8];
-                cfgs->auxBuffers = values[9];
-
-                cfgs->pbufferDrawable = FALSE;
-                /* Check for pbuffer support when it is around as
-                 * wglGetPixelFormatAttribiv fails for unknown attributes. */
-                if (gl_info->supported[WGL_ARB_PBUFFER])
-                {
-                    int attrib = WGL_DRAW_TO_PBUFFER_ARB;
-                    int value;
-                    if(GL_EXTCALL(wglGetPixelFormatAttribivARB(hdc, iPixelFormat, 0, 1, &attrib, &value)))
-                        cfgs->pbufferDrawable = value;
-                }
+                cfgs->colorSize = values[4];
+                cfgs->depthSize = values[5];
+                cfgs->stencilSize = values[6];
+                cfgs->windowDrawable = values[7];
+                cfgs->iPixelType = values[8];
+                cfgs->doubleBuffer = values[9];
+                cfgs->auxBuffers = values[10];
 
                 cfgs->numSamples = 0;
@@ -4804,5 +5235,9 @@
                 }
 
-                TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, depth=%d, stencil=%d, windowDrawable=%d, pbufferDrawable=%d\n", cfgs->iPixelFormat, cfgs->iPixelType, cfgs->doubleBuffer, cfgs->redSize, cfgs->greenSize, cfgs->blueSize, cfgs->alphaSize, cfgs->depthSize, cfgs->stencilSize, cfgs->windowDrawable, cfgs->pbufferDrawable);
+                TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
+                        "depth=%d, stencil=%d, samples=%d, windowDrawable=%d\n",
+                        cfgs->iPixelFormat, cfgs->iPixelType, cfgs->doubleBuffer,
+                        cfgs->redSize, cfgs->greenSize, cfgs->blueSize, cfgs->alphaSize,
+                        cfgs->depthSize, cfgs->stencilSize, cfgs->numSamples, cfgs->windowDrawable);
                 cfgs++;
             }
@@ -4838,7 +5273,7 @@
                 cfgs->blueSize = ppfd.cBlueBits;
                 cfgs->alphaSize = ppfd.cAlphaBits;
+                cfgs->colorSize = ppfd.cColorBits;
                 cfgs->depthSize = ppfd.cDepthBits;
                 cfgs->stencilSize = ppfd.cStencilBits;
-                cfgs->pbufferDrawable = 0;
                 cfgs->windowDrawable = (ppfd.dwFlags & PFD_DRAW_TO_WINDOW) ? 1 : 0;
                 cfgs->iPixelType = (ppfd.iPixelType == PFD_TYPE_RGBA) ? WGL_TYPE_RGBA_ARB : WGL_TYPE_COLORINDEX_ARB;
@@ -4847,5 +5282,9 @@
                 cfgs->numSamples = 0;
 
-                TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, depth=%d, stencil=%d, windowDrawable=%d, pbufferDrawable=%d\n", cfgs->iPixelFormat, cfgs->iPixelType, cfgs->doubleBuffer, cfgs->redSize, cfgs->greenSize, cfgs->blueSize, cfgs->alphaSize, cfgs->depthSize, cfgs->stencilSize, cfgs->windowDrawable, cfgs->pbufferDrawable);
+                TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
+                        "depth=%d, stencil=%d, windowDrawable=%d\n",
+                        cfgs->iPixelFormat, cfgs->iPixelType, cfgs->doubleBuffer,
+                        cfgs->redSize, cfgs->greenSize, cfgs->blueSize, cfgs->alphaSize,
+                        cfgs->depthSize, cfgs->stencilSize, cfgs->windowDrawable);
                 cfgs++;
                 adapter->nCfgs++;
@@ -4919,5 +5358,5 @@
  **********************************************************/
 
-const IWineD3DVtbl IWineD3D_Vtbl =
+static const struct IWineD3DVtbl IWineD3D_Vtbl =
 {
     /* IUnknown */
@@ -4949,2 +5388,22 @@
     wined3d_null_wined3d_object_destroyed,
 };
+
+HRESULT wined3d_init(IWineD3DImpl *wined3d, UINT version, IUnknown *parent)
+{
+    wined3d->lpVtbl = &IWineD3D_Vtbl;
+    wined3d->dxVersion = version;
+    wined3d->ref = 1;
+    wined3d->parent = parent;
+
+    if (!InitAdapters(wined3d))
+    {
+        WARN("Failed to initialize adapters.\n");
+        if (version > 7)
+        {
+            MESSAGE("Direct3D%u is not available without OpenGL.\n", version);
+            return E_FAIL;
+        }
+    }
+
+    return WINED3D_OK;
+}
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/drawprim.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/drawprim.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/drawprim.c	(revision 28475)
@@ -114,5 +114,4 @@
 
     /* Start drawing in GL */
-    VTRACE(("glBegin(%x)\n", glPrimType));
     glBegin(glPrimType);
 
@@ -238,11 +237,8 @@
 
             /* Indexed so work out the number of strides to skip */
-            if (idxSize == 2) {
-                VTRACE(("Idx for vertex %u = %u\n", vx_index, pIdxBufS[startIdx+vx_index]));
+            if (idxSize == 2)
                 SkipnStrides = pIdxBufS[startIdx + vx_index] + This->stateBlock->loadBaseVertexIndex;
-            } else {
-                VTRACE(("Idx for vertex %u = %u\n", vx_index, pIdxBufL[startIdx+vx_index]));
+            else
                 SkipnStrides = pIdxBufL[startIdx + vx_index] + This->stateBlock->loadBaseVertexIndex;
-            }
         }
 
@@ -346,5 +342,5 @@
             break;
         case WINED3DFMT_B8G8R8A8_UNORM:
-            if (gl_info->supported[EXT_VERTEX_ARRAY_BGRA])
+            if (gl_info->supported[ARB_VERTEX_ARRAY_BGRA])
             {
                 const DWORD *src = ptr;
@@ -463,5 +459,4 @@
 
     /* Start drawing in GL */
-    VTRACE(("glBegin(%x)\n", glPrimitiveType));
     glBegin(glPrimitiveType);
 
@@ -470,11 +465,8 @@
 
             /* Indexed so work out the number of strides to skip */
-            if (idxSize == 2) {
-                VTRACE(("Idx for vertex %d = %d\n", vx_index, pIdxBufS[startIdx+vx_index]));
+            if (idxSize == 2)
                 SkipnStrides = pIdxBufS[startIdx + vx_index] + stateblock->loadBaseVertexIndex;
-            } else {
-                VTRACE(("Idx for vertex %d = %d\n", vx_index, pIdxBufL[startIdx+vx_index]));
+            else
                 SkipnStrides = pIdxBufL[startIdx + vx_index] + stateblock->loadBaseVertexIndex;
-            }
         }
 
@@ -616,4 +608,10 @@
 
     context = context_acquire(This, This->render_targets[0], CTXUSAGE_DRAWPRIM);
+    if (!context->valid)
+    {
+        context_release(context);
+        WARN("Invalid context, skipping draw.\n");
+        return;
+    }
 
     if (This->stencilBufferTarget) {
@@ -702,4 +700,12 @@
     /* Finished updating the screen, restore lock */
     LEAVE_GL();
+
+    for(i = 0; i < This->num_buffer_queries; i++)
+    {
+        wined3d_event_query_issue(This->buffer_queries[i], This);
+    }
+
+    if (wined3d_settings.strict_draw_ordering) wglFlush(); /* Flush to ensure ordering across contexts. */
+
     context_release(context);
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/glsl_shader.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/glsl_shader.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/glsl_shader.c	(revision 28475)
@@ -167,4 +167,18 @@
 };
 
+static const char *debug_gl_shader_type(GLenum type)
+{
+    switch (type)
+    {
+#define WINED3D_TO_STR(u) case u: return #u
+        WINED3D_TO_STR(GL_VERTEX_SHADER_ARB);
+        WINED3D_TO_STR(GL_GEOMETRY_SHADER_ARB);
+        WINED3D_TO_STR(GL_FRAGMENT_SHADER_ARB);
+#undef WINED3D_TO_STR
+        default:
+            return wine_dbg_sprintf("UNKNOWN(%#x)", type);
+    }
+}
+
 /* Extract a line from the info log.
  * Note that this modifies the source string. */
@@ -247,4 +261,79 @@
         HeapFree(GetProcessHeap(), 0, infoLog);
     }
+}
+
+/* GL locking is done by the caller. */
+static void shader_glsl_dump_program_source(const struct wined3d_gl_info *gl_info, GLhandleARB program)
+{
+    GLint i, object_count, source_size;
+    GLhandleARB *objects;
+    char *source = NULL;
+
+    GL_EXTCALL(glGetObjectParameterivARB(program, GL_OBJECT_ATTACHED_OBJECTS_ARB, &object_count));
+    objects = HeapAlloc(GetProcessHeap(), 0, object_count * sizeof(*objects));
+    if (!objects)
+    {
+        ERR("Failed to allocate object array memory.\n");
+        return;
+    }
+
+    GL_EXTCALL(glGetAttachedObjectsARB(program, object_count, NULL, objects));
+    for (i = 0; i < object_count; ++i)
+    {
+        char *ptr, *line;
+        GLint tmp;
+
+        GL_EXTCALL(glGetObjectParameterivARB(objects[i], GL_OBJECT_SHADER_SOURCE_LENGTH_ARB, &tmp));
+
+        if (!source || source_size < tmp)
+        {
+            HeapFree(GetProcessHeap(), 0, source);
+
+            source = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, tmp);
+            if (!source)
+            {
+                ERR("Failed to allocate %d bytes for shader source.\n", tmp);
+                HeapFree(GetProcessHeap(), 0, objects);
+                return;
+            }
+            source_size = tmp;
+        }
+
+        FIXME("Object %u:\n", objects[i]);
+        GL_EXTCALL(glGetObjectParameterivARB(objects[i], GL_OBJECT_SUBTYPE_ARB, &tmp));
+        FIXME("    GL_OBJECT_SUBTYPE_ARB: %s.\n", debug_gl_shader_type(tmp));
+        GL_EXTCALL(glGetObjectParameterivARB(objects[i], GL_OBJECT_COMPILE_STATUS_ARB, &tmp));
+        FIXME("    GL_OBJECT_COMPILE_STATUS_ARB: %d.\n", tmp);
+        FIXME("\n");
+
+        ptr = source;
+        GL_EXTCALL(glGetShaderSourceARB(objects[i], source_size, NULL, source));
+        while ((line = get_info_log_line(&ptr))) FIXME("    %s\n", line);
+        FIXME("\n");
+    }
+
+    HeapFree(GetProcessHeap(), 0, source);
+    HeapFree(GetProcessHeap(), 0, objects);
+}
+
+/* GL locking is done by the caller. */
+static void shader_glsl_validate_link(const struct wined3d_gl_info *gl_info, GLhandleARB program)
+{
+    GLint tmp;
+
+    if (!TRACE_ON(d3d_shader) && !FIXME_ON(d3d_shader)) return;
+
+    GL_EXTCALL(glGetObjectParameterivARB(program, GL_OBJECT_TYPE_ARB, &tmp));
+    if (tmp == GL_PROGRAM_OBJECT_ARB)
+    {
+        GL_EXTCALL(glGetObjectParameterivARB(program, GL_OBJECT_LINK_STATUS_ARB, &tmp));
+        if (!tmp)
+        {
+            FIXME("Program %u link status invalid.\n", program);
+            shader_glsl_dump_program_source(gl_info, program);
+        }
+    }
+
+    print_glsl_info_log(gl_info, program);
 }
 
@@ -641,6 +730,6 @@
         char usePixelShader, char useVertexShader)
 {
-    IWineD3DDeviceImpl *device = ((IWineD3DSurfaceImpl *)context->surface)->resource.device;
     const struct wined3d_gl_info *gl_info = context->gl_info;
+    IWineD3DDeviceImpl *device = context->swapchain->device;
     IWineD3DStateBlockImpl* stateBlock = device->stateBlock;
     struct shader_glsl_priv *priv = device->shader_priv;
@@ -1093,4 +1182,6 @@
         }
     }
+
+    shader_addline(buffer, "const float FLT_MAX = 1e38;\n");
 
     /* Start the main program */
@@ -1205,6 +1296,5 @@
 
     IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
-    IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
-    const struct wined3d_gl_info *gl_info = &deviceImpl->adapter->gl_info;
+    const struct wined3d_gl_info *gl_info = ins->ctx->gl_info;
     char pshader = shader_is_pshader_version(This->baseShader.reg_maps.shader_version.type);
 
@@ -1563,5 +1653,6 @@
 }
 
-static void shader_glsl_get_sample_function(DWORD sampler_type, DWORD flags, glsl_sample_function_t *sample_function)
+static void shader_glsl_get_sample_function(const struct wined3d_gl_info *gl_info,
+        DWORD sampler_type, DWORD flags, glsl_sample_function_t *sample_function)
 {
     BOOL projected = flags & WINED3D_GLSL_SAMPLE_PROJECTED;
@@ -1575,7 +1666,19 @@
             if(lod) {
                 sample_function->name = projected ? "texture1DProjLod" : "texture1DLod";
-            } else  if(grad) {
-                sample_function->name = projected ? "texture1DProjGradARB" : "texture1DGradARB";
-            } else {
+            }
+            else  if (grad)
+            {
+                if (gl_info->supported[EXT_GPU_SHADER4])
+                    sample_function->name = projected ? "texture1DProjGrad" : "texture1DGrad";
+                else if (gl_info->supported[ARB_SHADER_TEXTURE_LOD])
+                    sample_function->name = projected ? "texture1DProjGradARB" : "texture1DGradARB";
+                else
+                {
+                    FIXME("Unsupported 1D grad function.\n");
+                    sample_function->name = "unsupported1DGrad";
+                }
+            }
+            else
+            {
                 sample_function->name = projected ? "texture1DProj" : "texture1D";
             }
@@ -1586,10 +1689,19 @@
                 if(lod) {
                     sample_function->name = projected ? "texture2DRectProjLod" : "texture2DRectLod";
-                } else  if(grad) {
-                    /* What good are texrect grad functions? I don't know, but GL_EXT_gpu_shader4 defines them.
-                    * There is no GL_ARB_shader_texture_lod spec yet, so I don't know if they're defined there
-                     */
-                    sample_function->name = projected ? "shadow2DRectProjGradARB" : "shadow2DRectGradARB";
-                } else {
+                }
+                else  if (grad)
+                {
+                    if (gl_info->supported[EXT_GPU_SHADER4])
+                        sample_function->name = projected ? "texture2DRectProjGrad" : "texture2DRectGrad";
+                    else if (gl_info->supported[ARB_SHADER_TEXTURE_LOD])
+                        sample_function->name = projected ? "texture2DRectProjGradARB" : "texture2DRectGradARB";
+                    else
+                    {
+                        FIXME("Unsupported RECT grad function.\n");
+                        sample_function->name = "unsupported2DRectGrad";
+                    }
+                }
+                else
+                {
                     sample_function->name = projected ? "texture2DRectProj" : "texture2DRect";
                 }
@@ -1597,7 +1709,19 @@
                 if(lod) {
                     sample_function->name = projected ? "texture2DProjLod" : "texture2DLod";
-                } else  if(grad) {
-                    sample_function->name = projected ? "texture2DProjGradARB" : "texture2DGradARB";
-                } else {
+                }
+                else  if (grad)
+                {
+                    if (gl_info->supported[EXT_GPU_SHADER4])
+                        sample_function->name = projected ? "texture2DProjGrad" : "texture2DGrad";
+                    else if (gl_info->supported[ARB_SHADER_TEXTURE_LOD])
+                        sample_function->name = projected ? "texture2DProjGradARB" : "texture2DGradARB";
+                    else
+                    {
+                        FIXME("Unsupported 2D grad function.\n");
+                        sample_function->name = "unsupported2DGrad";
+                    }
+                }
+                else
+                {
                     sample_function->name = projected ? "texture2DProj" : "texture2D";
                 }
@@ -1608,7 +1732,19 @@
             if(lod) {
                 sample_function->name = "textureCubeLod";
-            } else if(grad) {
-                sample_function->name = "textureCubeGradARB";
-            } else {
+            }
+            else if (grad)
+            {
+                if (gl_info->supported[EXT_GPU_SHADER4])
+                    sample_function->name = "textureCubeGrad";
+                else if (gl_info->supported[ARB_SHADER_TEXTURE_LOD])
+                    sample_function->name = "textureCubeGradARB";
+                else
+                {
+                    FIXME("Unsupported Cube grad function.\n");
+                    sample_function->name = "unsupportedCubeGrad";
+                }
+            }
+            else
+            {
                 sample_function->name = "textureCube";
             }
@@ -1618,7 +1754,19 @@
             if(lod) {
                 sample_function->name = projected ? "texture3DProjLod" : "texture3DLod";
-            } else  if(grad) {
-                sample_function->name = projected ? "texture3DProjGradARB" : "texture3DGradARB";
-            } else {
+            }
+            else  if (grad)
+            {
+                if (gl_info->supported[EXT_GPU_SHADER4])
+                    sample_function->name = projected ? "texture3DProjGrad" : "texture3DGrad";
+                else if (gl_info->supported[ARB_SHADER_TEXTURE_LOD])
+                    sample_function->name = projected ? "texture3DProjGradARB" : "texture3DGradARB";
+                else
+                {
+                    FIXME("Unsupported 3D grad function.\n");
+                    sample_function->name = "unsupported3DGrad";
+                }
+            }
+            else
+            {
                 sample_function->name = projected ? "texture3DProj" : "texture3D";
             }
@@ -1692,8 +1840,8 @@
     if (!mask) return; /* Nothing to do */
 
-    if (is_yuv_fixup(fixup))
-    {
-        enum yuv_fixup yuv_fixup = get_yuv_fixup(fixup);
-        FIXME("YUV fixup (%#x) not supported\n", yuv_fixup);
+    if (is_complex_fixup(fixup))
+    {
+        enum complex_fixup complex_fixup = get_complex_fixup(fixup);
+        FIXME("Complex fixup (%#x) not supported\n",complex_fixup);
         return;
     }
@@ -1833,4 +1981,5 @@
 static void shader_glsl_mov(const struct wined3d_shader_instruction *ins)
 {
+    const struct wined3d_gl_info *gl_info = ins->ctx->gl_info;
     struct wined3d_shader_buffer *buffer = ins->ctx->buffer;
     glsl_src_param_t src0_param;
@@ -1858,10 +2007,24 @@
         /* We need to *round* to the nearest int here. */
         unsigned int mask_size = shader_glsl_get_write_mask_size(write_mask);
-        if (mask_size > 1) {
-            shader_addline(buffer, "ivec%d(floor(abs(%s) + vec%d(0.5)) * sign(%s)));\n", mask_size, src0_param.param_str, mask_size, src0_param.param_str);
-        } else {
-            shader_addline(buffer, "int(floor(abs(%s) + 0.5) * sign(%s)));\n", src0_param.param_str, src0_param.param_str);
-        }
-    } else {
+
+        if (gl_info->supported[EXT_GPU_SHADER4])
+        {
+            if (mask_size > 1)
+                shader_addline(buffer, "ivec%d(round(%s)));\n", mask_size, src0_param.param_str);
+            else
+                shader_addline(buffer, "int(round(%s)));\n", src0_param.param_str);
+        }
+        else
+        {
+            if (mask_size > 1)
+                shader_addline(buffer, "ivec%d(floor(abs(%s) + vec%d(0.5)) * sign(%s)));\n",
+                        mask_size, src0_param.param_str, mask_size, src0_param.param_str);
+            else
+                shader_addline(buffer, "int(floor(abs(%s) + 0.5) * sign(%s)));\n",
+                        src0_param.param_str, src0_param.param_str);
+        }
+    }
+    else
+    {
         shader_addline(buffer, "%s);\n", src0_param.param_str);
     }
@@ -1953,8 +2116,13 @@
     shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_0, &src0_param);
 
-    if (dst_size > 1) {
-        shader_addline(buffer, "vec%d(log2(abs(%s))));\n", dst_size, src0_param.param_str);
-    } else {
-        shader_addline(buffer, "log2(abs(%s)));\n", src0_param.param_str);
+    if (dst_size > 1)
+    {
+        shader_addline(buffer, "vec%d(%s == 0.0 ? -FLT_MAX : log2(abs(%s))));\n",
+                dst_size, src0_param.param_str, src0_param.param_str);
+    }
+    else
+    {
+        shader_addline(buffer, "%s == 0.0 ? -FLT_MAX : log2(abs(%s)));\n",
+                src0_param.param_str, src0_param.param_str);
     }
 }
@@ -1977,5 +2145,4 @@
         case WINED3DSIH_ABS: instruction = "abs"; break;
         case WINED3DSIH_FRC: instruction = "fract"; break;
-        case WINED3DSIH_NRM: instruction = "normalize"; break;
         case WINED3DSIH_EXP: instruction = "exp2"; break;
         case WINED3DSIH_DSX: instruction = "dFdx"; break;
@@ -2002,4 +2169,30 @@
 
     shader_addline(buffer, "));\n");
+}
+
+static void shader_glsl_nrm(const struct wined3d_shader_instruction *ins)
+{
+    struct wined3d_shader_buffer *buffer = ins->ctx->buffer;
+    glsl_src_param_t src_param;
+    unsigned int mask_size;
+    DWORD write_mask;
+    char dst_mask[6];
+
+    write_mask = shader_glsl_get_write_mask(ins->dst, dst_mask);
+    mask_size = shader_glsl_get_write_mask_size(write_mask);
+    shader_glsl_add_src_param(ins, &ins->src[0], write_mask, &src_param);
+
+    shader_addline(buffer, "tmp0.x = length(%s);\n", src_param.param_str);
+    shader_glsl_append_dst(buffer, ins);
+    if (mask_size > 1)
+    {
+        shader_addline(buffer, "tmp0.x == 0.0 ? vec%u(0.0) : (%s / tmp0.x));\n",
+                mask_size, src_param.param_str);
+    }
+    else
+    {
+        shader_addline(buffer, "tmp0.x == 0.0 ? 0.0 : (%s / tmp0.x));\n",
+                src_param.param_str);
+    }
 }
 
@@ -2057,8 +2250,13 @@
     shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_3, &src_param);
 
-    if (mask_size > 1) {
-        shader_addline(ins->ctx->buffer, "vec%d(1.0 / %s));\n", mask_size, src_param.param_str);
-    } else {
-        shader_addline(ins->ctx->buffer, "1.0 / %s);\n", src_param.param_str);
+    if (mask_size > 1)
+    {
+        shader_addline(ins->ctx->buffer, "vec%d(%s == 0.0 ? FLT_MAX : 1.0 / %s));\n",
+                mask_size, src_param.param_str, src_param.param_str);
+    }
+    else
+    {
+        shader_addline(ins->ctx->buffer, "%s == 0.0 ? FLT_MAX : 1.0 / %s);\n",
+                src_param.param_str, src_param.param_str);
     }
 }
@@ -2076,8 +2274,13 @@
     shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_3, &src_param);
 
-    if (mask_size > 1) {
-        shader_addline(buffer, "vec%d(inversesqrt(%s)));\n", mask_size, src_param.param_str);
-    } else {
-        shader_addline(buffer, "inversesqrt(%s));\n", src_param.param_str);
+    if (mask_size > 1)
+    {
+        shader_addline(buffer, "vec%d(%s == 0.0 ? FLT_MAX : inversesqrt(abs(%s))));\n",
+                mask_size, src_param.param_str, src_param.param_str);
+    }
+    else
+    {
+        shader_addline(buffer, "%s == 0.0 ? FLT_MAX : inversesqrt(abs(%s)));\n",
+                src_param.param_str, src_param.param_str);
     }
 }
@@ -2682,8 +2885,9 @@
 static void shader_glsl_tex(const struct wined3d_shader_instruction *ins)
 {
-    IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader;
-    IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
+    IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
+    IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device;
     DWORD shader_version = WINED3D_SHADER_VERSION(ins->ctx->reg_maps->shader_version.major,
             ins->ctx->reg_maps->shader_version.minor);
+    const struct wined3d_gl_info *gl_info = ins->ctx->gl_info;
     glsl_sample_function_t sample_function;
     DWORD sample_flags = 0;
@@ -2739,5 +2943,5 @@
     }
 
-    shader_glsl_get_sample_function(sampler_type, sample_flags, &sample_function);
+    shader_glsl_get_sample_function(gl_info, sampler_type, sample_flags, &sample_function);
     mask |= sample_function.coord_mask;
 
@@ -2773,5 +2977,5 @@
     IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
     IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
-    const struct wined3d_gl_info *gl_info = &deviceImpl->adapter->gl_info;
+    const struct wined3d_gl_info *gl_info = ins->ctx->gl_info;
     glsl_sample_function_t sample_function;
     glsl_src_param_t coord_param, dx_param, dy_param;
@@ -2781,5 +2985,5 @@
     DWORD swizzle = ins->src[1].swizzle;
 
-    if (!gl_info->supported[ARB_SHADER_TEXTURE_LOD])
+    if (!gl_info->supported[ARB_SHADER_TEXTURE_LOD] && !gl_info->supported[EXT_GPU_SHADER4])
     {
         FIXME("texldd used, but not supported by hardware. Falling back to regular tex\n");
@@ -2794,5 +2998,5 @@
     }
 
-    shader_glsl_get_sample_function(sampler_type, sample_flags, &sample_function);
+    shader_glsl_get_sample_function(gl_info, sampler_type, sample_flags, &sample_function);
     shader_glsl_add_src_param(ins, &ins->src[0], sample_function.coord_mask, &coord_param);
     shader_glsl_add_src_param(ins, &ins->src[2], sample_function.coord_mask, &dx_param);
@@ -2807,5 +3011,5 @@
     IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
     IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
-    const struct wined3d_gl_info *gl_info = &deviceImpl->adapter->gl_info;
+    const struct wined3d_gl_info *gl_info = ins->ctx->gl_info;
     glsl_sample_function_t sample_function;
     glsl_src_param_t coord_param, lod_param;
@@ -2821,10 +3025,10 @@
         sample_flags |= WINED3D_GLSL_SAMPLE_RECT;
     }
-    shader_glsl_get_sample_function(sampler_type, sample_flags, &sample_function);
+    shader_glsl_get_sample_function(gl_info, sampler_type, sample_flags, &sample_function);
     shader_glsl_add_src_param(ins, &ins->src[0], sample_function.coord_mask, &coord_param);
 
     shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_3, &lod_param);
 
-    if (!gl_info->supported[ARB_SHADER_TEXTURE_LOD]
+    if (!gl_info->supported[ARB_SHADER_TEXTURE_LOD] && !gl_info->supported[EXT_GPU_SHADER4]
             && shader_is_pshader_version(ins->ctx->reg_maps->shader_version.type))
     {
@@ -2888,4 +3092,5 @@
 static void shader_glsl_texdp3tex(const struct wined3d_shader_instruction *ins)
 {
+    const struct wined3d_gl_info *gl_info = ins->ctx->gl_info;
     glsl_src_param_t src0_param;
     glsl_sample_function_t sample_function;
@@ -2902,5 +3107,5 @@
      * It is a dependent read - not valid with conditional NP2 textures
      */
-    shader_glsl_get_sample_function(sampler_type, 0, &sample_function);
+    shader_glsl_get_sample_function(gl_info, sampler_type, 0, &sample_function);
     mask_size = shader_glsl_get_write_mask_size(sample_function.coord_mask);
 
@@ -3001,5 +3206,5 @@
 static void shader_glsl_texm3x3pad(const struct wined3d_shader_instruction *ins)
 {
-    IWineD3DPixelShaderImpl *shader = (IWineD3DPixelShaderImpl *)ins->ctx->shader;
+    IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
     DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2;
     DWORD reg = ins->dst[0].reg.idx;
@@ -3015,4 +3220,5 @@
 static void shader_glsl_texm3x2tex(const struct wined3d_shader_instruction *ins)
 {
+    const struct wined3d_gl_info *gl_info = ins->ctx->gl_info;
     DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2;
     DWORD reg = ins->dst[0].reg.idx;
@@ -3025,5 +3231,5 @@
     shader_addline(buffer, "tmp0.y = dot(T%u.xyz, %s);\n", reg, src0_param.param_str);
 
-    shader_glsl_get_sample_function(sampler_type, 0, &sample_function);
+    shader_glsl_get_sample_function(gl_info, sampler_type, 0, &sample_function);
 
     /* Sample the texture using the calculated coordinates */
@@ -3036,8 +3242,9 @@
 {
     DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2;
+    IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
+    SHADER_PARSE_STATE *current_state = &shader->baseShader.parse_state;
+    const struct wined3d_gl_info *gl_info = ins->ctx->gl_info;
     glsl_src_param_t src0_param;
     DWORD reg = ins->dst[0].reg.idx;
-    IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader;
-    SHADER_PARSE_STATE* current_state = &This->baseShader.parse_state;
     WINED3DSAMPLER_TEXTURE_TYPE sampler_type = ins->ctx->reg_maps->sampler_type[reg];
     glsl_sample_function_t sample_function;
@@ -3047,5 +3254,5 @@
 
     /* Dependent read, not valid with conditional NP2 */
-    shader_glsl_get_sample_function(sampler_type, 0, &sample_function);
+    shader_glsl_get_sample_function(gl_info, sampler_type, 0, &sample_function);
 
     /* Sample the texture using the calculated coordinates */
@@ -3060,9 +3267,9 @@
 {
     DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2;
+    IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
+    SHADER_PARSE_STATE *current_state = &shader->baseShader.parse_state;
     glsl_src_param_t src0_param;
     char dst_mask[6];
     DWORD reg = ins->dst[0].reg.idx;
-    IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader;
-    SHADER_PARSE_STATE* current_state = &This->baseShader.parse_state;
 
     shader_glsl_add_src_param(ins, &ins->src[0], src_mask, &src0_param);
@@ -3079,5 +3286,6 @@
 static void shader_glsl_texm3x3spec(const struct wined3d_shader_instruction *ins)
 {
-    IWineD3DPixelShaderImpl *shader = (IWineD3DPixelShaderImpl *)ins->ctx->shader;
+    IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
+    const struct wined3d_gl_info *gl_info = ins->ctx->gl_info;
     DWORD reg = ins->dst[0].reg.idx;
     glsl_src_param_t src0_param;
@@ -3098,5 +3306,5 @@
 
     /* Dependent read, not valid with conditional NP2 */
-    shader_glsl_get_sample_function(stype, 0, &sample_function);
+    shader_glsl_get_sample_function(gl_info, stype, 0, &sample_function);
 
     /* Sample the texture */
@@ -3110,5 +3318,6 @@
 static void shader_glsl_texm3x3vspec(const struct wined3d_shader_instruction *ins)
 {
-    IWineD3DPixelShaderImpl *shader = (IWineD3DPixelShaderImpl *)ins->ctx->shader;
+    IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
+    const struct wined3d_gl_info *gl_info = ins->ctx->gl_info;
     DWORD reg = ins->dst[0].reg.idx;
     struct wined3d_shader_buffer *buffer = ins->ctx->buffer;
@@ -3130,5 +3339,5 @@
 
     /* Dependent read, not valid with conditional NP2 */
-    shader_glsl_get_sample_function(sampler_type, 0, &sample_function);
+    shader_glsl_get_sample_function(gl_info, sampler_type, 0, &sample_function);
 
     /* Sample the texture using the calculated coordinates */
@@ -3144,6 +3353,7 @@
 static void shader_glsl_texbem(const struct wined3d_shader_instruction *ins)
 {
-    IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader;
-    IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
+    IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
+    IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device;
+    const struct wined3d_gl_info *gl_info = ins->ctx->gl_info;
     glsl_sample_function_t sample_function;
     glsl_src_param_t coord_param;
@@ -3159,5 +3369,5 @@
     sampler_type = ins->ctx->reg_maps->sampler_type[sampler_idx];
     /* Dependent read, not valid with conditional NP2 */
-    shader_glsl_get_sample_function(sampler_type, 0, &sample_function);
+    shader_glsl_get_sample_function(gl_info, sampler_type, 0, &sample_function);
     mask = sample_function.coord_mask;
 
@@ -3218,4 +3428,5 @@
 static void shader_glsl_texreg2ar(const struct wined3d_shader_instruction *ins)
 {
+    const struct wined3d_gl_info *gl_info = ins->ctx->gl_info;
     glsl_src_param_t src0_param;
     DWORD sampler_idx = ins->dst[0].reg.idx;
@@ -3225,5 +3436,5 @@
     shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_ALL, &src0_param);
 
-    shader_glsl_get_sample_function(sampler_type, 0, &sample_function);
+    shader_glsl_get_sample_function(gl_info, sampler_type, 0, &sample_function);
     shader_glsl_gen_sample_code(ins, sampler_idx, &sample_function, WINED3DSP_NOSWIZZLE, NULL, NULL, NULL,
             "%s.wx", src0_param.reg_name);
@@ -3234,4 +3445,5 @@
 static void shader_glsl_texreg2gb(const struct wined3d_shader_instruction *ins)
 {
+    const struct wined3d_gl_info *gl_info = ins->ctx->gl_info;
     glsl_src_param_t src0_param;
     DWORD sampler_idx = ins->dst[0].reg.idx;
@@ -3241,5 +3453,5 @@
     shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_ALL, &src0_param);
 
-    shader_glsl_get_sample_function(sampler_type, 0, &sample_function);
+    shader_glsl_get_sample_function(gl_info, sampler_type, 0, &sample_function);
     shader_glsl_gen_sample_code(ins, sampler_idx, &sample_function, WINED3DSP_NOSWIZZLE, NULL, NULL, NULL,
             "%s.yz", src0_param.reg_name);
@@ -3250,4 +3462,5 @@
 static void shader_glsl_texreg2rgb(const struct wined3d_shader_instruction *ins)
 {
+    const struct wined3d_gl_info *gl_info = ins->ctx->gl_info;
     glsl_src_param_t src0_param;
     DWORD sampler_idx = ins->dst[0].reg.idx;
@@ -3256,5 +3469,5 @@
 
     /* Dependent read, not valid with conditional NP2 */
-    shader_glsl_get_sample_function(sampler_type, 0, &sample_function);
+    shader_glsl_get_sample_function(gl_info, sampler_type, 0, &sample_function);
     shader_glsl_add_src_param(ins, &ins->src[0], sample_function.coord_mask, &src0_param);
 
@@ -3769,4 +3982,8 @@
          */
         shader_addline(buffer, "#extension GL_ARB_texture_rectangle : enable\n");
+    }
+    if (gl_info->supported[EXT_GPU_SHADER4])
+    {
+        shader_addline(buffer, "#extension GL_EXT_gpu_shader4 : enable\n");
     }
 
@@ -3857,4 +4074,9 @@
     shader_addline(buffer, "#version 120\n");
 
+    if (gl_info->supported[EXT_GPU_SHADER4])
+    {
+        shader_addline(buffer, "#extension GL_EXT_gpu_shader4 : enable\n");
+    }
+
     memset(&priv_ctx, 0, sizeof(priv_ctx));
     priv_ctx.cur_vs_args = args;
@@ -4160,5 +4382,5 @@
     TRACE("Linking GLSL shader program %u\n", programId);
     GL_EXTCALL(glLinkProgramARB(programId));
-    print_glsl_info_log(gl_info, programId);
+    shader_glsl_validate_link(gl_info, programId);
 
     entry->vuniformF_locations = HeapAlloc(GetProcessHeap(), 0,
@@ -4241,8 +4463,10 @@
      * later
      */
-    if(pshader && !((IWineD3DPixelShaderImpl*)pshader)->baseShader.load_local_constsF) {
+    if (pshader && !((IWineD3DBaseShaderImpl *)pshader)->baseShader.load_local_constsF)
+    {
         hardcode_local_constants((IWineD3DBaseShaderImpl *) pshader, gl_info, programId, 'P');
     }
-    if(vshader && !((IWineD3DVertexShaderImpl*)vshader)->baseShader.load_local_constsF) {
+    if (vshader && !((IWineD3DBaseShaderImpl *)vshader)->baseShader.load_local_constsF)
+    {
         hardcode_local_constants((IWineD3DBaseShaderImpl *) vshader, gl_info, programId, 'V');
     }
@@ -4314,5 +4538,5 @@
     GL_EXTCALL(glLinkProgramARB(program_id));
 
-    print_glsl_info_log(gl_info, program_id);
+    shader_glsl_validate_link(gl_info, program_id);
 
     /* Once linked we can mark the shaders for deletion. They will be deleted once the program
@@ -4327,6 +4551,6 @@
 static void shader_glsl_select(const struct wined3d_context *context, BOOL usePS, BOOL useVS)
 {
-    IWineD3DDeviceImpl *device = ((IWineD3DSurfaceImpl *)context->surface)->resource.device;
     const struct wined3d_gl_info *gl_info = context->gl_info;
+    IWineD3DDeviceImpl *device = context->swapchain->device;
     struct shader_glsl_priv *priv = device->shader_priv;
     GLhandleARB program_id = 0;
@@ -4405,6 +4629,4 @@
     struct shader_glsl_priv *priv = device->shader_priv;
     const struct wined3d_gl_info *gl_info;
-    IWineD3DPixelShaderImpl *ps = NULL;
-    IWineD3DVertexShaderImpl *vs = NULL;
     struct wined3d_context *context;
 
@@ -4416,10 +4638,9 @@
     if(pshader) {
         struct glsl_pshader_private *shader_data;
-        ps = (IWineD3DPixelShaderImpl *) This;
-        shader_data = ps->baseShader.backend_data;
+        shader_data = This->baseShader.backend_data;
         if(!shader_data || shader_data->num_gl_shaders == 0)
         {
             HeapFree(GetProcessHeap(), 0, shader_data);
-            ps->baseShader.backend_data = NULL;
+            This->baseShader.backend_data = NULL;
             return;
         }
@@ -4436,10 +4657,9 @@
     } else {
         struct glsl_vshader_private *shader_data;
-        vs = (IWineD3DVertexShaderImpl *) This;
-        shader_data = vs->baseShader.backend_data;
+        shader_data = This->baseShader.backend_data;
         if(!shader_data || shader_data->num_gl_shaders == 0)
         {
             HeapFree(GetProcessHeap(), 0, shader_data);
-            vs->baseShader.backend_data = NULL;
+            This->baseShader.backend_data = NULL;
             return;
         }
@@ -4477,5 +4697,5 @@
     if(pshader) {
         UINT i;
-        struct glsl_pshader_private *shader_data = ps->baseShader.backend_data;
+        struct glsl_pshader_private *shader_data = This->baseShader.backend_data;
 
         ENTER_GL();
@@ -4487,9 +4707,9 @@
         LEAVE_GL();
         HeapFree(GetProcessHeap(), 0, shader_data->gl_shaders);
-        HeapFree(GetProcessHeap(), 0, shader_data);
-        ps->baseShader.backend_data = NULL;
-    } else {
+    }
+    else
+    {
         UINT i;
-        struct glsl_vshader_private *shader_data = vs->baseShader.backend_data;
+        struct glsl_vshader_private *shader_data = This->baseShader.backend_data;
 
         ENTER_GL();
@@ -4501,7 +4721,8 @@
         LEAVE_GL();
         HeapFree(GetProcessHeap(), 0, shader_data->gl_shaders);
-        HeapFree(GetProcessHeap(), 0, shader_data);
-        vs->baseShader.backend_data = NULL;
-    }
+    }
+
+    HeapFree(GetProcessHeap(), 0, This->baseShader.backend_data);
+    This->baseShader.backend_data = NULL;
 
     context_release(context);
@@ -4643,6 +4864,5 @@
 }
 
-static void shader_glsl_get_caps(WINED3DDEVTYPE devtype,
-        const struct wined3d_gl_info *gl_info, struct shader_caps *pCaps)
+static void shader_glsl_get_caps(const struct wined3d_gl_info *gl_info, struct shader_caps *pCaps)
 {
     /* Nvidia Geforce6/7 or Ati R4xx/R5xx cards with GLSL support, support VS 3.0 but older Nvidia/Ati
@@ -4708,5 +4928,5 @@
 
     /* We support everything except YUV conversions. */
-    if (!is_yuv_fixup(fixup))
+    if (!is_complex_fixup(fixup))
     {
         TRACE("[OK]\n");
@@ -4773,5 +4993,5 @@
     /* WINED3DSIH_MUL           */ shader_glsl_arith,
     /* WINED3DSIH_NOP           */ NULL,
-    /* WINED3DSIH_NRM           */ shader_glsl_map2gl,
+    /* WINED3DSIH_NRM           */ shader_glsl_nrm,
     /* WINED3DSIH_PHASE         */ NULL,
     /* WINED3DSIH_POW           */ shader_glsl_pow,
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/nvidia_texture_shader.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/nvidia_texture_shader.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/nvidia_texture_shader.c	(revision 28475)
@@ -638,6 +638,5 @@
 }
 
-static void nvrc_fragment_get_caps(WINED3DDEVTYPE devtype,
-        const struct wined3d_gl_info *gl_info, struct fragment_caps *pCaps)
+static void nvrc_fragment_get_caps(const struct wined3d_gl_info *gl_info, struct fragment_caps *pCaps)
 {
     pCaps->TextureOpCaps =  WINED3DTEXOPCAPS_ADD                        |
@@ -682,5 +681,5 @@
 #endif
 
-    pCaps->MaxTextureBlendStages = gl_info->limits.texture_stages;
+    pCaps->MaxTextureBlendStages = min(MAX_TEXTURES, gl_info->limits.general_combiners);
     pCaps->MaxSimultaneousTextures = gl_info->limits.textures;
 
@@ -725,117 +724,117 @@
 static const struct StateEntryTemplate nvrc_fragmentstate_template[] = {
     { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP),          { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),     { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
-    { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
-    { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
-    { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
-    { STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(0, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),     NULL                }, NV_TEXTURE_SHADER2              },
+    { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),     NULL                }, NV_TEXTURE_SHADER2              },
+    { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),     NULL                }, NV_TEXTURE_SHADER2              },
+    { STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(0, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP),          { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP),          { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),     { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
-    { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
-    { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
-    { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
-    { STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(1, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),     NULL                }, NV_TEXTURE_SHADER2              },
+    { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),     NULL                }, NV_TEXTURE_SHADER2              },
+    { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),     NULL                }, NV_TEXTURE_SHADER2              },
+    { STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(1, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP),          { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP),          { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),     { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
-    { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
-    { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
-    { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
-    { STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(2, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),     NULL                }, NV_TEXTURE_SHADER2              },
+    { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),     NULL                }, NV_TEXTURE_SHADER2              },
+    { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),     NULL                }, NV_TEXTURE_SHADER2              },
+    { STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(2, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP),          { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP),          { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),     { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
-    { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
-    { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
-    { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
-    { STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(3, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),     NULL                }, NV_TEXTURE_SHADER2              },
+    { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),     NULL                }, NV_TEXTURE_SHADER2              },
+    { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),     NULL                }, NV_TEXTURE_SHADER2              },
+    { STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(3, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP),          { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP),          { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),     { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
-    { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
-    { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
-    { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
-    { STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(4, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),     NULL                }, NV_TEXTURE_SHADER2              },
+    { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),     NULL                }, NV_TEXTURE_SHADER2              },
+    { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),     NULL                }, NV_TEXTURE_SHADER2              },
+    { STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(4, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP),          { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP),          { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),     { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
-    { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
-    { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
-    { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
-    { STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(5, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),     NULL                }, NV_TEXTURE_SHADER2              },
+    { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),     NULL                }, NV_TEXTURE_SHADER2              },
+    { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),     NULL                }, NV_TEXTURE_SHADER2              },
+    { STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(5, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP),          { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP),          { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),     { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
-    { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
-    { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
-    { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
-    { STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(6, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),     NULL                }, NV_TEXTURE_SHADER2              },
+    { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),     NULL                }, NV_TEXTURE_SHADER2              },
+    { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),     NULL                }, NV_TEXTURE_SHADER2              },
+    { STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(6, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP),          { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP),          { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),     { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
-    { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
-    { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
-    { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
-    { STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(7, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),     NULL                }, NV_TEXTURE_SHADER2              },
+    { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),     NULL                }, NV_TEXTURE_SHADER2              },
+    { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),     NULL                }, NV_TEXTURE_SHADER2              },
+    { STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(7, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_PIXELSHADER,                                  { STATE_PIXELSHADER,                                  apply_pixelshader   }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_SRGBWRITEENABLE),            { STATE_PIXELSHADER,                                  apply_pixelshader   }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_SRGBWRITEENABLE),            { STATE_PIXELSHADER,                                  NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_TEXTUREFACTOR),              { STATE_RENDER(WINED3DRS_TEXTUREFACTOR),              nvrc_texfactor      }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_FOGCOLOR),                   { STATE_RENDER(WINED3DRS_FOGCOLOR),                   state_fogcolor      }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_FOGDENSITY),                 { STATE_RENDER(WINED3DRS_FOGDENSITY),                 state_fogdensity    }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_FOGENABLE),                  { STATE_RENDER(WINED3DRS_FOGENABLE),                  state_fog_fragpart  }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_FOGTABLEMODE),               { STATE_RENDER(WINED3DRS_FOGENABLE),                  state_fog_fragpart  }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_FOGVERTEXMODE),              { STATE_RENDER(WINED3DRS_FOGENABLE),                  state_fog_fragpart  }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_FOGTABLEMODE),               { STATE_RENDER(WINED3DRS_FOGENABLE),                  NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_FOGVERTEXMODE),              { STATE_RENDER(WINED3DRS_FOGENABLE),                  NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_FOGSTART),                   { STATE_RENDER(WINED3DRS_FOGSTART),                   state_fogstartend   }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_FOGEND),                     { STATE_RENDER(WINED3DRS_FOGSTART),                   state_fogstartend   }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_FOGEND),                     { STATE_RENDER(WINED3DRS_FOGSTART),                   NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_SAMPLER(0),                                   { STATE_SAMPLER(0),                                   nvts_texdim         }, NV_TEXTURE_SHADER2              },
     { STATE_SAMPLER(0),                                   { STATE_SAMPLER(0),                                   sampler_texdim      }, WINED3D_GL_EXT_NONE             },
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/palette.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/palette.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/palette.c	(revision 28475)
@@ -85,5 +85,6 @@
 
 /* Not called from the vtable */
-DWORD IWineD3DPaletteImpl_Size(DWORD dwFlags) {
+static DWORD IWineD3DPaletteImpl_Size(DWORD dwFlags)
+{
     switch (dwFlags & SIZE_BITS) {
         case WINEDDPCAPS_1BIT: return 2;
@@ -194,5 +195,5 @@
 }
 
-const IWineD3DPaletteVtbl IWineD3DPalette_Vtbl =
+static const IWineD3DPaletteVtbl IWineD3DPalette_Vtbl =
 {
     /*** IUnknown ***/
@@ -206,2 +207,32 @@
     IWineD3DPaletteImpl_SetEntries
 };
+
+HRESULT wined3d_palette_init(IWineD3DPaletteImpl *palette, IWineD3DDeviceImpl *device,
+        DWORD flags, const PALETTEENTRY *entries, IUnknown *parent)
+{
+    HRESULT hr;
+
+    palette->lpVtbl = &IWineD3DPalette_Vtbl;
+    palette->ref = 1;
+    palette->parent = parent;
+    palette->device = device;
+    palette->Flags = flags;
+
+    palette->palNumEntries = IWineD3DPaletteImpl_Size(flags);
+    palette->hpal = CreatePalette((const LOGPALETTE *)&palette->palVersion);
+    if (!palette->hpal)
+    {
+        WARN("Failed to create palette.\n");
+        return E_FAIL;
+    }
+
+    hr = IWineD3DPalette_SetEntries((IWineD3DPalette *)palette, 0, 0, IWineD3DPaletteImpl_Size(flags), entries);
+    if (FAILED(hr))
+    {
+        WARN("Failed to set palette entries, hr %#x.\n", hr);
+        DeleteObject(palette->hpal);
+        return hr;
+    }
+
+    return WINED3D_OK;
+}
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/query.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/query.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/query.c	(revision 28475)
@@ -33,4 +33,211 @@
 #include "wined3d_private.h"
 
+WINE_DEFAULT_DEBUG_CHANNEL(d3d);
+#define GLINFO_LOCATION (*gl_info)
+
+BOOL wined3d_event_query_supported(const struct wined3d_gl_info *gl_info)
+{
+    return gl_info->supported[ARB_SYNC] || gl_info->supported[NV_FENCE] || gl_info->supported[APPLE_FENCE];
+}
+
+void wined3d_event_query_destroy(struct wined3d_event_query *query)
+{
+    if (query->context) context_free_event_query(query);
+    HeapFree(GetProcessHeap(), 0, query);
+}
+
+enum wined3d_event_query_result wined3d_event_query_test(struct wined3d_event_query *query, IWineD3DDeviceImpl *device)
+{
+    struct wined3d_context *context;
+    const struct wined3d_gl_info *gl_info;
+    enum wined3d_event_query_result ret;
+    BOOL fence_result;
+
+    TRACE("(%p) : device %p\n", query, device);
+
+    if (query->context == NULL)
+    {
+        TRACE("Query not started\n");
+        return WINED3D_EVENT_QUERY_NOT_STARTED;
+    }
+
+    if (!query->context->gl_info->supported[ARB_SYNC] && query->context->tid != GetCurrentThreadId())
+    {
+        WARN("Event query tested from wrong thread\n");
+        return WINED3D_EVENT_QUERY_WRONG_THREAD;
+    }
+
+    context = context_acquire(device, query->context->current_rt, CTXUSAGE_RESOURCELOAD);
+    gl_info = context->gl_info;
+
+    ENTER_GL();
+
+    if (gl_info->supported[ARB_SYNC])
+    {
+        GLenum gl_ret = GL_EXTCALL(glClientWaitSync(query->object.sync, 0, 0));
+        checkGLcall("glClientWaitSync");
+
+        switch (gl_ret)
+        {
+            case GL_ALREADY_SIGNALED:
+            case GL_CONDITION_SATISFIED:
+                ret = WINED3D_EVENT_QUERY_OK;
+                break;
+
+            case GL_TIMEOUT_EXPIRED:
+                ret = WINED3D_EVENT_QUERY_WAITING;
+                break;
+
+            case GL_WAIT_FAILED:
+            default:
+                ERR("glClientWaitSync returned %#x.\n", gl_ret);
+                ret = WINED3D_EVENT_QUERY_ERROR;
+        }
+    }
+    else if (gl_info->supported[APPLE_FENCE])
+    {
+        fence_result = GL_EXTCALL(glTestFenceAPPLE(query->object.id));
+        checkGLcall("glTestFenceAPPLE");
+        if (fence_result) ret = WINED3D_EVENT_QUERY_OK;
+        else ret = WINED3D_EVENT_QUERY_WAITING;
+    }
+    else if (gl_info->supported[NV_FENCE])
+    {
+        fence_result = GL_EXTCALL(glTestFenceNV(query->object.id));
+        checkGLcall("glTestFenceNV");
+        if (fence_result) ret = WINED3D_EVENT_QUERY_OK;
+        else ret = WINED3D_EVENT_QUERY_WAITING;
+    }
+    else
+    {
+        ERR("Event query created despite lack of GL support\n");
+        ret = WINED3D_EVENT_QUERY_ERROR;
+    }
+
+    LEAVE_GL();
+
+    context_release(context);
+    return ret;
+}
+
+enum wined3d_event_query_result wined3d_event_query_finish(struct wined3d_event_query *query, IWineD3DDeviceImpl *device)
+{
+    struct wined3d_context *context;
+    const struct wined3d_gl_info *gl_info;
+    enum wined3d_event_query_result ret;
+
+    TRACE("(%p)\n", query);
+
+    if (!query->context)
+    {
+        TRACE("Query not started\n");
+        return WINED3D_EVENT_QUERY_NOT_STARTED;
+    }
+    gl_info = query->context->gl_info;
+
+    if (query->context->tid != GetCurrentThreadId() && !gl_info->supported[ARB_SYNC])
+    {
+        /* A glFinish does not reliably wait for draws in other contexts. The caller has
+         * to find its own way to cope with the thread switch
+         */
+        WARN("Event query finished from wrong thread\n");
+        return WINED3D_EVENT_QUERY_WRONG_THREAD;
+    }
+
+    context = context_acquire(device, query->context->current_rt, CTXUSAGE_RESOURCELOAD);
+
+    ENTER_GL();
+    if (gl_info->supported[ARB_SYNC])
+    {
+        GLenum gl_ret = GL_EXTCALL(glClientWaitSync(query->object.sync, 0, ~(GLuint64)0));
+        checkGLcall("glClientWaitSync");
+
+        switch (gl_ret)
+        {
+            case GL_ALREADY_SIGNALED:
+            case GL_CONDITION_SATISFIED:
+                ret = WINED3D_EVENT_QUERY_OK;
+                break;
+
+                /* We don't expect a timeout for a ~584 year wait */
+            default:
+                ERR("glClientWaitSync returned %#x.\n", gl_ret);
+                ret = WINED3D_EVENT_QUERY_ERROR;
+        }
+    }
+    else if (context->gl_info->supported[APPLE_FENCE])
+    {
+        GL_EXTCALL(glFinishFenceAPPLE(query->object.id));
+        checkGLcall("glFinishFenceAPPLE");
+        ret = WINED3D_EVENT_QUERY_OK;
+    }
+    else if (context->gl_info->supported[NV_FENCE])
+    {
+        GL_EXTCALL(glFinishFenceNV(query->object.id));
+        checkGLcall("glFinishFenceNV");
+        ret = WINED3D_EVENT_QUERY_OK;
+    }
+    else
+    {
+        ERR("Event query created without GL support\n");
+        ret = WINED3D_EVENT_QUERY_ERROR;
+    }
+    LEAVE_GL();
+
+    context_release(context);
+    return ret;
+}
+
+void wined3d_event_query_issue(struct wined3d_event_query *query, IWineD3DDeviceImpl *device)
+{
+    const struct wined3d_gl_info *gl_info;
+    struct wined3d_context *context;
+
+    if (query->context)
+    {
+        if (!query->context->gl_info->supported[ARB_SYNC] && query->context->tid != GetCurrentThreadId())
+        {
+            context_free_event_query(query);
+            context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
+            context_alloc_event_query(context, query);
+        }
+        else
+        {
+            context = context_acquire(device, query->context->current_rt, CTXUSAGE_RESOURCELOAD);
+        }
+    }
+    else
+    {
+        context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
+        context_alloc_event_query(context, query);
+    }
+
+    gl_info = context->gl_info;
+
+    ENTER_GL();
+
+    if (gl_info->supported[ARB_SYNC])
+    {
+        if (query->object.sync) GL_EXTCALL(glDeleteSync(query->object.sync));
+        checkGLcall("glDeleteSync");
+        query->object.sync = GL_EXTCALL(glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0));
+        checkGLcall("glFenceSync");
+    }
+    else if (gl_info->supported[APPLE_FENCE])
+    {
+        GL_EXTCALL(glSetFenceAPPLE(query->object.id));
+        checkGLcall("glSetFenceAPPLE");
+    }
+    else if (gl_info->supported[NV_FENCE])
+    {
+        GL_EXTCALL(glSetFenceNV(query->object.id, GL_ALL_COMPLETED_NV));
+        checkGLcall("glSetFenceNV");
+    }
+
+    LEAVE_GL();
+
+    context_release(context);
+}
+
 /*
  * Occlusion Queries:
@@ -38,7 +245,4 @@
  * http://oss.sgi.com/projects/ogl-sample/registry/ARB/occlusion_query.txt
  */
-
-WINE_DEFAULT_DEBUG_CHANNEL(d3d);
-#define GLINFO_LOCATION This->device->adapter->gl_info
 
 /* *******************************************
@@ -79,6 +283,5 @@
         {
             struct wined3d_event_query *query = This->extendedData;
-
-            if (query->context) context_free_event_query(query);
+            if (query) wined3d_event_query_destroy(query);
         }
         else if (This->type == WINED3DQUERYTYPE_OCCLUSION)
@@ -87,7 +290,7 @@
 
             if (query->context) context_free_occlusion_query(query);
-        }
-
-        HeapFree(GetProcessHeap(), 0, This->extendedData);
+            HeapFree(GetProcessHeap(), 0, This->extendedData);
+        }
+
         HeapFree(GetProcessHeap(), 0, This);
     }
@@ -108,166 +311,4 @@
 
     return WINED3D_OK;
-}
-
-static HRESULT  WINAPI IWineD3DQueryImpl_GetData(IWineD3DQuery* iface, void* pData, DWORD dwSize, DWORD dwGetDataFlags){
-    IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface;
-    HRESULT res = S_OK;
-
-    TRACE("(%p) : type %#x, pData %p, dwSize %#x, dwGetDataFlags %#x\n", This, This->type, pData, dwSize, dwGetDataFlags);
-
-    switch (This->type){
-
-    case WINED3DQUERYTYPE_VCACHE:
-    {
-
-        WINED3DDEVINFO_VCACHE *data = pData;
-        FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_VCACHE\n", This);
-        if(pData == NULL || dwSize == 0) break;
-        data->Pattern     = WINEMAKEFOURCC('C','A','C','H');
-        data->OptMethod   = 0; /*0 get longest strips, 1 optimize vertex cache*/
-        data->CacheSize   = 0; /*cache size, only required if OptMethod == 1*/
-        data->MagicNumber = 0; /*only required if OptMethod == 1 (used internally)*/
-
-    }
-    break;
-    case WINED3DQUERYTYPE_RESOURCEMANAGER:
-    {
-        WINED3DDEVINFO_RESOURCEMANAGER *data = pData;
-        int i;
-        FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_RESOURCEMANAGER\n", This);
-        if(pData == NULL || dwSize == 0) break;
-        for(i = 0; i < WINED3DRTYPECOUNT; i++){
-            /*I'm setting the default values to 1 so as to reduce the risk of a div/0 in the caller*/
-            /*  isTextureResident could be used to get some of this information  */
-            data->stats[i].bThrashing            = FALSE;
-            data->stats[i].ApproxBytesDownloaded = 1;
-            data->stats[i].NumEvicts             = 1;
-            data->stats[i].NumVidCreates         = 1;
-            data->stats[i].LastPri               = 1;
-            data->stats[i].NumUsed               = 1;
-            data->stats[i].NumUsedInVidMem       = 1;
-            data->stats[i].WorkingSet            = 1;
-            data->stats[i].WorkingSetBytes       = 1;
-            data->stats[i].TotalManaged          = 1;
-            data->stats[i].TotalBytes            = 1;
-        }
-
-    }
-    break;
-    case WINED3DQUERYTYPE_VERTEXSTATS:
-    {
-        WINED3DDEVINFO_VERTEXSTATS *data = pData;
-        FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_VERTEXSTATS\n", This);
-        if(pData == NULL || dwSize == 0) break;
-        data->NumRenderedTriangles      = 1;
-        data->NumExtraClippingTriangles = 1;
-
-    }
-    break;
-    case WINED3DQUERYTYPE_TIMESTAMP:
-    {
-        UINT64* data = pData;
-        FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_TIMESTAMP\n", This);
-        if(pData == NULL || dwSize == 0) break;
-        *data = 1; /*Don't know what this is supposed to be*/
-    }
-    break;
-    case WINED3DQUERYTYPE_TIMESTAMPDISJOINT:
-    {
-        BOOL* data = pData;
-        FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_TIMESTAMPDISJOINT\n", This);
-        if(pData == NULL || dwSize == 0) break;
-        *data = FALSE; /*Don't know what this is supposed to be*/
-    }
-    break;
-    case WINED3DQUERYTYPE_TIMESTAMPFREQ:
-    {
-        UINT64* data = pData;
-        FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_TIMESTAMPFREQ\n", This);
-        if(pData == NULL || dwSize == 0) break;
-        *data = 1; /*Don't know what this is supposed to be*/
-    }
-    break;
-    case WINED3DQUERYTYPE_PIPELINETIMINGS:
-    {
-        WINED3DDEVINFO_PIPELINETIMINGS *data = pData;
-        FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_PIPELINETIMINGS\n", This);
-        if(pData == NULL || dwSize == 0) break;
-
-        data->VertexProcessingTimePercent    =   1.0f;
-        data->PixelProcessingTimePercent     =   1.0f;
-        data->OtherGPUProcessingTimePercent  =  97.0f;
-        data->GPUIdleTimePercent             =   1.0f;
-    }
-    break;
-    case WINED3DQUERYTYPE_INTERFACETIMINGS:
-    {
-        WINED3DDEVINFO_INTERFACETIMINGS *data = pData;
-        FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_INTERFACETIMINGS\n", This);
-
-        if(pData == NULL || dwSize == 0) break;
-        data->WaitingForGPUToUseApplicationResourceTimePercent =   1.0f;
-        data->WaitingForGPUToAcceptMoreCommandsTimePercent     =   1.0f;
-        data->WaitingForGPUToStayWithinLatencyTimePercent      =   1.0f;
-        data->WaitingForGPUExclusiveResourceTimePercent        =   1.0f;
-        data->WaitingForGPUOtherTimePercent                    =  96.0f;
-    }
-
-    break;
-    case WINED3DQUERYTYPE_VERTEXTIMINGS:
-    {
-        WINED3DDEVINFO_STAGETIMINGS *data = pData;
-        FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_VERTEXTIMINGS\n", This);
-
-        if(pData == NULL || dwSize == 0) break;
-        data->MemoryProcessingPercent      = 50.0f;
-        data->ComputationProcessingPercent = 50.0f;
-
-    }
-    break;
-    case WINED3DQUERYTYPE_PIXELTIMINGS:
-    {
-        WINED3DDEVINFO_STAGETIMINGS *data = pData;
-        FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_PIXELTIMINGS\n", This);
-
-        if(pData == NULL || dwSize == 0) break;
-        data->MemoryProcessingPercent      = 50.0f;
-        data->ComputationProcessingPercent = 50.0f;
-    }
-    break;
-    case WINED3DQUERYTYPE_BANDWIDTHTIMINGS:
-    {
-        WINED3DDEVINFO_BANDWIDTHTIMINGS *data = pData;
-        FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_BANDWIDTHTIMINGS\n", This);
-
-        if(pData == NULL || dwSize == 0) break;
-        data->MaxBandwidthUtilized                =  1.0f;
-        data->FrontEndUploadMemoryUtilizedPercent =  1.0f;
-        data->VertexRateUtilizedPercent           =  1.0f;
-        data->TriangleSetupRateUtilizedPercent    =  1.0f;
-        data->FillRateUtilizedPercent             = 97.0f;
-    }
-    break;
-    case WINED3DQUERYTYPE_CACHEUTILIZATION:
-    {
-        WINED3DDEVINFO_CACHEUTILIZATION *data = pData;
-        FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_CACHEUTILIZATION\n", This);
-
-        if(pData == NULL || dwSize == 0) break;
-        data->TextureCacheHitRate             = 1.0f;
-        data->PostTransformVertexCacheHitRate = 1.0f;
-    }
-
-
-    break;
-    default:
-        FIXME("(%p) Unhandled query type %d\n",This , This->type);
-
-    };
-
-    /*dwGetDataFlags = 0 || D3DGETDATA_FLUSH
-    D3DGETDATA_FLUSH may return WINED3DERR_DEVICELOST if the device is lost
-    */
-    return res; /* S_OK if the query data is available*/
 }
 
@@ -350,104 +391,40 @@
     IWineD3DQueryImpl *This = (IWineD3DQueryImpl *) iface;
     struct wined3d_event_query *query = This->extendedData;
-    struct wined3d_context *context;
     BOOL *data = pData;
+    enum wined3d_event_query_result ret;
 
     TRACE("(%p) : type D3DQUERY_EVENT, pData %p, dwSize %#x, dwGetDataFlags %#x\n", This, pData, dwSize, dwGetDataFlags);
 
     if (!pData || !dwSize) return S_OK;
-
-    if (!query->context)
-    {
-        TRACE("Query not started, returning TRUE.\n");
+    if (!query)
+    {
+        WARN("(%p): Event query not supported by GL, reporting GPU idle\n", This);
         *data = TRUE;
-
         return S_OK;
     }
 
-    if (query->context->tid != GetCurrentThreadId())
-    {
-        /* See comment in IWineD3DQuery::Issue, event query codeblock */
-        FIXME("Wrong thread, reporting GPU idle.\n");
-        *data = TRUE;
-
-        return S_OK;
-    }
-
-    context = context_acquire(This->device, query->context->current_rt, CTXUSAGE_RESOURCELOAD);
-
-    ENTER_GL();
-
-    if (context->gl_info->supported[APPLE_FENCE])
-    {
-        *data = GL_EXTCALL(glTestFenceAPPLE(query->id));
-        checkGLcall("glTestFenceAPPLE");
-    }
-    else if (context->gl_info->supported[NV_FENCE])
-    {
-        *data = GL_EXTCALL(glTestFenceNV(query->id));
-        checkGLcall("glTestFenceNV");
-    }
-    else
-    {
-        WARN("(%p): reporting GPU idle\n", This);
-        *data = TRUE;
-    }
-
-    LEAVE_GL();
-
-    context_release(context);
+    ret = wined3d_event_query_test(query, This->device);
+    switch(ret)
+    {
+        case WINED3D_EVENT_QUERY_OK:
+        case WINED3D_EVENT_QUERY_NOT_STARTED:
+            *data = TRUE;
+            break;
+
+        case WINED3D_EVENT_QUERY_WAITING:
+            *data = FALSE;
+            break;
+
+        case WINED3D_EVENT_QUERY_WRONG_THREAD:
+            FIXME("(%p) Wrong thread, reporting GPU idle.\n", This);
+            *data = TRUE;
+            break;
+
+        case WINED3D_EVENT_QUERY_ERROR:
+            ERR("The GL event query failed, returning D3DERR_INVALIDCALL\n");
+            return WINED3DERR_INVALIDCALL;
+    }
 
     return S_OK;
-}
-
-static DWORD  WINAPI IWineD3DQueryImpl_GetDataSize(IWineD3DQuery* iface){
-    IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface;
-    int dataSize = 0;
-    TRACE("(%p) : type %#x\n", This, This->type);
-    switch(This->type){
-    case WINED3DQUERYTYPE_VCACHE:
-        dataSize = sizeof(WINED3DDEVINFO_VCACHE);
-        break;
-    case WINED3DQUERYTYPE_RESOURCEMANAGER:
-        dataSize = sizeof(WINED3DDEVINFO_RESOURCEMANAGER);
-        break;
-    case WINED3DQUERYTYPE_VERTEXSTATS:
-        dataSize = sizeof(WINED3DDEVINFO_VERTEXSTATS);
-        break;
-    case WINED3DQUERYTYPE_EVENT:
-        dataSize = sizeof(BOOL);
-        break;
-    case WINED3DQUERYTYPE_TIMESTAMP:
-        dataSize = sizeof(UINT64);
-        break;
-    case WINED3DQUERYTYPE_TIMESTAMPDISJOINT:
-        dataSize = sizeof(BOOL);
-        break;
-    case WINED3DQUERYTYPE_TIMESTAMPFREQ:
-        dataSize = sizeof(UINT64);
-        break;
-    case WINED3DQUERYTYPE_PIPELINETIMINGS:
-        dataSize = sizeof(WINED3DDEVINFO_PIPELINETIMINGS);
-        break;
-    case WINED3DQUERYTYPE_INTERFACETIMINGS:
-        dataSize = sizeof(WINED3DDEVINFO_INTERFACETIMINGS);
-        break;
-    case WINED3DQUERYTYPE_VERTEXTIMINGS:
-        dataSize = sizeof(WINED3DDEVINFO_STAGETIMINGS);
-        break;
-    case WINED3DQUERYTYPE_PIXELTIMINGS:
-        dataSize = sizeof(WINED3DDEVINFO_STAGETIMINGS);
-        break;
-    case WINED3DQUERYTYPE_BANDWIDTHTIMINGS:
-        dataSize = sizeof(WINED3DQUERYTYPE_BANDWIDTHTIMINGS);
-        break;
-    case WINED3DQUERYTYPE_CACHEUTILIZATION:
-        dataSize = sizeof(WINED3DDEVINFO_CACHEUTILIZATION);
-        break;
-    default:
-       FIXME("(%p) Unhandled query type %d\n",This , This->type);
-       dataSize = 0;
-    }
-    return dataSize;
 }
 
@@ -469,5 +446,4 @@
 }
 
-
 static HRESULT  WINAPI IWineD3DEventQueryImpl_Issue(IWineD3DQuery* iface,  DWORD dwIssueFlags) {
     IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface;
@@ -477,41 +453,9 @@
     {
         struct wined3d_event_query *query = This->extendedData;
-        struct wined3d_context *context;
-
-        if (query->context)
-        {
-            if (query->context->tid != GetCurrentThreadId())
-            {
-                context_free_event_query(query);
-                context = context_acquire(This->device, NULL, CTXUSAGE_RESOURCELOAD);
-                context_alloc_event_query(context, query);
-            }
-            else
-            {
-                context = context_acquire(This->device, query->context->current_rt, CTXUSAGE_RESOURCELOAD);
-            }
-        }
-        else
-        {
-            context = context_acquire(This->device, NULL, CTXUSAGE_RESOURCELOAD);
-            context_alloc_event_query(context, query);
-        }
-
-        ENTER_GL();
-
-        if (context->gl_info->supported[APPLE_FENCE])
-        {
-            GL_EXTCALL(glSetFenceAPPLE(query->id));
-            checkGLcall("glSetFenceAPPLE");
-        }
-        else if (context->gl_info->supported[NV_FENCE])
-        {
-            GL_EXTCALL(glSetFenceNV(query->id, GL_ALL_COMPLETED_NV));
-            checkGLcall("glSetFenceNV");
-        }
-
-        LEAVE_GL();
-
-        context_release(context);
+
+        /* Faked event query support */
+        if (!query) return WINED3D_OK;
+
+        wined3d_event_query_issue(query, This->device);
     }
     else if(dwIssueFlags & WINED3DISSUE_BEGIN)
@@ -613,41 +557,5 @@
 }
 
-static HRESULT  WINAPI IWineD3DQueryImpl_Issue(IWineD3DQuery* iface,  DWORD dwIssueFlags){
-    IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface;
-
-    TRACE("(%p) : dwIssueFlags %#x, type %#x\n", This, dwIssueFlags, This->type);
-
-    /* The fixme is printed when the app asks for the resulting data */
-    WARN("(%p) : Unhandled query type %#x\n", This, This->type);
-
-    if(dwIssueFlags & WINED3DISSUE_BEGIN) {
-        This->state = QUERY_BUILDING;
-    } else {
-        This->state = QUERY_SIGNALLED;
-    }
-
-    return WINED3D_OK; /* can be WINED3DERR_INVALIDCALL.    */
-}
-
-
-/**********************************************************
- * IWineD3DQuery VTbl follows
- **********************************************************/
-
-const IWineD3DQueryVtbl IWineD3DQuery_Vtbl =
-{
-    /*** IUnknown methods ***/
-    IWineD3DQueryImpl_QueryInterface,
-    IWineD3DQueryImpl_AddRef,
-    IWineD3DQueryImpl_Release,
-     /*** IWineD3Dquery methods ***/
-    IWineD3DQueryImpl_GetParent,
-    IWineD3DQueryImpl_GetData,
-    IWineD3DQueryImpl_GetDataSize,
-    IWineD3DQueryImpl_GetType,
-    IWineD3DQueryImpl_Issue
-};
-
-const IWineD3DQueryVtbl IWineD3DEventQuery_Vtbl =
+static const IWineD3DQueryVtbl IWineD3DEventQuery_Vtbl =
 {
     /*** IUnknown methods ***/
@@ -663,5 +571,5 @@
 };
 
-const IWineD3DQueryVtbl IWineD3DOcclusionQuery_Vtbl =
+static const IWineD3DQueryVtbl IWineD3DOcclusionQuery_Vtbl =
 {
     /*** IUnknown methods ***/
@@ -676,2 +584,71 @@
     IWineD3DOcclusionQueryImpl_Issue
 };
+
+HRESULT query_init(IWineD3DQueryImpl *query, IWineD3DDeviceImpl *device,
+        WINED3DQUERYTYPE type, IUnknown *parent)
+{
+    const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
+
+    switch (type)
+    {
+        case WINED3DQUERYTYPE_OCCLUSION:
+            TRACE("Occlusion query.\n");
+            if (!gl_info->supported[ARB_OCCLUSION_QUERY])
+            {
+                WARN("Unsupported in local OpenGL implementation: ARB_OCCLUSION_QUERY.\n");
+                return WINED3DERR_NOTAVAILABLE;
+            }
+            query->lpVtbl = &IWineD3DOcclusionQuery_Vtbl;
+            query->extendedData = HeapAlloc(GetProcessHeap(), 0, sizeof(struct wined3d_occlusion_query));
+            if (!query->extendedData)
+            {
+                ERR("Failed to allocate occlusion query extended data.\n");
+                return E_OUTOFMEMORY;
+            }
+            ((struct wined3d_occlusion_query *)query->extendedData)->context = NULL;
+            break;
+
+        case WINED3DQUERYTYPE_EVENT:
+            TRACE("Event query.\n");
+            if (!wined3d_event_query_supported(gl_info))
+            {
+                /* Half-Life 2 needs this query. It does not render the main
+                 * menu correctly otherwise. Pretend to support it, faking
+                 * this query does not do much harm except potentially
+                 * lowering performance. */
+                FIXME("Event query: Unimplemented, but pretending to be supported.\n");
+            }
+            query->lpVtbl = &IWineD3DEventQuery_Vtbl;
+            query->extendedData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct wined3d_event_query));
+            if (!query->extendedData)
+            {
+                ERR("Failed to allocate event query memory.\n");
+                return E_OUTOFMEMORY;
+            }
+            break;
+
+        case WINED3DQUERYTYPE_VCACHE:
+        case WINED3DQUERYTYPE_RESOURCEMANAGER:
+        case WINED3DQUERYTYPE_VERTEXSTATS:
+        case WINED3DQUERYTYPE_TIMESTAMP:
+        case WINED3DQUERYTYPE_TIMESTAMPDISJOINT:
+        case WINED3DQUERYTYPE_TIMESTAMPFREQ:
+        case WINED3DQUERYTYPE_PIPELINETIMINGS:
+        case WINED3DQUERYTYPE_INTERFACETIMINGS:
+        case WINED3DQUERYTYPE_VERTEXTIMINGS:
+        case WINED3DQUERYTYPE_PIXELTIMINGS:
+        case WINED3DQUERYTYPE_BANDWIDTHTIMINGS:
+        case WINED3DQUERYTYPE_CACHEUTILIZATION:
+        default:
+            FIXME("Unhandled query type %#x.\n", type);
+            return WINED3DERR_NOTAVAILABLE;
+    }
+
+    query->type = type;
+    query->state = QUERY_CREATED;
+    query->device = device;
+    query->parent = parent;
+    query->ref = 1;
+
+    return WINED3D_OK;
+}
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/resource.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/resource.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/resource.c	(revision 28475)
@@ -38,5 +38,5 @@
 
 HRESULT resource_init(IWineD3DResource *iface, WINED3DRESOURCETYPE resource_type,
-        IWineD3DDeviceImpl *device, UINT size, DWORD usage, const struct GlPixelFormatDesc *format_desc,
+        IWineD3DDeviceImpl *device, UINT size, DWORD usage, const struct wined3d_format_desc *format_desc,
         WINED3DPOOL pool, IUnknown *parent, const struct wined3d_parent_ops *parent_ops)
 {
@@ -257,10 +257,2 @@
     return WINED3D_OK;
 }
-
-void dumpResources(struct list *list) {
-    IWineD3DResourceImpl *resource;
-
-    LIST_FOR_EACH_ENTRY(resource, list, IWineD3DResourceImpl, resource.resource_list_entry) {
-        FIXME("Leftover resource %p with type %d,%s\n", resource, IWineD3DResource_GetType((IWineD3DResource *) resource), debug_d3dresourcetype(IWineD3DResource_GetType((IWineD3DResource *) resource)));
-    }
-}
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/shader.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/shader.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/shader.c	(revision 28475)
@@ -33,11 +33,1439 @@
 
 #include "config.h"
+#include "wine/port.h"
 
 #include <math.h>
 #include <stdio.h>
+#include <string.h>
 
 #include "wined3d_private.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
+WINE_DECLARE_DEBUG_CHANNEL(d3d);
+
+static const char *shader_opcode_names[] =
+{
+    /* WINED3DSIH_ABS           */ "abs",
+    /* WINED3DSIH_ADD           */ "add",
+    /* WINED3DSIH_BEM           */ "bem",
+    /* WINED3DSIH_BREAK         */ "break",
+    /* WINED3DSIH_BREAKC        */ "breakc",
+    /* WINED3DSIH_BREAKP        */ "breakp",
+    /* WINED3DSIH_CALL          */ "call",
+    /* WINED3DSIH_CALLNZ        */ "callnz",
+    /* WINED3DSIH_CMP           */ "cmp",
+    /* WINED3DSIH_CND           */ "cnd",
+    /* WINED3DSIH_CRS           */ "crs",
+    /* WINED3DSIH_CUT           */ "cut",
+    /* WINED3DSIH_DCL           */ "dcl",
+    /* WINED3DSIH_DEF           */ "def",
+    /* WINED3DSIH_DEFB          */ "defb",
+    /* WINED3DSIH_DEFI          */ "defi",
+    /* WINED3DSIH_DP2ADD        */ "dp2add",
+    /* WINED3DSIH_DP3           */ "dp3",
+    /* WINED3DSIH_DP4           */ "dp4",
+    /* WINED3DSIH_DST           */ "dst",
+    /* WINED3DSIH_DSX           */ "dsx",
+    /* WINED3DSIH_DSY           */ "dsy",
+    /* WINED3DSIH_ELSE          */ "else",
+    /* WINED3DSIH_EMIT          */ "emit",
+    /* WINED3DSIH_ENDIF         */ "endif",
+    /* WINED3DSIH_ENDLOOP       */ "endloop",
+    /* WINED3DSIH_ENDREP        */ "endrep",
+    /* WINED3DSIH_EXP           */ "exp",
+    /* WINED3DSIH_EXPP          */ "expp",
+    /* WINED3DSIH_FRC           */ "frc",
+    /* WINED3DSIH_IADD          */ "iadd",
+    /* WINED3DSIH_IF            */ "if",
+    /* WINED3DSIH_IFC           */ "ifc",
+    /* WINED3DSIH_IGE           */ "ige",
+    /* WINED3DSIH_LABEL         */ "label",
+    /* WINED3DSIH_LIT           */ "lit",
+    /* WINED3DSIH_LOG           */ "log",
+    /* WINED3DSIH_LOGP          */ "logp",
+    /* WINED3DSIH_LOOP          */ "loop",
+    /* WINED3DSIH_LRP           */ "lrp",
+    /* WINED3DSIH_LT            */ "lt",
+    /* WINED3DSIH_M3x2          */ "m3x2",
+    /* WINED3DSIH_M3x3          */ "m3x3",
+    /* WINED3DSIH_M3x4          */ "m3x4",
+    /* WINED3DSIH_M4x3          */ "m4x3",
+    /* WINED3DSIH_M4x4          */ "m4x4",
+    /* WINED3DSIH_MAD           */ "mad",
+    /* WINED3DSIH_MAX           */ "max",
+    /* WINED3DSIH_MIN           */ "min",
+    /* WINED3DSIH_MOV           */ "mov",
+    /* WINED3DSIH_MOVA          */ "mova",
+    /* WINED3DSIH_MUL           */ "mul",
+    /* WINED3DSIH_NOP           */ "nop",
+    /* WINED3DSIH_NRM           */ "nrm",
+    /* WINED3DSIH_PHASE         */ "phase",
+    /* WINED3DSIH_POW           */ "pow",
+    /* WINED3DSIH_RCP           */ "rcp",
+    /* WINED3DSIH_REP           */ "rep",
+    /* WINED3DSIH_RET           */ "ret",
+    /* WINED3DSIH_RSQ           */ "rsq",
+    /* WINED3DSIH_SETP          */ "setp",
+    /* WINED3DSIH_SGE           */ "sge",
+    /* WINED3DSIH_SGN           */ "sgn",
+    /* WINED3DSIH_SINCOS        */ "sincos",
+    /* WINED3DSIH_SLT           */ "slt",
+    /* WINED3DSIH_SUB           */ "sub",
+    /* WINED3DSIH_TEX           */ "texld",
+    /* WINED3DSIH_TEXBEM        */ "texbem",
+    /* WINED3DSIH_TEXBEML       */ "texbeml",
+    /* WINED3DSIH_TEXCOORD      */ "texcrd",
+    /* WINED3DSIH_TEXDEPTH      */ "texdepth",
+    /* WINED3DSIH_TEXDP3        */ "texdp3",
+    /* WINED3DSIH_TEXDP3TEX     */ "texdp3tex",
+    /* WINED3DSIH_TEXKILL       */ "texkill",
+    /* WINED3DSIH_TEXLDD        */ "texldd",
+    /* WINED3DSIH_TEXLDL        */ "texldl",
+    /* WINED3DSIH_TEXM3x2DEPTH  */ "texm3x2depth",
+    /* WINED3DSIH_TEXM3x2PAD    */ "texm3x2pad",
+    /* WINED3DSIH_TEXM3x2TEX    */ "texm3x2tex",
+    /* WINED3DSIH_TEXM3x3       */ "texm3x3",
+    /* WINED3DSIH_TEXM3x3DIFF   */ "texm3x3diff",
+    /* WINED3DSIH_TEXM3x3PAD    */ "texm3x3pad",
+    /* WINED3DSIH_TEXM3x3SPEC   */ "texm3x3spec",
+    /* WINED3DSIH_TEXM3x3TEX    */ "texm3x3tex",
+    /* WINED3DSIH_TEXM3x3VSPEC  */ "texm3x3vspec",
+    /* WINED3DSIH_TEXREG2AR     */ "texreg2ar",
+    /* WINED3DSIH_TEXREG2GB     */ "texreg2gb",
+    /* WINED3DSIH_TEXREG2RGB    */ "texreg2rgb",
+};
+
+static const char *semantic_names[] =
+{
+    /* WINED3DDECLUSAGE_POSITION        */ "SV_POSITION",
+    /* WINED3DDECLUSAGE_BLENDWEIGHT     */ "BLENDWEIGHT",
+    /* WINED3DDECLUSAGE_BLENDINDICES    */ "BLENDINDICES",
+    /* WINED3DDECLUSAGE_NORMAL          */ "NORMAL",
+    /* WINED3DDECLUSAGE_PSIZE           */ "PSIZE",
+    /* WINED3DDECLUSAGE_TEXCOORD        */ "TEXCOORD",
+    /* WINED3DDECLUSAGE_TANGENT         */ "TANGENT",
+    /* WINED3DDECLUSAGE_BINORMAL        */ "BINORMAL",
+    /* WINED3DDECLUSAGE_TESSFACTOR      */ "TESSFACTOR",
+    /* WINED3DDECLUSAGE_POSITIONT       */ "POSITIONT",
+    /* WINED3DDECLUSAGE_COLOR           */ "COLOR",
+    /* WINED3DDECLUSAGE_FOG             */ "FOG",
+    /* WINED3DDECLUSAGE_DEPTH           */ "DEPTH",
+    /* WINED3DDECLUSAGE_SAMPLE          */ "SAMPLE",
+};
+
+static const char *shader_semantic_name_from_usage(WINED3DDECLUSAGE usage)
+{
+    if (usage >= sizeof(semantic_names) / sizeof(*semantic_names))
+    {
+        FIXME("Unrecognized usage %#x.\n", usage);
+        return "UNRECOGNIZED";
+    }
+
+    return semantic_names[usage];
+}
+
+static WINED3DDECLUSAGE shader_usage_from_semantic_name(const char *name)
+{
+    unsigned int i;
+
+    for (i = 0; i < sizeof(semantic_names) / sizeof(*semantic_names); ++i)
+    {
+        if (!strcmp(name, semantic_names[i])) return i;
+    }
+
+    return ~0U;
+}
+
+BOOL shader_match_semantic(const char *semantic_name, WINED3DDECLUSAGE usage)
+{
+    return !strcmp(semantic_name, shader_semantic_name_from_usage(usage));
+}
+
+static void shader_signature_from_semantic(struct wined3d_shader_signature_element *e,
+        const struct wined3d_shader_semantic *s)
+{
+    e->semantic_name = shader_semantic_name_from_usage(s->usage);
+    e->semantic_idx = s->usage_idx;
+    e->sysval_semantic = 0;
+    e->component_type = 0;
+    e->register_idx = s->reg.reg.idx;
+    e->mask = s->reg.write_mask;
+}
+
+static const struct wined3d_shader_frontend *shader_select_frontend(DWORD version_token)
+{
+    switch (version_token >> 16)
+    {
+        case WINED3D_SM1_VS:
+        case WINED3D_SM1_PS:
+            return &sm1_shader_frontend;
+
+        case WINED3D_SM4_PS:
+        case WINED3D_SM4_VS:
+        case WINED3D_SM4_GS:
+            return &sm4_shader_frontend;
+
+        default:
+            FIXME("Unrecognised version token %#x\n", version_token);
+            return NULL;
+    }
+}
+
+void shader_buffer_clear(struct wined3d_shader_buffer *buffer)
+{
+    buffer->buffer[0] = '\0';
+    buffer->bsize = 0;
+    buffer->lineNo = 0;
+    buffer->newline = TRUE;
+}
+
+BOOL shader_buffer_init(struct wined3d_shader_buffer *buffer)
+{
+    buffer->buffer = HeapAlloc(GetProcessHeap(), 0, SHADER_PGMSIZE);
+    if (!buffer->buffer)
+    {
+        ERR("Failed to allocate shader buffer memory.\n");
+        return FALSE;
+    }
+
+    shader_buffer_clear(buffer);
+    return TRUE;
+}
+
+void shader_buffer_free(struct wined3d_shader_buffer *buffer)
+{
+    HeapFree(GetProcessHeap(), 0, buffer->buffer);
+}
+
+int shader_vaddline(struct wined3d_shader_buffer *buffer, const char *format, va_list args)
+{
+    char *base = buffer->buffer + buffer->bsize;
+    int rc;
+
+    rc = vsnprintf(base, SHADER_PGMSIZE - 1 - buffer->bsize, format, args);
+
+    if (rc < 0 /* C89 */ || (unsigned int)rc > SHADER_PGMSIZE - 1 - buffer->bsize /* C99 */)
+    {
+        ERR("The buffer allocated for the shader program string "
+            "is too small at %d bytes.\n", SHADER_PGMSIZE);
+        buffer->bsize = SHADER_PGMSIZE - 1;
+        return -1;
+    }
+
+    if (buffer->newline)
+    {
+        TRACE("GL HW (%u, %u) : %s", buffer->lineNo + 1, buffer->bsize, base);
+        buffer->newline = FALSE;
+    }
+    else
+    {
+        TRACE("%s", base);
+    }
+
+    buffer->bsize += rc;
+    if (buffer->buffer[buffer->bsize-1] == '\n')
+    {
+        ++buffer->lineNo;
+        buffer->newline = TRUE;
+    }
+
+    return 0;
+}
+
+int shader_addline(struct wined3d_shader_buffer *buffer, const char *format, ...)
+{
+    va_list args;
+    int ret;
+
+    va_start(args, format);
+    ret = shader_vaddline(buffer, format, args);
+    va_end(args);
+
+    return ret;
+}
+
+static void shader_init(struct IWineD3DBaseShaderClass *shader, IWineD3DDeviceImpl *device,
+        IUnknown *parent, const struct wined3d_parent_ops *parent_ops)
+{
+    shader->ref = 1;
+    shader->device = (IWineD3DDevice *)device;
+    shader->parent = parent;
+    shader->parent_ops = parent_ops;
+    list_init(&shader->linked_programs);
+    list_add_head(&device->shaders, &shader->shader_list_entry);
+}
+
+/* Convert floating point offset relative to a register file to an absolute
+ * offset for float constants. */
+static unsigned int shader_get_float_offset(WINED3DSHADER_PARAM_REGISTER_TYPE register_type, UINT register_idx)
+{
+    switch (register_type)
+    {
+        case WINED3DSPR_CONST: return register_idx;
+        case WINED3DSPR_CONST2: return 2048 + register_idx;
+        case WINED3DSPR_CONST3: return 4096 + register_idx;
+        case WINED3DSPR_CONST4: return 6144 + register_idx;
+        default:
+            FIXME("Unsupported register type: %u.\n", register_type);
+            return register_idx;
+    }
+}
+
+static void shader_delete_constant_list(struct list *clist)
+{
+    struct local_constant *constant;
+    struct list *ptr;
+
+    ptr = list_head(clist);
+    while (ptr)
+    {
+        constant = LIST_ENTRY(ptr, struct local_constant, entry);
+        ptr = list_next(clist, ptr);
+        HeapFree(GetProcessHeap(), 0, constant);
+    }
+    list_init(clist);
+}
+
+static inline void set_bitmap_bit(DWORD *bitmap, DWORD bit)
+{
+    DWORD idx, shift;
+    idx = bit >> 5;
+    shift = bit & 0x1f;
+    bitmap[idx] |= (1 << shift);
+}
+
+static void shader_record_register_usage(IWineD3DBaseShaderImpl *shader, struct shader_reg_maps *reg_maps,
+        const struct wined3d_shader_register *reg, enum wined3d_shader_type shader_type)
+{
+    switch (reg->type)
+    {
+        case WINED3DSPR_TEXTURE: /* WINED3DSPR_ADDR */
+            if (shader_type == WINED3D_SHADER_TYPE_PIXEL) reg_maps->texcoord |= 1 << reg->idx;
+            else reg_maps->address |= 1 << reg->idx;
+            break;
+
+        case WINED3DSPR_TEMP:
+            reg_maps->temporary |= 1 << reg->idx;
+            break;
+
+        case WINED3DSPR_INPUT:
+            if (shader_type == WINED3D_SHADER_TYPE_PIXEL)
+            {
+                if (reg->rel_addr)
+                {
+                    /* If relative addressing is used, we must assume that all registers
+                     * are used. Even if it is a construct like v3[aL], we can't assume
+                     * that v0, v1 and v2 aren't read because aL can be negative */
+                    unsigned int i;
+                    for (i = 0; i < MAX_REG_INPUT; ++i)
+                    {
+                        ((IWineD3DPixelShaderImpl *)shader)->input_reg_used[i] = TRUE;
+                    }
+                }
+                else
+                {
+                    ((IWineD3DPixelShaderImpl *)shader)->input_reg_used[reg->idx] = TRUE;
+                }
+            }
+            else reg_maps->input_registers |= 1 << reg->idx;
+            break;
+
+        case WINED3DSPR_RASTOUT:
+            if (reg->idx == 1) reg_maps->fog = 1;
+            break;
+
+        case WINED3DSPR_MISCTYPE:
+            if (shader_type == WINED3D_SHADER_TYPE_PIXEL)
+            {
+                if (reg->idx == 0) reg_maps->vpos = 1;
+                else if (reg->idx == 1) reg_maps->usesfacing = 1;
+            }
+            break;
+
+        case WINED3DSPR_CONST:
+            if (reg->rel_addr)
+            {
+                if (shader_type != WINED3D_SHADER_TYPE_PIXEL)
+                {
+                    if (reg->idx < ((IWineD3DVertexShaderImpl *)shader)->min_rel_offset)
+                    {
+                        ((IWineD3DVertexShaderImpl *)shader)->min_rel_offset = reg->idx;
+                    }
+                    if (reg->idx > ((IWineD3DVertexShaderImpl *)shader)->max_rel_offset)
+                    {
+                        ((IWineD3DVertexShaderImpl *)shader)->max_rel_offset = reg->idx;
+                    }
+                }
+                reg_maps->usesrelconstF = TRUE;
+            }
+            else
+            {
+                set_bitmap_bit(reg_maps->constf, reg->idx);
+            }
+            break;
+
+        case WINED3DSPR_CONSTINT:
+            reg_maps->integer_constants |= (1 << reg->idx);
+            break;
+
+        case WINED3DSPR_CONSTBOOL:
+            reg_maps->boolean_constants |= (1 << reg->idx);
+            break;
+
+        case WINED3DSPR_COLOROUT:
+            reg_maps->highest_render_target = max(reg_maps->highest_render_target, reg->idx);
+            break;
+
+        default:
+            TRACE("Not recording register of type %#x and idx %u\n", reg->type, reg->idx);
+            break;
+    }
+}
+
+static unsigned int get_instr_extra_regcount(enum WINED3D_SHADER_INSTRUCTION_HANDLER instr, unsigned int param)
+{
+    switch (instr)
+    {
+        case WINED3DSIH_M4x4:
+        case WINED3DSIH_M3x4:
+            return param == 1 ? 3 : 0;
+
+        case WINED3DSIH_M4x3:
+        case WINED3DSIH_M3x3:
+            return param == 1 ? 2 : 0;
+
+        case WINED3DSIH_M3x2:
+            return param == 1 ? 1 : 0;
+
+        default:
+            return 0;
+    }
+}
+
+/* Note that this does not count the loop register as an address register. */
+static HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3d_shader_frontend *fe,
+        struct shader_reg_maps *reg_maps, struct wined3d_shader_signature_element *input_signature,
+        struct wined3d_shader_signature_element *output_signature, const DWORD *byte_code, DWORD constf_size)
+{
+    IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)iface;
+    unsigned int cur_loop_depth = 0, max_loop_depth = 0;
+    void *fe_data = shader->baseShader.frontend_data;
+    struct wined3d_shader_version shader_version;
+    const DWORD *ptr = byte_code;
+
+    memset(reg_maps, 0, sizeof(*reg_maps));
+
+    /* get_registers_used() is called on every compile on some 1.x shaders,
+     * which can result in stacking up a collection of local constants.
+     * Delete the old constants if existing. */
+    shader_delete_constant_list(&shader->baseShader.constantsF);
+    shader_delete_constant_list(&shader->baseShader.constantsB);
+    shader_delete_constant_list(&shader->baseShader.constantsI);
+
+    fe->shader_read_header(fe_data, &ptr, &shader_version);
+    reg_maps->shader_version = shader_version;
+
+    reg_maps->constf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
+            sizeof(*reg_maps->constf) * ((constf_size + 31) / 32));
+    if (!reg_maps->constf)
+    {
+        ERR("Failed to allocate constant map memory.\n");
+        return E_OUTOFMEMORY;
+    }
+
+    while (!fe->shader_is_end(fe_data, &ptr))
+    {
+        struct wined3d_shader_instruction ins;
+        const char *comment;
+        UINT comment_size;
+        UINT param_size;
+
+        /* Skip comments. */
+        fe->shader_read_comment(&ptr, &comment, &comment_size);
+        if (comment) continue;
+
+        /* Fetch opcode. */
+        fe->shader_read_opcode(fe_data, &ptr, &ins, &param_size);
+
+        /* Unhandled opcode, and its parameters. */
+        if (ins.handler_idx == WINED3DSIH_TABLE_SIZE)
+        {
+            TRACE("Skipping unrecognized instruction.\n");
+            ptr += param_size;
+            continue;
+        }
+
+        /* Handle declarations. */
+        if (ins.handler_idx == WINED3DSIH_DCL)
+        {
+            struct wined3d_shader_semantic semantic;
+
+            fe->shader_read_semantic(&ptr, &semantic);
+
+            switch (semantic.reg.reg.type)
+            {
+                /* Mark input registers used. */
+                case WINED3DSPR_INPUT:
+                    reg_maps->input_registers |= 1 << semantic.reg.reg.idx;
+                    shader_signature_from_semantic(&input_signature[semantic.reg.reg.idx], &semantic);
+                    break;
+
+                /* Vertex shader: mark 3.0 output registers used, save token. */
+                case WINED3DSPR_OUTPUT:
+                    reg_maps->output_registers |= 1 << semantic.reg.reg.idx;
+                    shader_signature_from_semantic(&output_signature[semantic.reg.reg.idx], &semantic);
+                    if (semantic.usage == WINED3DDECLUSAGE_FOG) reg_maps->fog = 1;
+                    break;
+
+                /* Save sampler usage token. */
+                case WINED3DSPR_SAMPLER:
+                    reg_maps->sampler_type[semantic.reg.reg.idx] = semantic.sampler_type;
+                    break;
+
+                default:
+                    TRACE("Not recording DCL register type %#x.\n", semantic.reg.reg.type);
+                    break;
+            }
+        }
+        else if (ins.handler_idx == WINED3DSIH_DEF)
+        {
+            struct wined3d_shader_src_param rel_addr;
+            struct wined3d_shader_dst_param dst;
+
+            local_constant *lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant));
+            if (!lconst) return E_OUTOFMEMORY;
+
+            fe->shader_read_dst_param(fe_data, &ptr, &dst, &rel_addr);
+            lconst->idx = dst.reg.idx;
+
+            memcpy(lconst->value, ptr, 4 * sizeof(DWORD));
+            ptr += 4;
+
+            /* In pixel shader 1.X shaders, the constants are clamped between [-1;1] */
+            if (shader_version.major == 1 && shader_version.type == WINED3D_SHADER_TYPE_PIXEL)
+            {
+                float *value = (float *)lconst->value;
+                if (value[0] < -1.0f) value[0] = -1.0f;
+                else if (value[0] > 1.0f) value[0] = 1.0f;
+                if (value[1] < -1.0f) value[1] = -1.0f;
+                else if (value[1] > 1.0f) value[1] = 1.0f;
+                if (value[2] < -1.0f) value[2] = -1.0f;
+                else if (value[2] > 1.0f) value[2] = 1.0f;
+                if (value[3] < -1.0f) value[3] = -1.0f;
+                else if (value[3] > 1.0f) value[3] = 1.0f;
+            }
+
+            list_add_head(&shader->baseShader.constantsF, &lconst->entry);
+        }
+        else if (ins.handler_idx == WINED3DSIH_DEFI)
+        {
+            struct wined3d_shader_src_param rel_addr;
+            struct wined3d_shader_dst_param dst;
+
+            local_constant *lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant));
+            if (!lconst) return E_OUTOFMEMORY;
+
+            fe->shader_read_dst_param(fe_data, &ptr, &dst, &rel_addr);
+            lconst->idx = dst.reg.idx;
+
+            memcpy(lconst->value, ptr, 4 * sizeof(DWORD));
+            ptr += 4;
+
+            list_add_head(&shader->baseShader.constantsI, &lconst->entry);
+            reg_maps->local_int_consts |= (1 << dst.reg.idx);
+        }
+        else if (ins.handler_idx == WINED3DSIH_DEFB)
+        {
+            struct wined3d_shader_src_param rel_addr;
+            struct wined3d_shader_dst_param dst;
+
+            local_constant *lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant));
+            if (!lconst) return E_OUTOFMEMORY;
+
+            fe->shader_read_dst_param(fe_data, &ptr, &dst, &rel_addr);
+            lconst->idx = dst.reg.idx;
+
+            memcpy(lconst->value, ptr, sizeof(DWORD));
+            ++ptr;
+
+            list_add_head(&shader->baseShader.constantsB, &lconst->entry);
+            reg_maps->local_bool_consts |= (1 << dst.reg.idx);
+        }
+        /* If there's a loop in the shader. */
+        else if (ins.handler_idx == WINED3DSIH_LOOP
+                || ins.handler_idx == WINED3DSIH_REP)
+        {
+            struct wined3d_shader_src_param src, rel_addr;
+
+            fe->shader_read_src_param(fe_data, &ptr, &src, &rel_addr);
+
+            /* Rep and Loop always use an integer constant for the control parameters. */
+            if (ins.handler_idx == WINED3DSIH_REP)
+            {
+                reg_maps->integer_constants |= 1 << src.reg.idx;
+            }
+            else
+            {
+                fe->shader_read_src_param(fe_data, &ptr, &src, &rel_addr);
+                reg_maps->integer_constants |= 1 << src.reg.idx;
+            }
+
+            cur_loop_depth++;
+            if (cur_loop_depth > max_loop_depth) max_loop_depth = cur_loop_depth;
+        }
+        else if (ins.handler_idx == WINED3DSIH_ENDLOOP
+                || ins.handler_idx == WINED3DSIH_ENDREP)
+        {
+            cur_loop_depth--;
+        }
+        /* For subroutine prototypes. */
+        else if (ins.handler_idx == WINED3DSIH_LABEL)
+        {
+            struct wined3d_shader_src_param src, rel_addr;
+
+            fe->shader_read_src_param(fe_data, &ptr, &src, &rel_addr);
+            reg_maps->labels |= 1 << src.reg.idx;
+        }
+        /* Set texture, address, temporary registers. */
+        else
+        {
+            BOOL color0_mov = FALSE;
+            int i, limit;
+
+            /* This will loop over all the registers and try to
+             * make a bitmask of the ones we're interested in.
+             *
+             * Relative addressing tokens are ignored, but that's
+             * okay, since we'll catch any address registers when
+             * they are initialized (required by spec). */
+            if (ins.dst_count)
+            {
+                struct wined3d_shader_src_param dst_rel_addr;
+                struct wined3d_shader_dst_param dst_param;
+
+                fe->shader_read_dst_param(fe_data, &ptr, &dst_param, &dst_rel_addr);
+
+                shader_record_register_usage(shader, reg_maps, &dst_param.reg, shader_version.type);
+
+                /* WINED3DSPR_TEXCRDOUT is the same as WINED3DSPR_OUTPUT. _OUTPUT can be > MAX_REG_TEXCRD and
+                 * is used in >= 3.0 shaders. Filter 3.0 shaders to prevent overflows, and also filter pixel
+                 * shaders because TECRDOUT isn't used in them, but future register types might cause issues */
+                if (shader_version.type == WINED3D_SHADER_TYPE_VERTEX && shader_version.major < 3
+                        && dst_param.reg.type == WINED3DSPR_TEXCRDOUT)
+                {
+                    reg_maps->texcoord_mask[dst_param.reg.idx] |= dst_param.write_mask;
+                }
+
+                if (shader_version.type == WINED3D_SHADER_TYPE_PIXEL)
+                {
+                    IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *)shader;
+
+                    if (dst_param.reg.type == WINED3DSPR_COLOROUT && dst_param.reg.idx == 0)
+                    {
+                    /* Many 2.0 and 3.0 pixel shaders end with a MOV from a temp register to
+                     * COLOROUT 0. If we know this in advance, the ARB shader backend can skip
+                     * the mov and perform the sRGB write correction from the source register.
+                     *
+                     * However, if the mov is only partial, we can't do this, and if the write
+                     * comes from an instruction other than MOV it is hard to do as well. If
+                     * COLOROUT 0 is overwritten partially later, the marker is dropped again. */
+
+                        ps->color0_mov = FALSE;
+                        if (ins.handler_idx == WINED3DSIH_MOV)
+                        {
+                            /* Used later when the source register is read. */
+                            color0_mov = TRUE;
+                        }
+                    }
+                    /* Also drop the MOV marker if the source register is overwritten prior to the shader
+                     * end
+                     */
+                    else if (dst_param.reg.type == WINED3DSPR_TEMP && dst_param.reg.idx == ps->color0_reg)
+                    {
+                        ps->color0_mov = FALSE;
+                    }
+                }
+
+                /* Declare 1.x samplers implicitly, based on the destination reg. number. */
+                if (shader_version.major == 1
+                        && (ins.handler_idx == WINED3DSIH_TEX
+                            || ins.handler_idx == WINED3DSIH_TEXBEM
+                            || ins.handler_idx == WINED3DSIH_TEXBEML
+                            || ins.handler_idx == WINED3DSIH_TEXDP3TEX
+                            || ins.handler_idx == WINED3DSIH_TEXM3x2TEX
+                            || ins.handler_idx == WINED3DSIH_TEXM3x3SPEC
+                            || ins.handler_idx == WINED3DSIH_TEXM3x3TEX
+                            || ins.handler_idx == WINED3DSIH_TEXM3x3VSPEC
+                            || ins.handler_idx == WINED3DSIH_TEXREG2AR
+                            || ins.handler_idx == WINED3DSIH_TEXREG2GB
+                            || ins.handler_idx == WINED3DSIH_TEXREG2RGB))
+                {
+                    /* Fake sampler usage, only set reserved bit and type. */
+                    DWORD sampler_code = dst_param.reg.idx;
+
+                    TRACE("Setting fake 2D sampler for 1.x pixelshader.\n");
+                    reg_maps->sampler_type[sampler_code] = WINED3DSTT_2D;
+
+                    /* texbem is only valid with < 1.4 pixel shaders */
+                    if (ins.handler_idx == WINED3DSIH_TEXBEM
+                            || ins.handler_idx == WINED3DSIH_TEXBEML)
+                    {
+                        reg_maps->bumpmat |= 1 << dst_param.reg.idx;
+                        if (ins.handler_idx == WINED3DSIH_TEXBEML)
+                        {
+                            reg_maps->luminanceparams |= 1 << dst_param.reg.idx;
+                        }
+                    }
+                }
+                else if (ins.handler_idx == WINED3DSIH_BEM)
+                {
+                    reg_maps->bumpmat |= 1 << dst_param.reg.idx;
+                }
+            }
+
+            if (ins.handler_idx == WINED3DSIH_NRM) reg_maps->usesnrm = 1;
+            else if (ins.handler_idx == WINED3DSIH_DSY) reg_maps->usesdsy = 1;
+            else if (ins.handler_idx == WINED3DSIH_DSX) reg_maps->usesdsx = 1;
+            else if (ins.handler_idx == WINED3DSIH_TEXLDD) reg_maps->usestexldd = 1;
+            else if (ins.handler_idx == WINED3DSIH_TEXLDL) reg_maps->usestexldl = 1;
+            else if (ins.handler_idx == WINED3DSIH_MOVA) reg_maps->usesmova = 1;
+            else if (ins.handler_idx == WINED3DSIH_IFC) reg_maps->usesifc = 1;
+            else if (ins.handler_idx == WINED3DSIH_CALL) reg_maps->usescall = 1;
+
+            limit = ins.src_count + (ins.predicate ? 1 : 0);
+            for (i = 0; i < limit; ++i)
+            {
+                struct wined3d_shader_src_param src_param, src_rel_addr;
+                unsigned int count;
+
+                fe->shader_read_src_param(fe_data, &ptr, &src_param, &src_rel_addr);
+                count = get_instr_extra_regcount(ins.handler_idx, i);
+
+                shader_record_register_usage(shader, reg_maps, &src_param.reg, shader_version.type);
+                while (count)
+                {
+                    ++src_param.reg.idx;
+                    shader_record_register_usage(shader, reg_maps, &src_param.reg, shader_version.type);
+                    --count;
+                }
+
+                if (color0_mov)
+                {
+                    IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *)shader;
+                    if (src_param.reg.type == WINED3DSPR_TEMP
+                            && src_param.swizzle == WINED3DSP_NOSWIZZLE)
+                    {
+                        ps->color0_mov = TRUE;
+                        ps->color0_reg = src_param.reg.idx;
+                    }
+                }
+            }
+        }
+    }
+    reg_maps->loop_depth = max_loop_depth;
+
+    shader->baseShader.functionLength = ((const char *)ptr - (const char *)byte_code);
+
+    return WINED3D_OK;
+}
+
+unsigned int shader_find_free_input_register(const struct shader_reg_maps *reg_maps, unsigned int max)
+{
+    DWORD map = 1 << max;
+    map |= map - 1;
+    map &= reg_maps->shader_version.major < 3 ? ~reg_maps->texcoord : ~reg_maps->input_registers;
+
+    return wined3d_log2i(map);
+}
+
+static void shader_dump_decl_usage(const struct wined3d_shader_semantic *semantic,
+        const struct wined3d_shader_version *shader_version)
+{
+    TRACE("dcl");
+
+    if (semantic->reg.reg.type == WINED3DSPR_SAMPLER)
+    {
+        switch (semantic->sampler_type)
+        {
+            case WINED3DSTT_2D: TRACE("_2d"); break;
+            case WINED3DSTT_CUBE: TRACE("_cube"); break;
+            case WINED3DSTT_VOLUME: TRACE("_volume"); break;
+            default: TRACE("_unknown_ttype(0x%08x)", semantic->sampler_type);
+        }
+    }
+    else
+    {
+        /* Pixel shaders 3.0 don't have usage semantics. */
+        if (shader_version->major < 3 && shader_version->type == WINED3D_SHADER_TYPE_PIXEL) return;
+        else TRACE("_");
+
+        switch (semantic->usage)
+        {
+            case WINED3DDECLUSAGE_POSITION:
+                TRACE("position%u", semantic->usage_idx);
+                break;
+
+            case WINED3DDECLUSAGE_BLENDINDICES:
+                TRACE("blend");
+                break;
+
+            case WINED3DDECLUSAGE_BLENDWEIGHT:
+                TRACE("weight");
+                break;
+
+            case WINED3DDECLUSAGE_NORMAL:
+                TRACE("normal%u", semantic->usage_idx);
+                break;
+
+            case WINED3DDECLUSAGE_PSIZE:
+                TRACE("psize");
+                break;
+
+            case WINED3DDECLUSAGE_COLOR:
+                if (semantic->usage_idx == 0) TRACE("color");
+                else TRACE("specular%u", (semantic->usage_idx - 1));
+                break;
+
+            case WINED3DDECLUSAGE_TEXCOORD:
+                TRACE("texture%u", semantic->usage_idx);
+                break;
+
+            case WINED3DDECLUSAGE_TANGENT:
+                TRACE("tangent");
+                break;
+
+            case WINED3DDECLUSAGE_BINORMAL:
+                TRACE("binormal");
+                break;
+
+            case WINED3DDECLUSAGE_TESSFACTOR:
+                TRACE("tessfactor");
+                break;
+
+            case WINED3DDECLUSAGE_POSITIONT:
+                TRACE("positionT%u", semantic->usage_idx);
+                break;
+
+            case WINED3DDECLUSAGE_FOG:
+                TRACE("fog");
+                break;
+
+            case WINED3DDECLUSAGE_DEPTH:
+                TRACE("depth");
+                break;
+
+            case WINED3DDECLUSAGE_SAMPLE:
+                TRACE("sample");
+                break;
+
+            default:
+                FIXME("unknown_semantics(0x%08x)", semantic->usage);
+        }
+    }
+}
+
+static void shader_dump_register(const struct wined3d_shader_register *reg,
+        const struct wined3d_shader_version *shader_version)
+{
+    static const char * const rastout_reg_names[] = {"oPos", "oFog", "oPts"};
+    static const char * const misctype_reg_names[] = {"vPos", "vFace"};
+    UINT offset = reg->idx;
+
+    switch (reg->type)
+    {
+        case WINED3DSPR_TEMP:
+            TRACE("r");
+            break;
+
+        case WINED3DSPR_INPUT:
+            TRACE("v");
+            break;
+
+        case WINED3DSPR_CONST:
+        case WINED3DSPR_CONST2:
+        case WINED3DSPR_CONST3:
+        case WINED3DSPR_CONST4:
+            TRACE("c");
+            offset = shader_get_float_offset(reg->type, reg->idx);
+            break;
+
+        case WINED3DSPR_TEXTURE: /* vs: case WINED3DSPR_ADDR */
+            TRACE("%c", shader_version->type == WINED3D_SHADER_TYPE_PIXEL ? 't' : 'a');
+            break;
+
+        case WINED3DSPR_RASTOUT:
+            TRACE("%s", rastout_reg_names[reg->idx]);
+            break;
+
+        case WINED3DSPR_COLOROUT:
+            TRACE("oC");
+            break;
+
+        case WINED3DSPR_DEPTHOUT:
+            TRACE("oDepth");
+            break;
+
+        case WINED3DSPR_ATTROUT:
+            TRACE("oD");
+            break;
+
+        case WINED3DSPR_TEXCRDOUT:
+            /* Vertex shaders >= 3.0 use general purpose output registers
+             * (WINED3DSPR_OUTPUT), which can include an address token. */
+            if (shader_version->major >= 3) TRACE("o");
+            else TRACE("oT");
+            break;
+
+        case WINED3DSPR_CONSTINT:
+            TRACE("i");
+            break;
+
+        case WINED3DSPR_CONSTBOOL:
+            TRACE("b");
+            break;
+
+        case WINED3DSPR_LABEL:
+            TRACE("l");
+            break;
+
+        case WINED3DSPR_LOOP:
+            TRACE("aL");
+            break;
+
+        case WINED3DSPR_SAMPLER:
+            TRACE("s");
+            break;
+
+        case WINED3DSPR_MISCTYPE:
+            if (reg->idx > 1) FIXME("Unhandled misctype register %u.\n", reg->idx);
+            else TRACE("%s", misctype_reg_names[reg->idx]);
+            break;
+
+        case WINED3DSPR_PREDICATE:
+            TRACE("p");
+            break;
+
+        case WINED3DSPR_IMMCONST:
+            TRACE("l");
+            break;
+
+        case WINED3DSPR_CONSTBUFFER:
+            TRACE("cb");
+            break;
+
+        default:
+            TRACE("unhandled_rtype(%#x)", reg->type);
+            break;
+    }
+
+    if (reg->type == WINED3DSPR_IMMCONST)
+    {
+        TRACE("(");
+        switch (reg->immconst_type)
+        {
+            case WINED3D_IMMCONST_FLOAT:
+                TRACE("%.8e", *(const float *)reg->immconst_data);
+                break;
+
+            case WINED3D_IMMCONST_FLOAT4:
+                TRACE("%.8e, %.8e, %.8e, %.8e",
+                        *(const float *)&reg->immconst_data[0], *(const float *)&reg->immconst_data[1],
+                        *(const float *)&reg->immconst_data[2], *(const float *)&reg->immconst_data[3]);
+                break;
+
+            default:
+                TRACE("<unhandled immconst_type %#x>", reg->immconst_type);
+                break;
+        }
+        TRACE(")");
+    }
+    else if (reg->type != WINED3DSPR_RASTOUT && reg->type != WINED3DSPR_MISCTYPE)
+    {
+        if (reg->array_idx != ~0U)
+        {
+            TRACE("%u[%u", offset, reg->array_idx);
+            if (reg->rel_addr)
+            {
+                TRACE(" + ");
+                shader_dump_src_param(reg->rel_addr, shader_version);
+            }
+            TRACE("]");
+        }
+        else
+        {
+            if (reg->rel_addr)
+            {
+                TRACE("[");
+                shader_dump_src_param(reg->rel_addr, shader_version);
+                TRACE(" + ");
+            }
+            TRACE("%u", offset);
+            if (reg->rel_addr) TRACE("]");
+        }
+    }
+}
+
+void shader_dump_dst_param(const struct wined3d_shader_dst_param *param,
+        const struct wined3d_shader_version *shader_version)
+{
+    DWORD write_mask = param->write_mask;
+
+    shader_dump_register(&param->reg, shader_version);
+
+    if (write_mask != WINED3DSP_WRITEMASK_ALL)
+    {
+        static const char *write_mask_chars = "xyzw";
+
+        TRACE(".");
+        if (write_mask & WINED3DSP_WRITEMASK_0) TRACE("%c", write_mask_chars[0]);
+        if (write_mask & WINED3DSP_WRITEMASK_1) TRACE("%c", write_mask_chars[1]);
+        if (write_mask & WINED3DSP_WRITEMASK_2) TRACE("%c", write_mask_chars[2]);
+        if (write_mask & WINED3DSP_WRITEMASK_3) TRACE("%c", write_mask_chars[3]);
+    }
+}
+
+void shader_dump_src_param(const struct wined3d_shader_src_param *param,
+        const struct wined3d_shader_version *shader_version)
+{
+    DWORD src_modifier = param->modifiers;
+    DWORD swizzle = param->swizzle;
+
+    if (src_modifier == WINED3DSPSM_NEG
+            || src_modifier == WINED3DSPSM_BIASNEG
+            || src_modifier == WINED3DSPSM_SIGNNEG
+            || src_modifier == WINED3DSPSM_X2NEG
+            || src_modifier == WINED3DSPSM_ABSNEG)
+        TRACE("-");
+    else if (src_modifier == WINED3DSPSM_COMP)
+        TRACE("1-");
+    else if (src_modifier == WINED3DSPSM_NOT)
+        TRACE("!");
+
+    if (src_modifier == WINED3DSPSM_ABS || src_modifier == WINED3DSPSM_ABSNEG)
+        TRACE("abs(");
+
+    shader_dump_register(&param->reg, shader_version);
+
+    if (src_modifier)
+    {
+        switch (src_modifier)
+        {
+            case WINED3DSPSM_NONE:    break;
+            case WINED3DSPSM_NEG:     break;
+            case WINED3DSPSM_NOT:     break;
+            case WINED3DSPSM_BIAS:    TRACE("_bias"); break;
+            case WINED3DSPSM_BIASNEG: TRACE("_bias"); break;
+            case WINED3DSPSM_SIGN:    TRACE("_bx2"); break;
+            case WINED3DSPSM_SIGNNEG: TRACE("_bx2"); break;
+            case WINED3DSPSM_COMP:    break;
+            case WINED3DSPSM_X2:      TRACE("_x2"); break;
+            case WINED3DSPSM_X2NEG:   TRACE("_x2"); break;
+            case WINED3DSPSM_DZ:      TRACE("_dz"); break;
+            case WINED3DSPSM_DW:      TRACE("_dw"); break;
+            case WINED3DSPSM_ABSNEG:  TRACE(")"); break;
+            case WINED3DSPSM_ABS:     TRACE(")"); break;
+            default:                  TRACE("_unknown_modifier(%#x)", src_modifier);
+        }
+    }
+
+    if (swizzle != WINED3DSP_NOSWIZZLE)
+    {
+        static const char *swizzle_chars = "xyzw";
+        DWORD swizzle_x = swizzle & 0x03;
+        DWORD swizzle_y = (swizzle >> 2) & 0x03;
+        DWORD swizzle_z = (swizzle >> 4) & 0x03;
+        DWORD swizzle_w = (swizzle >> 6) & 0x03;
+
+        if (swizzle_x == swizzle_y
+                && swizzle_x == swizzle_z
+                && swizzle_x == swizzle_w)
+        {
+            TRACE(".%c", swizzle_chars[swizzle_x]);
+        }
+        else
+        {
+            TRACE(".%c%c%c%c", swizzle_chars[swizzle_x], swizzle_chars[swizzle_y],
+                    swizzle_chars[swizzle_z], swizzle_chars[swizzle_w]);
+        }
+    }
+}
+
+/* Shared code in order to generate the bulk of the shader string.
+ * NOTE: A description of how to parse tokens can be found on MSDN. */
+void shader_generate_main(IWineD3DBaseShader *iface, struct wined3d_shader_buffer *buffer,
+        const shader_reg_maps *reg_maps, const DWORD *byte_code, void *backend_ctx)
+{
+    IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)iface;
+    IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)shader->baseShader.device;
+    const struct wined3d_shader_frontend *fe = shader->baseShader.frontend;
+    void *fe_data = shader->baseShader.frontend_data;
+    struct wined3d_shader_src_param src_rel_addr[4];
+    struct wined3d_shader_src_param src_param[4];
+    struct wined3d_shader_version shader_version;
+    struct wined3d_shader_src_param dst_rel_addr;
+    struct wined3d_shader_dst_param dst_param;
+    struct wined3d_shader_instruction ins;
+    struct wined3d_shader_context ctx;
+    const DWORD *ptr = byte_code;
+    DWORD i;
+
+    /* Initialize current parsing state. */
+    ctx.shader = iface;
+    ctx.gl_info = &device->adapter->gl_info;
+    ctx.reg_maps = reg_maps;
+    ctx.buffer = buffer;
+    ctx.backend_data = backend_ctx;
+
+    ins.ctx = &ctx;
+    ins.dst = &dst_param;
+    ins.src = src_param;
+    shader->baseShader.parse_state.current_row = 0;
+
+    fe->shader_read_header(fe_data, &ptr, &shader_version);
+
+    while (!fe->shader_is_end(fe_data, &ptr))
+    {
+        const char *comment;
+        UINT comment_size;
+        UINT param_size;
+
+        /* Skip comment tokens. */
+        fe->shader_read_comment(&ptr, &comment, &comment_size);
+        if (comment) continue;
+
+        /* Read opcode. */
+        fe->shader_read_opcode(fe_data, &ptr, &ins, &param_size);
+
+        /* Unknown opcode and its parameters. */
+        if (ins.handler_idx == WINED3DSIH_TABLE_SIZE)
+        {
+            TRACE("Skipping unrecognized instruction.\n");
+            ptr += param_size;
+            continue;
+        }
+
+        /* Nothing to do. */
+        if (ins.handler_idx == WINED3DSIH_DCL
+                || ins.handler_idx == WINED3DSIH_NOP
+                || ins.handler_idx == WINED3DSIH_DEF
+                || ins.handler_idx == WINED3DSIH_DEFI
+                || ins.handler_idx == WINED3DSIH_DEFB
+                || ins.handler_idx == WINED3DSIH_PHASE)
+        {
+            ptr += param_size;
+            continue;
+        }
+
+        /* Destination token */
+        if (ins.dst_count) fe->shader_read_dst_param(fe_data, &ptr, &dst_param, &dst_rel_addr);
+
+        /* Predication token */
+        if (ins.predicate)
+        {
+            FIXME("Predicates not implemented.\n");
+            ins.predicate = *ptr++;
+        }
+
+        /* Other source tokens */
+        for (i = 0; i < ins.src_count; ++i)
+        {
+            fe->shader_read_src_param(fe_data, &ptr, &src_param[i], &src_rel_addr[i]);
+        }
+
+        /* Call appropriate function for output target */
+        device->shader_backend->shader_handle_instruction(&ins);
+    }
+}
+
+static void shader_dump_ins_modifiers(const struct wined3d_shader_dst_param *dst)
+{
+    DWORD mmask = dst->modifiers;
+
+    switch (dst->shift)
+    {
+        case 0: break;
+        case 13: TRACE("_d8"); break;
+        case 14: TRACE("_d4"); break;
+        case 15: TRACE("_d2"); break;
+        case 1: TRACE("_x2"); break;
+        case 2: TRACE("_x4"); break;
+        case 3: TRACE("_x8"); break;
+        default: TRACE("_unhandled_shift(%d)", dst->shift); break;
+    }
+
+    if (mmask & WINED3DSPDM_SATURATE)         TRACE("_sat");
+    if (mmask & WINED3DSPDM_PARTIALPRECISION) TRACE("_pp");
+    if (mmask & WINED3DSPDM_MSAMPCENTROID)    TRACE("_centroid");
+
+    mmask &= ~(WINED3DSPDM_SATURATE | WINED3DSPDM_PARTIALPRECISION | WINED3DSPDM_MSAMPCENTROID);
+    if (mmask) FIXME("_unrecognized_modifier(%#x)", mmask);
+}
+
+static void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe_data, const DWORD *byte_code)
+{
+    struct wined3d_shader_version shader_version;
+    const DWORD *ptr = byte_code;
+    const char *type_prefix;
+    DWORD i;
+
+    TRACE("Parsing %p.\n", byte_code);
+
+    fe->shader_read_header(fe_data, &ptr, &shader_version);
+
+    switch (shader_version.type)
+    {
+        case WINED3D_SHADER_TYPE_VERTEX:
+            type_prefix = "vs";
+            break;
+
+        case WINED3D_SHADER_TYPE_GEOMETRY:
+            type_prefix = "gs";
+            break;
+
+        case WINED3D_SHADER_TYPE_PIXEL:
+            type_prefix = "ps";
+            break;
+
+        default:
+            FIXME("Unhandled shader type %#x.\n", shader_version.type);
+            type_prefix = "unknown";
+            break;
+    }
+
+    TRACE("%s_%u_%u\n", type_prefix, shader_version.major, shader_version.minor);
+
+    while (!fe->shader_is_end(fe_data, &ptr))
+    {
+        struct wined3d_shader_instruction ins;
+        const char *comment;
+        UINT comment_size;
+        UINT param_size;
+
+        /* comment */
+        fe->shader_read_comment(&ptr, &comment, &comment_size);
+        if (comment)
+        {
+            if (comment_size > 4 && *(const DWORD *)comment == WINEMAKEFOURCC('T', 'E', 'X', 'T'))
+            {
+                const char *end = comment + comment_size;
+                const char *ptr = comment + 4;
+                const char *line = ptr;
+
+                TRACE("// TEXT\n");
+                while (ptr != end)
+                {
+                    if (*ptr == '\n')
+                    {
+                        UINT len = ptr - line;
+                        if (len && *(ptr - 1) == '\r') --len;
+                        TRACE("// %s\n", debugstr_an(line, len));
+                        line = ++ptr;
+                    }
+                    else ++ptr;
+                }
+                if (line != ptr) TRACE("// %s\n", debugstr_an(line, ptr - line));
+            }
+            else TRACE("// %s\n", debugstr_an(comment, comment_size));
+            continue;
+        }
+
+        fe->shader_read_opcode(fe_data, &ptr, &ins, &param_size);
+        if (ins.handler_idx == WINED3DSIH_TABLE_SIZE)
+        {
+            TRACE("Skipping unrecognized instruction.\n");
+            ptr += param_size;
+            continue;
+        }
+
+        if (ins.handler_idx == WINED3DSIH_DCL)
+        {
+            struct wined3d_shader_semantic semantic;
+
+            fe->shader_read_semantic(&ptr, &semantic);
+
+            shader_dump_decl_usage(&semantic, &shader_version);
+            shader_dump_ins_modifiers(&semantic.reg);
+            TRACE(" ");
+            shader_dump_dst_param(&semantic.reg, &shader_version);
+        }
+        else if (ins.handler_idx == WINED3DSIH_DEF)
+        {
+            struct wined3d_shader_src_param rel_addr;
+            struct wined3d_shader_dst_param dst;
+
+            fe->shader_read_dst_param(fe_data, &ptr, &dst, &rel_addr);
+
+            TRACE("def c%u = %f, %f, %f, %f", shader_get_float_offset(dst.reg.type, dst.reg.idx),
+                    *(const float *)(ptr),
+                    *(const float *)(ptr + 1),
+                    *(const float *)(ptr + 2),
+                    *(const float *)(ptr + 3));
+            ptr += 4;
+        }
+        else if (ins.handler_idx == WINED3DSIH_DEFI)
+        {
+            struct wined3d_shader_src_param rel_addr;
+            struct wined3d_shader_dst_param dst;
+
+            fe->shader_read_dst_param(fe_data, &ptr, &dst, &rel_addr);
+
+            TRACE("defi i%u = %d, %d, %d, %d", dst.reg.idx,
+                    *(ptr),
+                    *(ptr + 1),
+                    *(ptr + 2),
+                    *(ptr + 3));
+            ptr += 4;
+        }
+        else if (ins.handler_idx == WINED3DSIH_DEFB)
+        {
+            struct wined3d_shader_src_param rel_addr;
+            struct wined3d_shader_dst_param dst;
+
+            fe->shader_read_dst_param(fe_data, &ptr, &dst, &rel_addr);
+
+            TRACE("defb b%u = %s", dst.reg.idx, *ptr ? "true" : "false");
+            ++ptr;
+        }
+        else
+        {
+            struct wined3d_shader_src_param dst_rel_addr, src_rel_addr;
+            struct wined3d_shader_dst_param dst_param;
+            struct wined3d_shader_src_param src_param;
+
+            if (ins.dst_count)
+            {
+                fe->shader_read_dst_param(fe_data, &ptr, &dst_param, &dst_rel_addr);
+            }
+
+            /* Print out predication source token first - it follows
+             * the destination token. */
+            if (ins.predicate)
+            {
+                fe->shader_read_src_param(fe_data, &ptr, &src_param, &src_rel_addr);
+                TRACE("(");
+                shader_dump_src_param(&src_param, &shader_version);
+                TRACE(") ");
+            }
+
+            /* PixWin marks instructions with the coissue flag with a '+' */
+            if (ins.coissue) TRACE("+");
+
+            TRACE("%s", shader_opcode_names[ins.handler_idx]);
+
+            if (ins.handler_idx == WINED3DSIH_IFC
+                    || ins.handler_idx == WINED3DSIH_BREAKC)
+            {
+                switch (ins.flags)
+                {
+                    case COMPARISON_GT: TRACE("_gt"); break;
+                    case COMPARISON_EQ: TRACE("_eq"); break;
+                    case COMPARISON_GE: TRACE("_ge"); break;
+                    case COMPARISON_LT: TRACE("_lt"); break;
+                    case COMPARISON_NE: TRACE("_ne"); break;
+                    case COMPARISON_LE: TRACE("_le"); break;
+                    default: TRACE("_(%u)", ins.flags);
+                }
+            }
+            else if (ins.handler_idx == WINED3DSIH_TEX
+                    && shader_version.major >= 2
+                    && (ins.flags & WINED3DSI_TEXLD_PROJECT))
+            {
+                TRACE("p");
+            }
+
+            /* We already read the destination token, print it. */
+            if (ins.dst_count)
+            {
+                shader_dump_ins_modifiers(&dst_param);
+                TRACE(" ");
+                shader_dump_dst_param(&dst_param, &shader_version);
+            }
+
+            /* Other source tokens */
+            for (i = ins.dst_count; i < (ins.dst_count + ins.src_count); ++i)
+            {
+                fe->shader_read_src_param(fe_data, &ptr, &src_param, &src_rel_addr);
+                TRACE(!i ? " " : ", ");
+                shader_dump_src_param(&src_param, &shader_version);
+            }
+        }
+        TRACE("\n");
+    }
+}
+
+static void shader_cleanup(IWineD3DBaseShader *iface)
+{
+    IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)iface;
+
+    ((IWineD3DDeviceImpl *)shader->baseShader.device)->shader_backend->shader_destroy(iface);
+    HeapFree(GetProcessHeap(), 0, shader->baseShader.reg_maps.constf);
+    HeapFree(GetProcessHeap(), 0, shader->baseShader.function);
+    shader_delete_constant_list(&shader->baseShader.constantsF);
+    shader_delete_constant_list(&shader->baseShader.constantsB);
+    shader_delete_constant_list(&shader->baseShader.constantsI);
+    list_remove(&shader->baseShader.shader_list_entry);
+
+    if (shader->baseShader.frontend && shader->baseShader.frontend_data)
+    {
+        shader->baseShader.frontend->shader_free(shader->baseShader.frontend_data);
+    }
+}
+
+static void shader_none_handle_instruction(const struct wined3d_shader_instruction *ins) {}
+static void shader_none_select(const struct wined3d_context *context, BOOL usePS, BOOL useVS) {}
+static void shader_none_select_depth_blt(IWineD3DDevice *iface, enum tex_types tex_type) {}
+static void shader_none_deselect_depth_blt(IWineD3DDevice *iface) {}
+static void shader_none_update_float_vertex_constants(IWineD3DDevice *iface, UINT start, UINT count) {}
+static void shader_none_update_float_pixel_constants(IWineD3DDevice *iface, UINT start, UINT count) {}
+static void shader_none_load_constants(const struct wined3d_context *context, char usePS, char useVS) {}
+static void shader_none_load_np2fixup_constants(IWineD3DDevice *iface, char usePS, char useVS) {}
+static void shader_none_destroy(IWineD3DBaseShader *iface) {}
+static HRESULT shader_none_alloc(IWineD3DDevice *iface) {return WINED3D_OK;}
+static void shader_none_free(IWineD3DDevice *iface) {}
+static BOOL shader_none_dirty_const(IWineD3DDevice *iface) {return FALSE;}
+
+static void shader_none_get_caps(const struct wined3d_gl_info *gl_info, struct shader_caps *caps)
+{
+    /* Set the shader caps to 0 for the none shader backend */
+    caps->VertexShaderVersion = 0;
+    caps->PixelShaderVersion = 0;
+    caps->PixelShader1xMaxValue = 0.0f;
+}
+
+static BOOL shader_none_color_fixup_supported(struct color_fixup_desc fixup)
+{
+    if (TRACE_ON(d3d_shader) && TRACE_ON(d3d))
+    {
+        TRACE("Checking support for fixup:\n");
+        dump_color_fixup_desc(fixup);
+    }
+
+    /* Faked to make some apps happy. */
+    if (!is_complex_fixup(fixup))
+    {
+        TRACE("[OK]\n");
+        return TRUE;
+    }
+
+    TRACE("[FAILED]\n");
+    return FALSE;
+}
+
+const shader_backend_t none_shader_backend = {
+    shader_none_handle_instruction,
+    shader_none_select,
+    shader_none_select_depth_blt,
+    shader_none_deselect_depth_blt,
+    shader_none_update_float_vertex_constants,
+    shader_none_update_float_pixel_constants,
+    shader_none_load_constants,
+    shader_none_load_np2fixup_constants,
+    shader_none_destroy,
+    shader_none_alloc,
+    shader_none_free,
+    shader_none_dirty_const,
+    shader_none_get_caps,
+    shader_none_color_fixup_supported,
+};
 
 static void shader_get_parent(IWineD3DBaseShaderImpl *shader, IUnknown **parent)
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/shader_sm1.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/shader_sm1.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/shader_sm1.c	(revision 28475)
@@ -651,7 +651,8 @@
 }
 
-static void shader_sm1_read_comment(const DWORD **ptr, const char **comment)
+static void shader_sm1_read_comment(const DWORD **ptr, const char **comment, UINT *comment_size)
 {
     DWORD token = **ptr;
+    UINT size;
 
     if ((token & WINED3DSI_OPCODE_MASK) != WINED3D_SM1_OP_COMMENT)
@@ -661,6 +662,8 @@
     }
 
+    size = (token & WINED3DSI_COMMENTSIZE_MASK) >> WINED3DSI_COMMENTSIZE_SHIFT;
     *comment = (const char *)++(*ptr);
-    *ptr += (token & WINED3DSI_COMMENTSIZE_MASK) >> WINED3DSI_COMMENTSIZE_SHIFT;
+    *comment_size = size * sizeof(DWORD);
+    *ptr += size;
 }
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/shader_sm4.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/shader_sm4.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/shader_sm4.c	(revision 28475)
@@ -416,7 +416,7 @@
 }
 
-static void shader_sm4_read_comment(const DWORD **ptr, const char **comment)
-{
-    FIXME("ptr %p, comment %p stub!\n", ptr, comment);
+static void shader_sm4_read_comment(const DWORD **ptr, const char **comment, UINT *comment_size)
+{
+    FIXME("ptr %p, comment %p, comment_size %p stub!\n", ptr, comment, comment_size);
     *comment = NULL;
 }
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/state.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/state.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/state.c	(revision 28475)
@@ -51,21 +51,12 @@
 static void state_blendop(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context);
 
-static void state_nogl(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
-{
-    /* Used for states which are not mapped to a gl state as-is, but used somehow different,
-     * e.g as a parameter for drawing, or which are unimplemented in windows d3d
-     */
-    if(STATE_IS_RENDER(state)) {
-        WINED3DRENDERSTATETYPE RenderState = state - STATE_RENDER(0);
-        TRACE("(%s,%d) no direct mapping to gl\n", debug_d3drenderstate(RenderState), stateblock->renderState[RenderState]);
-    } else {
-        /* Shouldn't have an unknown type here */
-        FIXME("%d no direct mapping to gl of state with unknown type\n", state);
-    }
-}
-
 static void state_undefined(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
 {
     ERR("Undefined state.\n");
+}
+
+static void state_nop(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+{
+    TRACE("%s: nop in current pipe config.\n", debug_d3dstate(state));
 }
 
@@ -460,8 +451,5 @@
         so it may need updating */
     if (stateblock->renderState[WINED3DRS_COLORKEYENABLE])
-    {
-        const struct StateEntry *StateTable = stateblock->device->StateTable;
-        StateTable[STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP)].apply(STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), stateblock, context);
-    }
+        stateblock_apply_state(STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), stateblock, context);
 }
 
@@ -516,8 +504,5 @@
 
     if (enable_ckey || context->last_was_ckey)
-    {
-        const struct StateEntry *StateTable = stateblock->device->StateTable;
-        StateTable[STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP)].apply(STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), stateblock, context);
-    }
+        stateblock_apply_state(STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), stateblock, context);
     context->last_was_ckey = enable_ckey;
 
@@ -593,4 +578,8 @@
             glEnable(GL_DEPTH_CLAMP);
             checkGLcall("glEnable(GL_DEPTH_CLAMP)");
+        }
+        else
+        {
+            FIXME("Clipping disabled, but ARB_depth_clamp isn't supported.\n");
         }
     }
@@ -1532,26 +1521,56 @@
 static void state_colorwrite(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
 {
-    DWORD Value = stateblock->renderState[WINED3DRS_COLORWRITEENABLE];
+    DWORD mask0 = stateblock->renderState[WINED3DRS_COLORWRITEENABLE];
+    DWORD mask1 = stateblock->renderState[WINED3DRS_COLORWRITEENABLE1];
+    DWORD mask2 = stateblock->renderState[WINED3DRS_COLORWRITEENABLE2];
+    DWORD mask3 = stateblock->renderState[WINED3DRS_COLORWRITEENABLE3];
 
     TRACE("Color mask: r(%d) g(%d) b(%d) a(%d)\n",
-        Value & WINED3DCOLORWRITEENABLE_RED   ? 1 : 0,
-        Value & WINED3DCOLORWRITEENABLE_GREEN ? 1 : 0,
-        Value & WINED3DCOLORWRITEENABLE_BLUE  ? 1 : 0,
-        Value & WINED3DCOLORWRITEENABLE_ALPHA ? 1 : 0);
-    glColorMask(Value & WINED3DCOLORWRITEENABLE_RED   ? GL_TRUE : GL_FALSE,
-                Value & WINED3DCOLORWRITEENABLE_GREEN ? GL_TRUE : GL_FALSE,
-                Value & WINED3DCOLORWRITEENABLE_BLUE  ? GL_TRUE : GL_FALSE,
-                Value & WINED3DCOLORWRITEENABLE_ALPHA ? GL_TRUE : GL_FALSE);
+            mask0 & WINED3DCOLORWRITEENABLE_RED ? 1 : 0,
+            mask0 & WINED3DCOLORWRITEENABLE_GREEN ? 1 : 0,
+            mask0 & WINED3DCOLORWRITEENABLE_BLUE ? 1 : 0,
+            mask0 & WINED3DCOLORWRITEENABLE_ALPHA ? 1 : 0);
+    glColorMask(mask0 & WINED3DCOLORWRITEENABLE_RED ? GL_TRUE : GL_FALSE,
+            mask0 & WINED3DCOLORWRITEENABLE_GREEN ? GL_TRUE : GL_FALSE,
+            mask0 & WINED3DCOLORWRITEENABLE_BLUE ? GL_TRUE : GL_FALSE,
+            mask0 & WINED3DCOLORWRITEENABLE_ALPHA ? GL_TRUE : GL_FALSE);
     checkGLcall("glColorMask(...)");
 
-    /* depends on WINED3DRS_COLORWRITEENABLE. */
-    if(stateblock->renderState[WINED3DRS_COLORWRITEENABLE1] != 0x0000000F ||
-       stateblock->renderState[WINED3DRS_COLORWRITEENABLE2] != 0x0000000F ||
-       stateblock->renderState[WINED3DRS_COLORWRITEENABLE3] != 0x0000000F ) {
-        ERR("(WINED3DRS_COLORWRITEENABLE1/2/3,%d,%d,%d) not yet implemented. Missing of cap D3DPMISCCAPS_INDEPENDENTWRITEMASKS wasn't honored?\n",
-            stateblock->renderState[WINED3DRS_COLORWRITEENABLE1],
-            stateblock->renderState[WINED3DRS_COLORWRITEENABLE2],
-            stateblock->renderState[WINED3DRS_COLORWRITEENABLE3]);
-    }
+    if (!((mask1 == mask0 && mask2 == mask0 && mask3 == mask0)
+        || (mask1 == 0xf && mask2 == 0xf && mask3 == 0xf)))
+    {
+        FIXME("WINED3DRS_COLORWRITEENABLE/1/2/3, %#x/%#x/%#x/%#x not yet implemented.\n",
+            mask0, mask1, mask2, mask3);
+        FIXME("Missing of cap D3DPMISCCAPS_INDEPENDENTWRITEMASKS wasn't honored?\n");
+    }
+}
+
+static void set_color_mask(struct wined3d_context *context, UINT index, DWORD mask)
+{
+    GL_EXTCALL(glColorMaskIndexedEXT(index,
+            mask & WINED3DCOLORWRITEENABLE_RED ? GL_TRUE : GL_FALSE,
+            mask & WINED3DCOLORWRITEENABLE_GREEN ? GL_TRUE : GL_FALSE,
+            mask & WINED3DCOLORWRITEENABLE_BLUE ? GL_TRUE : GL_FALSE,
+            mask & WINED3DCOLORWRITEENABLE_ALPHA ? GL_TRUE : GL_FALSE));
+}
+
+static void state_colorwrite0(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+{
+    set_color_mask(context, 0, stateblock->renderState[WINED3DRS_COLORWRITEENABLE]);
+}
+
+static void state_colorwrite1(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+{
+    set_color_mask(context, 1, stateblock->renderState[WINED3DRS_COLORWRITEENABLE1]);
+}
+
+static void state_colorwrite2(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+{
+    set_color_mask(context, 2, stateblock->renderState[WINED3DRS_COLORWRITEENABLE2]);
+}
+
+static void state_colorwrite3(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+{
+    set_color_mask(context, 3, stateblock->renderState[WINED3DRS_COLORWRITEENABLE3]);
 }
 
@@ -1713,4 +1732,10 @@
 }
 
+static void state_zvisible(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+{
+    if (stateblock->renderState[WINED3DRS_ZVISIBLE])
+        FIXME("WINED3DRS_ZVISIBLE not implemented.\n");
+}
+
 static void state_perspective(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
 {
@@ -1847,11 +1872,4 @@
     if(stateblock->renderState[WINED3DRS_STIPPLEENABLE]) {
         FIXME("Render state WINED3DRS_STIPPLEENABLE not implemented yet\n");
-    }
-}
-
-static void state_bordercolor(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
-{
-    if(stateblock->renderState[WINED3DRS_BORDERCOLOR]) {
-        FIXME("Render state WINED3DRS_BORDERCOLOR not implemented yet\n");
     }
 }
@@ -3534,5 +3552,4 @@
         BOOL srgb = stateblock->samplerState[sampler][WINED3DSAMP_SRGBTEXTURE];
         IWineD3DBaseTextureImpl *tex_impl = (IWineD3DBaseTextureImpl *) stateblock->textures[sampler];
-        tex_impl->baseTexture.internal_preload(stateblock->textures[sampler], srgb ? SRGB_SRGB : SRGB_RGB);
         IWineD3DBaseTexture_BindTexture(stateblock->textures[sampler], srgb);
         basetexture_apply_state_changes(stateblock->textures[sampler],
@@ -3608,11 +3625,9 @@
     } else {
         /* Disabled the pixel shader - color ops weren't applied
-         * while it was enabled, so re-apply them.
-         */
-        for(i=0; i < MAX_TEXTURES; i++) {
-            if(!isStateDirty(context, STATE_TEXTURESTAGE(i, WINED3DTSS_COLOROP))) {
-                device->StateTable[STATE_TEXTURESTAGE(i, WINED3DTSS_COLOROP)].apply
-                        (STATE_TEXTURESTAGE(i, WINED3DTSS_COLOROP), stateblock, context);
-            }
+         * while it was enabled, so re-apply them. */
+        for (i = 0; i < context->gl_info->limits.texture_stages; ++i)
+        {
+            if (!isStateDirty(context, STATE_TEXTURESTAGE(i, WINED3DTSS_COLOROP)))
+                stateblock_apply_state(STATE_TEXTURESTAGE(i, WINED3DTSS_COLOROP), stateblock, context);
         }
         context->last_was_pshader = FALSE;
@@ -3758,20 +3773,11 @@
 static void state_vertexblend_w(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
 {
-    static BOOL once = FALSE;
-
-    switch(stateblock->renderState[WINED3DRS_VERTEXBLEND]) {
-        case WINED3DVBF_1WEIGHTS:
-        case WINED3DVBF_2WEIGHTS:
-        case WINED3DVBF_3WEIGHTS:
-            if(!once) {
-                once = TRUE;
-                /* TODO: Implement vertex blending in drawStridedSlow */
-                FIXME("Vertex blending enabled, but not supported by hardware\n");
-            }
-            break;
-
-        case WINED3DVBF_TWEENING:
-            WARN("Tweening not supported yet\n");
-    }
+    WINED3DVERTEXBLENDFLAGS f = stateblock->renderState[WINED3DRS_VERTEXBLEND];
+    static unsigned int once;
+
+    if (f == WINED3DVBF_DISABLE) return;
+
+    if (!once++) FIXME("Vertex blend flags %#x not supported.\n", f);
+    else WARN("Vertex blend flags %#x not supported.\n", f);
 }
 
@@ -3779,4 +3785,5 @@
 {
     WINED3DVERTEXBLENDFLAGS val = stateblock->renderState[WINED3DRS_VERTEXBLEND];
+    static unsigned int once;
 
     switch(val) {
@@ -3806,16 +3813,12 @@
             break;
 
+        case WINED3DVBF_TWEENING:
+        case WINED3DVBF_0WEIGHTS: /* Indexed vertex blending, not supported. */
+            if (!once++) FIXME("Vertex blend flags %#x not supported.\n", val);
+            else WARN("Vertex blend flags %#x not supported.\n", val);
+            /* Fall through. */
         case WINED3DVBF_DISABLE:
-        case WINED3DVBF_0WEIGHTS: /* for Indexed vertex blending - not supported */
             glDisable(GL_VERTEX_BLEND_ARB);
             checkGLcall("glDisable(GL_VERTEX_BLEND_ARB)");
-            break;
-
-        case WINED3DVBF_TWEENING:
-            /* Just set the vertex weight for weight 0, enable vertex blending and hope the app doesn't have
-             * vertex weights in the vertices?
-             * For now we don't report that as supported, so a warn should suffice
-             */
-            WARN("Tweening not supported yet\n");
             break;
     }
@@ -3891,60 +3894,16 @@
     checkGLcall("glLoadIdentity");
 
-    if(context->last_was_rhw) {
-        double X, Y, height, width, minZ, maxZ;
-
-        X      = stateblock->viewport.X;
-        Y      = stateblock->viewport.Y;
-        height = stateblock->viewport.Height;
-        width  = stateblock->viewport.Width;
-        minZ   = stateblock->viewport.MinZ;
-        maxZ   = stateblock->viewport.MaxZ;
-
-        if (!stateblock->device->untransformed)
-        {
-            /* Transformed vertices are supposed to bypass the whole transform pipeline including
-             * frustum clipping. This can't be done in opengl, so this code adjusts the Z range to
-             * suppress depth clipping. This can be done because it is an orthogonal projection and
-             * the Z coordinate does not affect the size of the primitives. Half Life 1 and Prince of
-             * Persia 3D need this.
-             *
-             * Note that using minZ and maxZ here doesn't entirely fix the problem, since view frustum
-             * clipping is still enabled, but it seems to fix it for all apps tested so far. A minor
-             * problem can be witnessed in half-life 1 engine based games, the weapon is clipped close
-             * to the viewer.
-             *
-             * Also note that this breaks z comparison against z values filled in with clear,
-             * but no app depending on that and disabled clipping has been found yet. Comparing
-             * primitives against themselves works, so the Z buffer is still intact for normal hidden
-             * surface removal.
-             *
-             * We could disable clipping entirely by setting the near to infinity and far to -infinity,
-             * but this would break Z buffer operation. Raising the range to something less than
-             * infinity would help a bit at the cost of Z precision, but it wouldn't eliminate the
-             * problem either.
-             */
-            TRACE("Calling glOrtho with %f, %f, %f, %f\n", width, height, -minZ, -maxZ);
-            if (context->render_offscreen)
-            {
-                glOrtho(X, X + width, -Y, -Y - height, -minZ, -maxZ);
-            } else {
-                glOrtho(X, X + width, Y + height, Y, -minZ, -maxZ);
-            }
-        } else {
-            /* If the app mixes transformed and untransformed primitives we can't use the coordinate system
-             * trick above because this would mess up transformed and untransformed Z order. Pass the z position
-             * unmodified to opengl.
-             *
-             * If the app depends on mixed types and disabled clipping we're out of luck without a pipeline
-             * replacement shader.
-             */
-            TRACE("Calling glOrtho with %f, %f, %f, %f\n", width, height, 1.0, -1.0);
-            if (context->render_offscreen)
-            {
-                glOrtho(X, X + width, -Y, -Y - height, 0.0, -1.0);
-            } else {
-                glOrtho(X, X + width, Y + height, Y, 0.0, -1.0);
-            }
-        }
+    if (context->last_was_rhw)
+    {
+        double x = stateblock->viewport.X;
+        double y = stateblock->viewport.Y;
+        double w = stateblock->viewport.Width;
+        double h = stateblock->viewport.Height;
+
+        TRACE("Calling glOrtho with x %.8e, y %.8e, w %.8e, h %.8e.\n", x, y, w, h);
+        if (context->render_offscreen)
+            glOrtho(x, x + w, -y, -y - h, 0.0, -1.0);
+        else
+            glOrtho(x, x + w, y + h, y, 0.0, -1.0);
         checkGLcall("glOrtho");
 
@@ -4178,5 +4137,5 @@
                     break;
                 case WINED3DFMT_B8G8R8A8_UNORM:
-                    if (gl_info->supported[EXT_VERTEX_ARRAY_BGRA])
+                    if (gl_info->supported[ARB_VERTEX_ARRAY_BGRA])
                     {
                         const DWORD *src = (const DWORD *)ptr;
@@ -4277,9 +4236,4 @@
             GL_EXTCALL(glVertexBlendARB(e->format_desc->component_count + 1));
 
-            VTRACE(("glWeightPointerARB(%d, GL_FLOAT, %d, %p)\n",
-                WINED3D_ATR_FORMAT(sd->u.s.blendWeights.dwType) ,
-                sd->u.s.blendWeights.dwStride,
-                sd->u.s.blendWeights.lpData + stateblock->loadBaseVertexIndex * sd->u.s.blendWeights.dwStride + offset[sd->u.s.blendWeights.streamNo]));
-
             if (curVBO != e->buffer_object)
             {
@@ -4289,6 +4243,11 @@
             }
 
-            GL_EXTCALL(glWeightPointerARB)(e->format_desc->gl_vtx_format, e->format_desc->gl_vtx_type, e->stride,
-                e->data + stateblock->loadBaseVertexIndex * e->stride + offset[e->stream_idx]);
+            TRACE("glWeightPointerARB(%#x, %#x, %#x, %p);\n",
+                    e->format_desc->gl_vtx_format,
+                    e->format_desc->gl_vtx_type,
+                    e->stride,
+                    e->data + stateblock->loadBaseVertexIndex * e->stride + offset[e->stream_idx]);
+            GL_EXTCALL(glWeightPointerARB(e->format_desc->gl_vtx_format, e->format_desc->gl_vtx_type, e->stride,
+                    e->data + stateblock->loadBaseVertexIndex * e->stride + offset[e->stream_idx]));
 
             checkGLcall("glWeightPointerARB");
@@ -4331,6 +4290,4 @@
     if (si->use_map & (1 << WINED3D_FFP_POSITION))
     {
-        VTRACE(("glVertexPointer(%d, GL_FLOAT, %d, %p)\n", e->stride, e->size, e->data));
-
         e = &si->elements[WINED3D_FFP_POSITION];
         if (curVBO != e->buffer_object)
@@ -4351,7 +4308,14 @@
         if (!e->buffer_object)
         {
+            TRACE("glVertexPointer(3, %#x, %#x, %p);\n", e->format_desc->gl_vtx_type, e->stride,
+                    e->data + stateblock->loadBaseVertexIndex * e->stride + offset[e->stream_idx]);
             glVertexPointer(3 /* min(e->format_desc->gl_vtx_format, 3) */, e->format_desc->gl_vtx_type, e->stride,
                     e->data + stateblock->loadBaseVertexIndex * e->stride + offset[e->stream_idx]);
-        } else {
+        }
+        else
+        {
+            TRACE("glVertexPointer(%#x, %#x, %#x, %p);\n",
+                    e->format_desc->gl_vtx_format, e->format_desc->gl_vtx_type, e->stride,
+                    e->data + stateblock->loadBaseVertexIndex * e->stride + offset[e->stream_idx]);
             glVertexPointer(e->format_desc->gl_vtx_format, e->format_desc->gl_vtx_type, e->stride,
                     e->data + stateblock->loadBaseVertexIndex * e->stride + offset[e->stream_idx]);
@@ -4365,6 +4329,4 @@
     if (si->use_map & (1 << WINED3D_FFP_NORMAL))
     {
-        VTRACE(("glNormalPointer(GL_FLOAT, %d, %p)\n", e->stride, e->data));
-
         e = &si->elements[WINED3D_FFP_NORMAL];
         if (curVBO != e->buffer_object)
@@ -4374,4 +4336,7 @@
             curVBO = e->buffer_object;
         }
+
+        TRACE("glNormalPointer(%#x, %#x, %p);\n", e->format_desc->gl_vtx_type, e->stride,
+                e->data + stateblock->loadBaseVertexIndex * e->stride + offset[e->stream_idx]);
         glNormalPointer(e->format_desc->gl_vtx_type, e->stride,
                 e->data + stateblock->loadBaseVertexIndex * e->stride + offset[e->stream_idx]);
@@ -4396,6 +4361,4 @@
     if (si->use_map & (1 << WINED3D_FFP_DIFFUSE))
     {
-        VTRACE(("glColorPointer(4, GL_UNSIGNED_BYTE, %d, %p)\n", e->stride, e->data));
-
         e = &si->elements[WINED3D_FFP_DIFFUSE];
         if (curVBO != e->buffer_object)
@@ -4406,4 +4369,7 @@
         }
 
+        TRACE("glColorPointer(%#x, %#x %#x, %p);\n",
+                e->format_desc->gl_vtx_format, e->format_desc->gl_vtx_type, e->stride,
+                e->data + stateblock->loadBaseVertexIndex * e->stride + offset[e->stream_idx]);
         glColorPointer(e->format_desc->gl_vtx_format, e->format_desc->gl_vtx_type, e->stride,
                 e->data + stateblock->loadBaseVertexIndex * e->stride + offset[e->stream_idx]);
@@ -4421,5 +4387,4 @@
     {
         TRACE("setting specular colour\n");
-        VTRACE(("glSecondaryColorPointer(4, GL_UNSIGNED_BYTE, %d, %p)\n", e->stride, e->data));
 
         e = &si->elements[WINED3D_FFP_SPECULAR];
@@ -4443,6 +4408,8 @@
                  * 4 component secondary colors use it
                  */
-                GL_EXTCALL(glSecondaryColorPointerEXT)(format, type,
-                        e->stride, e->data + stateblock->loadBaseVertexIndex * e->stride + offset[e->stream_idx]);
+                TRACE("glSecondaryColorPointer(%#x, %#x, %#x, %p);\n", format, type, e->stride,
+                        e->data + stateblock->loadBaseVertexIndex * e->stride + offset[e->stream_idx]);
+                GL_EXTCALL(glSecondaryColorPointerEXT(format, type, e->stride,
+                        e->data + stateblock->loadBaseVertexIndex * e->stride + offset[e->stream_idx]));
                 checkGLcall("glSecondaryColorPointerEXT(format, type, ...)");
             }
@@ -4452,6 +4419,8 @@
                 {
                     case GL_UNSIGNED_BYTE:
-                        GL_EXTCALL(glSecondaryColorPointerEXT)(3, GL_UNSIGNED_BYTE,
-                                e->stride, e->data + stateblock->loadBaseVertexIndex * e->stride + offset[e->stream_idx]);
+                        TRACE("glSecondaryColorPointer(3, GL_UNSIGNED_BYTE, %#x, %p);\n", e->stride,
+                                e->data + stateblock->loadBaseVertexIndex * e->stride + offset[e->stream_idx]);
+                        GL_EXTCALL(glSecondaryColorPointerEXT(3, GL_UNSIGNED_BYTE, e->stride,
+                                e->data + stateblock->loadBaseVertexIndex * e->stride + offset[e->stream_idx]));
                         checkGLcall("glSecondaryColorPointerEXT(3, GL_UNSIGNED_BYTE, ...)");
                         break;
@@ -4460,6 +4429,8 @@
                         FIXME("Add 4 component specular color pointers for type %x\n", type);
                         /* Make sure that the right color component is dropped */
-                        GL_EXTCALL(glSecondaryColorPointerEXT)(3, type,
-                                e->stride, e->data + stateblock->loadBaseVertexIndex * e->stride + offset[e->stream_idx]);
+                        TRACE("glSecondaryColorPointer(3, %#x, %#x, %p);\n", type, e->stride,
+                                e->data + stateblock->loadBaseVertexIndex * e->stride + offset[e->stream_idx]);
+                        GL_EXTCALL(glSecondaryColorPointerEXT(3, type, e->stride,
+                                e->data + stateblock->loadBaseVertexIndex * e->stride + offset[e->stream_idx]));
                         checkGLcall("glSecondaryColorPointerEXT(3, type, ...)");
                 }
@@ -4467,8 +4438,8 @@
             glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
             checkGLcall("glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT)");
-        } else {
-
-        /* Missing specular color is not critical, no warnings */
-        VTRACE(("Specular colour is not supported in this GL implementation\n"));
+        }
+        else
+        {
+            WARN("Specular colour is not supported in this GL implementation.\n");
         }
     }
@@ -4479,8 +4450,8 @@
             GL_EXTCALL(glSecondaryColor3fEXT)(0, 0, 0);
             checkGLcall("glSecondaryColor3fEXT(0, 0, 0)");
-        } else {
-
-            /* Missing specular color is not critical, no warnings */
-            VTRACE(("Specular colour is not supported in this GL implementation\n"));
+        }
+        else
+        {
+            WARN("Specular colour is not supported in this GL implementation.\n");
         }
     }
@@ -4490,85 +4461,9 @@
 }
 
-static inline void drawPrimitiveTraceDataLocations(const struct wined3d_stream_info *dataLocations)
-{
-    /* Dump out what parts we have supplied */
-    TRACE("Strided Data:\n");
-    TRACE_STRIDED((dataLocations), WINED3D_FFP_POSITION);
-    TRACE_STRIDED((dataLocations), WINED3D_FFP_BLENDWEIGHT);
-    TRACE_STRIDED((dataLocations), WINED3D_FFP_BLENDINDICES);
-    TRACE_STRIDED((dataLocations), WINED3D_FFP_NORMAL);
-    TRACE_STRIDED((dataLocations), WINED3D_FFP_PSIZE);
-    TRACE_STRIDED((dataLocations), WINED3D_FFP_DIFFUSE);
-    TRACE_STRIDED((dataLocations), WINED3D_FFP_SPECULAR);
-    TRACE_STRIDED((dataLocations), WINED3D_FFP_TEXCOORD0);
-    TRACE_STRIDED((dataLocations), WINED3D_FFP_TEXCOORD1);
-    TRACE_STRIDED((dataLocations), WINED3D_FFP_TEXCOORD2);
-    TRACE_STRIDED((dataLocations), WINED3D_FFP_TEXCOORD3);
-    TRACE_STRIDED((dataLocations), WINED3D_FFP_TEXCOORD4);
-    TRACE_STRIDED((dataLocations), WINED3D_FFP_TEXCOORD5);
-    TRACE_STRIDED((dataLocations), WINED3D_FFP_TEXCOORD6);
-    TRACE_STRIDED((dataLocations), WINED3D_FFP_TEXCOORD7);
-}
-
 static void streamsrc(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
 {
-    const struct wined3d_gl_info *gl_info = context->gl_info;
     IWineD3DDeviceImpl *device = stateblock->device;
-    BOOL fixup = FALSE;
-    struct wined3d_stream_info *dataLocations = &device->strided_streams;
-    BOOL useVertexShaderFunction;
-    BOOL load_numbered = FALSE;
-    BOOL load_named = FALSE;
-
-    useVertexShaderFunction = (device->vs_selected_mode != SHADER_NONE && stateblock->vertexShader) ? TRUE : FALSE;
-
-    if(device->up_strided) {
-        /* Note: this is a ddraw fixed-function code path */
-        TRACE("================ Strided Input ===================\n");
-        device_stream_info_from_strided(gl_info, device->up_strided, dataLocations);
-
-        if(TRACE_ON(d3d)) {
-            drawPrimitiveTraceDataLocations(dataLocations);
-        }
-    } else {
-        /* Note: This is a fixed function or shader codepath.
-         * This means it must handle both types of strided data.
-         * Shaders must go through here to zero the strided data, even if they
-         * don't set any declaration at all
-         */
-        TRACE("================ Vertex Declaration  ===================\n");
-        device_stream_info_from_declaration(device, useVertexShaderFunction, dataLocations, &fixup);
-    }
-
-    if (dataLocations->position_transformed) useVertexShaderFunction = FALSE;
-
-    if(useVertexShaderFunction) {
-        if(((IWineD3DVertexDeclarationImpl *) stateblock->vertexDecl)->half_float_conv_needed && !fixup) {
-            TRACE("Using drawStridedSlow with vertex shaders for FLOAT16 conversion\n");
-            device->useDrawStridedSlow = TRUE;
-        } else {
-            load_numbered = TRUE;
-            device->useDrawStridedSlow = FALSE;
-        }
-    }
-    else
-    {
-        WORD slow_mask = (1 << WINED3D_FFP_PSIZE);
-        slow_mask |= -!gl_info->supported[EXT_VERTEX_ARRAY_BGRA]
-                & ((1 << WINED3D_FFP_DIFFUSE) | (1 << WINED3D_FFP_SPECULAR));
-
-        if (fixup || (!dataLocations->position_transformed
-                && !(dataLocations->use_map & slow_mask)))
-        {
-            /* Load the vertex data using named arrays */
-            load_named = TRUE;
-            device->useDrawStridedSlow = FALSE;
-        }
-        else
-        {
-            TRACE("Not loading vertex data\n");
-            device->useDrawStridedSlow = TRUE;
-        }
-    }
+    BOOL load_numbered = use_vs(stateblock) && !device->useDrawStridedSlow;
+    BOOL load_named = !use_vs(stateblock) && !device->useDrawStridedSlow;
 
     if (context->numberedArraysLoaded && !load_numbered)
@@ -4587,5 +4482,5 @@
     {
         TRACE("Loading numbered arrays\n");
-        loadNumberedArrays(stateblock, dataLocations, context);
+        loadNumberedArrays(stateblock, &device->strided_streams, context);
         context->numberedArraysLoaded = TRUE;
     }
@@ -4593,5 +4488,5 @@
     {
         TRACE("Loading vertex data\n");
-        loadVertexData(context, stateblock, dataLocations);
+        loadVertexData(context, stateblock, &device->strided_streams);
         context->namedArraysLoaded = TRUE;
     }
@@ -4746,7 +4641,6 @@
     context->last_was_vshader = useVertexShaderFunction;
 
-    if(updateFog) {
-        device->StateTable[STATE_RENDER(WINED3DRS_FOGVERTEXMODE)].apply(STATE_RENDER(WINED3DRS_FOGVERTEXMODE), stateblock, context);
-    }
+    if (updateFog) stateblock_apply_state(STATE_RENDER(WINED3DRS_FOGVERTEXMODE), stateblock, context);
+
     if(!useVertexShaderFunction) {
         int i;
@@ -4799,4 +4693,6 @@
         state_pscale(STATE_RENDER(WINED3DRS_POINTSCALEENABLE), stateblock, context);
     }
+    if (!isStateDirty(context, STATE_VERTEXSHADERCONSTANT))
+        shaderconstant(STATE_VERTEXSHADERCONSTANT, stateblock, context);
 }
 
@@ -4961,15 +4857,15 @@
 
 const struct StateEntryTemplate misc_state_template[] = {
-    { STATE_RENDER(WINED3DRS_SRCBLEND),                   { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE),           state_blend         }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_DESTBLEND),                  { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE),           state_blend         }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_SRCBLEND),                   { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE),           NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_DESTBLEND),                  { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE),           NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE),           { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE),           state_blend         }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_EDGEANTIALIAS),              { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE),           state_blend         }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_ANTIALIASEDLINEENABLE),      { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE),           state_blend         }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_SEPARATEALPHABLENDENABLE),   { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE),           state_blend         }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_SRCBLENDALPHA),              { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE),           state_blend         }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_DESTBLENDALPHA),             { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE),           state_blend         }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_DESTBLENDALPHA),             { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE),           state_blend         }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_BLENDOPALPHA),               { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE),           state_blend         }, WINED3D_GL_EXT_NONE             },
-    { STATE_STREAMSRC,                                    { STATE_VDECL,                                        streamsrc           }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_EDGEANTIALIAS),              { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE),           NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_ANTIALIASEDLINEENABLE),      { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE),           NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_SEPARATEALPHABLENDENABLE),   { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE),           NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_SRCBLENDALPHA),              { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE),           NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_DESTBLENDALPHA),             { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE),           NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_DESTBLENDALPHA),             { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE),           NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_BLENDOPALPHA),               { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE),           NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_STREAMSRC,                                    { STATE_VDECL,                                        NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_VDECL,                                        { STATE_VDECL,                                        streamsrc           }, WINED3D_GL_EXT_NONE             },
     { STATE_FRONTFACE,                                    { STATE_FRONTFACE,                                    frontface           }, WINED3D_GL_EXT_NONE             },
@@ -4979,56 +4875,57 @@
      */
     { STATE_VERTEXSHADERCONSTANT,                         { STATE_VERTEXSHADERCONSTANT,                         shaderconstant      }, WINED3D_GL_EXT_NONE             },
-    { STATE_PIXELSHADERCONSTANT,                          { STATE_VERTEXSHADERCONSTANT,                         shaderconstant      }, WINED3D_GL_EXT_NONE             },
+    { STATE_PIXELSHADERCONSTANT,                          { STATE_VERTEXSHADERCONSTANT,                         NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),     { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),     shader_bumpenvmat   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),     shader_bumpenvmat   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),     shader_bumpenvmat   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),     shader_bumpenvmat   }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),     NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),     NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),     NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),     { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),     shader_bumpenvmat   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),     shader_bumpenvmat   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),     shader_bumpenvmat   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),     shader_bumpenvmat   }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),     NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),     NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),     NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),     { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),     shader_bumpenvmat   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),     shader_bumpenvmat   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),     shader_bumpenvmat   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),     shader_bumpenvmat   }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),     NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),     NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),     NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),     { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),     shader_bumpenvmat   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),     shader_bumpenvmat   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),     shader_bumpenvmat   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),     shader_bumpenvmat   }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),     NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),     NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),     NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),     { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),     shader_bumpenvmat   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),     shader_bumpenvmat   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),     shader_bumpenvmat   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),     shader_bumpenvmat   }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),     NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),     NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),     NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),     { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),     shader_bumpenvmat   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),     shader_bumpenvmat   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),     shader_bumpenvmat   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),     shader_bumpenvmat   }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),     NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),     NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),     NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),     { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),     shader_bumpenvmat   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),     shader_bumpenvmat   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),     shader_bumpenvmat   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),     shader_bumpenvmat   }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),     NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),     NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),     NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),     { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),     shader_bumpenvmat   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),     shader_bumpenvmat   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),     shader_bumpenvmat   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),     shader_bumpenvmat   }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),     NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),     NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),     NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLSCALE),    { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLSCALE),    tex_bumpenvlscale   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLOFFSET),   { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLSCALE),    tex_bumpenvlscale   }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLOFFSET),   { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLSCALE),    NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLSCALE),    { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLSCALE),    tex_bumpenvlscale   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLOFFSET),   { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLSCALE),    tex_bumpenvlscale   }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLOFFSET),   { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLSCALE),    NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLSCALE),    { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLSCALE),    tex_bumpenvlscale   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLOFFSET),   { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLSCALE),    tex_bumpenvlscale   }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLOFFSET),   { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLSCALE),    NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLSCALE),    { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLSCALE),    tex_bumpenvlscale   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLOFFSET),   { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLSCALE),    tex_bumpenvlscale   }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLOFFSET),   { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLSCALE),    NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLSCALE),    { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLSCALE),    tex_bumpenvlscale   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLOFFSET),   { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLSCALE),    tex_bumpenvlscale   }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLOFFSET),   { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLSCALE),    NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLSCALE),    { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLSCALE),    tex_bumpenvlscale   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLOFFSET),   { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLSCALE),    tex_bumpenvlscale   }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLOFFSET),   { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLSCALE),    NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLSCALE),    { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLSCALE),    tex_bumpenvlscale   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLOFFSET),   { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLSCALE),    tex_bumpenvlscale   }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLOFFSET),   { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLSCALE),    NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLSCALE),    { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLSCALE),    tex_bumpenvlscale   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLOFFSET),   { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLSCALE),    tex_bumpenvlscale   }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLOFFSET),   { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLSCALE),    NULL                }, WINED3D_GL_EXT_NONE             },
 
     { STATE_VIEWPORT,                                     { STATE_VIEWPORT,                                     viewport_miscpart   }, WINED3D_GL_EXT_NONE             },
     { STATE_INDEXBUFFER,                                  { STATE_INDEXBUFFER,                                  indexbuffer         }, ARB_VERTEX_BUFFER_OBJECT        },
+    { STATE_INDEXBUFFER,                                  { STATE_INDEXBUFFER,                                  state_nop           }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_ANTIALIAS),                  { STATE_RENDER(WINED3DRS_ANTIALIAS),                  state_antialias     }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_TEXTUREPERSPECTIVE),         { STATE_RENDER(WINED3DRS_TEXTUREPERSPECTIVE),         state_perspective   }, WINED3D_GL_EXT_NONE             },
@@ -5044,7 +4941,7 @@
     { STATE_RENDER(WINED3DRS_ZWRITEENABLE),               { STATE_RENDER(WINED3DRS_ZWRITEENABLE),               state_zwritenable   }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_ALPHATESTENABLE),            { STATE_RENDER(WINED3DRS_ALPHATESTENABLE),            state_alpha         }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_ALPHAREF),                   { STATE_RENDER(WINED3DRS_ALPHATESTENABLE),            state_alpha         }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_ALPHAFUNC),                  { STATE_RENDER(WINED3DRS_ALPHATESTENABLE),            state_alpha         }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_COLORKEYENABLE),             { STATE_RENDER(WINED3DRS_ALPHATESTENABLE),            state_alpha         }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_ALPHAREF),                   { STATE_RENDER(WINED3DRS_ALPHATESTENABLE),            NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_ALPHAFUNC),                  { STATE_RENDER(WINED3DRS_ALPHATESTENABLE),            NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_COLORKEYENABLE),             { STATE_RENDER(WINED3DRS_ALPHATESTENABLE),            NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_LASTPIXEL),                  { STATE_RENDER(WINED3DRS_LASTPIXEL),                  state_lastpixel     }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_CULLMODE),                   { STATE_RENDER(WINED3DRS_CULLMODE),                   state_cullmode      }, WINED3D_GL_EXT_NONE             },
@@ -5061,33 +4958,33 @@
     { STATE_RENDER(WINED3DRS_TRANSLUCENTSORTINDEPENDENT), { STATE_RENDER(WINED3DRS_TRANSLUCENTSORTINDEPENDENT), state_translucentsi }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_STENCILENABLE),              { STATE_RENDER(WINED3DRS_STENCILENABLE),              state_stencil       }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_STENCILFAIL),                { STATE_RENDER(WINED3DRS_STENCILENABLE),              state_stencil       }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_STENCILZFAIL),               { STATE_RENDER(WINED3DRS_STENCILENABLE),              state_stencil       }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_STENCILPASS),                { STATE_RENDER(WINED3DRS_STENCILENABLE),              state_stencil       }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_STENCILFUNC),                { STATE_RENDER(WINED3DRS_STENCILENABLE),              state_stencil       }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_STENCILREF),                 { STATE_RENDER(WINED3DRS_STENCILENABLE),              state_stencil       }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_STENCILMASK),                { STATE_RENDER(WINED3DRS_STENCILENABLE),              state_stencil       }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_STENCILFAIL),                { STATE_RENDER(WINED3DRS_STENCILENABLE),              NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_STENCILZFAIL),               { STATE_RENDER(WINED3DRS_STENCILENABLE),              NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_STENCILPASS),                { STATE_RENDER(WINED3DRS_STENCILENABLE),              NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_STENCILFUNC),                { STATE_RENDER(WINED3DRS_STENCILENABLE),              NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_STENCILREF),                 { STATE_RENDER(WINED3DRS_STENCILENABLE),              NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_STENCILMASK),                { STATE_RENDER(WINED3DRS_STENCILENABLE),              NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_STENCILWRITEMASK),           { STATE_RENDER(WINED3DRS_STENCILWRITEMASK),           state_stencilwrite2s}, EXT_STENCIL_TWO_SIDE            },
     { STATE_RENDER(WINED3DRS_STENCILWRITEMASK),           { STATE_RENDER(WINED3DRS_STENCILWRITEMASK),           state_stencilwrite  }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_TWOSIDEDSTENCILMODE),        { STATE_RENDER(WINED3DRS_STENCILENABLE),              state_stencil       }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_CCW_STENCILFAIL),            { STATE_RENDER(WINED3DRS_STENCILENABLE),              state_stencil       }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_CCW_STENCILZFAIL),           { STATE_RENDER(WINED3DRS_STENCILENABLE),              state_stencil       }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_CCW_STENCILPASS),            { STATE_RENDER(WINED3DRS_STENCILENABLE),              state_stencil       }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_CCW_STENCILFUNC),            { STATE_RENDER(WINED3DRS_STENCILENABLE),              state_stencil       }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_TWOSIDEDSTENCILMODE),        { STATE_RENDER(WINED3DRS_STENCILENABLE),              NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_CCW_STENCILFAIL),            { STATE_RENDER(WINED3DRS_STENCILENABLE),              NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_CCW_STENCILZFAIL),           { STATE_RENDER(WINED3DRS_STENCILENABLE),              NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_CCW_STENCILPASS),            { STATE_RENDER(WINED3DRS_STENCILENABLE),              NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_CCW_STENCILFUNC),            { STATE_RENDER(WINED3DRS_STENCILENABLE),              NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_WRAP0),                      { STATE_RENDER(WINED3DRS_WRAP0),                      state_wrap          }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_WRAP1),                      { STATE_RENDER(WINED3DRS_WRAP0),                      state_wrap          }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_WRAP2),                      { STATE_RENDER(WINED3DRS_WRAP0),                      state_wrap          }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_WRAP3),                      { STATE_RENDER(WINED3DRS_WRAP0),                      state_wrap          }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_WRAP4),                      { STATE_RENDER(WINED3DRS_WRAP0),                      state_wrap          }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_WRAP5),                      { STATE_RENDER(WINED3DRS_WRAP0),                      state_wrap          }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_WRAP6),                      { STATE_RENDER(WINED3DRS_WRAP0),                      state_wrap          }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_WRAP7),                      { STATE_RENDER(WINED3DRS_WRAP0),                      state_wrap          }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_WRAP8),                      { STATE_RENDER(WINED3DRS_WRAP0),                      state_wrap          }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_WRAP9),                      { STATE_RENDER(WINED3DRS_WRAP0),                      state_wrap          }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_WRAP10),                     { STATE_RENDER(WINED3DRS_WRAP0),                      state_wrap          }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_WRAP11),                     { STATE_RENDER(WINED3DRS_WRAP0),                      state_wrap          }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_WRAP12),                     { STATE_RENDER(WINED3DRS_WRAP0),                      state_wrap          }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_WRAP13),                     { STATE_RENDER(WINED3DRS_WRAP0),                      state_wrap          }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_WRAP14),                     { STATE_RENDER(WINED3DRS_WRAP0),                      state_wrap          }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_WRAP15),                     { STATE_RENDER(WINED3DRS_WRAP0),                      state_wrap          }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_WRAP1),                      { STATE_RENDER(WINED3DRS_WRAP0),                      NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_WRAP2),                      { STATE_RENDER(WINED3DRS_WRAP0),                      NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_WRAP3),                      { STATE_RENDER(WINED3DRS_WRAP0),                      NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_WRAP4),                      { STATE_RENDER(WINED3DRS_WRAP0),                      NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_WRAP5),                      { STATE_RENDER(WINED3DRS_WRAP0),                      NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_WRAP6),                      { STATE_RENDER(WINED3DRS_WRAP0),                      NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_WRAP7),                      { STATE_RENDER(WINED3DRS_WRAP0),                      NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_WRAP8),                      { STATE_RENDER(WINED3DRS_WRAP0),                      NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_WRAP9),                      { STATE_RENDER(WINED3DRS_WRAP0),                      NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_WRAP10),                     { STATE_RENDER(WINED3DRS_WRAP0),                      NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_WRAP11),                     { STATE_RENDER(WINED3DRS_WRAP0),                      NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_WRAP12),                     { STATE_RENDER(WINED3DRS_WRAP0),                      NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_WRAP13),                     { STATE_RENDER(WINED3DRS_WRAP0),                      NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_WRAP14),                     { STATE_RENDER(WINED3DRS_WRAP0),                      NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_WRAP15),                     { STATE_RENDER(WINED3DRS_WRAP0),                      NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_EXTENTS),                    { STATE_RENDER(WINED3DRS_EXTENTS),                    state_extents       }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_COLORKEYBLENDENABLE),        { STATE_RENDER(WINED3DRS_COLORKEYBLENDENABLE),        state_ckeyblend     }, WINED3D_GL_EXT_NONE             },
@@ -5097,10 +4994,10 @@
     { STATE_RENDER(WINED3DRS_POSITIONDEGREE),             { STATE_RENDER(WINED3DRS_POSITIONDEGREE),             state_positiondegree}, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_NORMALDEGREE),               { STATE_RENDER(WINED3DRS_NORMALDEGREE),               state_normaldegree  }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_MINTESSELLATIONLEVEL),       { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_tessellation  }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_MAXTESSELLATIONLEVEL),       { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_tessellation  }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_ADAPTIVETESS_X),             { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_tessellation  }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_ADAPTIVETESS_Y),             { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_tessellation  }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_ADAPTIVETESS_Z),             { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_tessellation  }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_ADAPTIVETESS_W),             { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_tessellation  }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_MINTESSELLATIONLEVEL),       { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_MAXTESSELLATIONLEVEL),       { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_ADAPTIVETESS_X),             { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_ADAPTIVETESS_Y),             { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_ADAPTIVETESS_Z),             { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_ADAPTIVETESS_W),             { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_tessellation  }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_MULTISAMPLEANTIALIAS),       { STATE_RENDER(WINED3DRS_MULTISAMPLEANTIALIAS),       state_msaa          }, ARB_MULTISAMPLE                 },
@@ -5108,15 +5005,20 @@
     { STATE_RENDER(WINED3DRS_MULTISAMPLEMASK),            { STATE_RENDER(WINED3DRS_MULTISAMPLEMASK),            state_multisampmask }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_DEBUGMONITORTOKEN),          { STATE_RENDER(WINED3DRS_DEBUGMONITORTOKEN),          state_debug_monitor }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_COLORWRITEENABLE),           { STATE_RENDER(WINED3DRS_COLORWRITEENABLE),           state_colorwrite0   }, EXT_DRAW_BUFFERS2               },
     { STATE_RENDER(WINED3DRS_COLORWRITEENABLE),           { STATE_RENDER(WINED3DRS_COLORWRITEENABLE),           state_colorwrite    }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_BLENDOP),                    { STATE_RENDER(WINED3DRS_BLENDOP),                    state_blendop       }, EXT_BLEND_MINMAX                },
     { STATE_RENDER(WINED3DRS_BLENDOP),                    { STATE_RENDER(WINED3DRS_BLENDOP),                    state_blendop_w     }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_SCISSORTESTENABLE),          { STATE_RENDER(WINED3DRS_SCISSORTESTENABLE),          state_scissor       }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_SLOPESCALEDEPTHBIAS),        { STATE_RENDER(WINED3DRS_DEPTHBIAS),                  state_depthbias     }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_COLORWRITEENABLE1),          { STATE_RENDER(WINED3DRS_COLORWRITEENABLE),           state_colorwrite    }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_COLORWRITEENABLE2),          { STATE_RENDER(WINED3DRS_COLORWRITEENABLE),           state_colorwrite    }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_COLORWRITEENABLE3),          { STATE_RENDER(WINED3DRS_COLORWRITEENABLE),           state_colorwrite    }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_SLOPESCALEDEPTHBIAS),        { STATE_RENDER(WINED3DRS_DEPTHBIAS),                  NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_COLORWRITEENABLE1),          { STATE_RENDER(WINED3DRS_COLORWRITEENABLE1),          state_colorwrite1   }, EXT_DRAW_BUFFERS2               },
+    { STATE_RENDER(WINED3DRS_COLORWRITEENABLE1),          { STATE_RENDER(WINED3DRS_COLORWRITEENABLE),           NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_COLORWRITEENABLE2),          { STATE_RENDER(WINED3DRS_COLORWRITEENABLE2),          state_colorwrite2   }, EXT_DRAW_BUFFERS2               },
+    { STATE_RENDER(WINED3DRS_COLORWRITEENABLE2),          { STATE_RENDER(WINED3DRS_COLORWRITEENABLE),           NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_COLORWRITEENABLE3),          { STATE_RENDER(WINED3DRS_COLORWRITEENABLE3),          state_colorwrite3   }, EXT_DRAW_BUFFERS2               },
+    { STATE_RENDER(WINED3DRS_COLORWRITEENABLE3),          { STATE_RENDER(WINED3DRS_COLORWRITEENABLE),           NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_BLENDFACTOR),                { STATE_RENDER(WINED3DRS_BLENDFACTOR),                state_blendfactor   }, EXT_BLEND_COLOR                 },
     { STATE_RENDER(WINED3DRS_BLENDFACTOR),                { STATE_RENDER(WINED3DRS_BLENDFACTOR),                state_blendfactor_w }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_DEPTHBIAS),                  { STATE_RENDER(WINED3DRS_DEPTHBIAS),                  state_depthbias     }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_ZVISIBLE),                   { STATE_RENDER(WINED3DRS_ZVISIBLE),                   state_zvisible      }, WINED3D_GL_EXT_NONE             },
     /* Samplers */
     { STATE_SAMPLER(0),                                   { STATE_SAMPLER(0),                                   sampler             }, WINED3D_GL_EXT_NONE             },
@@ -5145,6 +5047,6 @@
 const struct StateEntryTemplate ffp_vertexstate_template[] = {
     { STATE_VDECL,                                        { STATE_VDECL,                                        vertexdeclaration   }, WINED3D_GL_EXT_NONE             },
-    { STATE_VSHADER,                                      { STATE_VDECL,                                        vertexdeclaration   }, WINED3D_GL_EXT_NONE             },
-    { STATE_MATERIAL,                                     { STATE_RENDER(WINED3DRS_SPECULARENABLE),             state_specularenable}, WINED3D_GL_EXT_NONE             },
+    { STATE_VSHADER,                                      { STATE_VDECL,                                        NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_MATERIAL,                                     { STATE_RENDER(WINED3DRS_SPECULARENABLE),             NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_SPECULARENABLE),             { STATE_RENDER(WINED3DRS_SPECULARENABLE),             state_specularenable}, WINED3D_GL_EXT_NONE             },
       /* Clip planes */
@@ -5195,12 +5097,12 @@
     { STATE_TRANSFORM(WINED3DTS_VIEW),                    { STATE_TRANSFORM(WINED3DTS_VIEW),                    transform_view      }, WINED3D_GL_EXT_NONE             },
     { STATE_TRANSFORM(WINED3DTS_PROJECTION),              { STATE_TRANSFORM(WINED3DTS_PROJECTION),              transform_projection}, WINED3D_GL_EXT_NONE             },
-    { STATE_TRANSFORM(WINED3DTS_TEXTURE0),                { STATE_TEXTURESTAGE(0,WINED3DTSS_TEXTURETRANSFORMFLAGS),  transform_texture   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TRANSFORM(WINED3DTS_TEXTURE1),                { STATE_TEXTURESTAGE(1,WINED3DTSS_TEXTURETRANSFORMFLAGS),  transform_texture   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TRANSFORM(WINED3DTS_TEXTURE2),                { STATE_TEXTURESTAGE(2,WINED3DTSS_TEXTURETRANSFORMFLAGS),  transform_texture   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TRANSFORM(WINED3DTS_TEXTURE3),                { STATE_TEXTURESTAGE(3,WINED3DTSS_TEXTURETRANSFORMFLAGS),  transform_texture   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TRANSFORM(WINED3DTS_TEXTURE4),                { STATE_TEXTURESTAGE(4,WINED3DTSS_TEXTURETRANSFORMFLAGS),  transform_texture   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TRANSFORM(WINED3DTS_TEXTURE5),                { STATE_TEXTURESTAGE(5,WINED3DTSS_TEXTURETRANSFORMFLAGS),  transform_texture   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TRANSFORM(WINED3DTS_TEXTURE6),                { STATE_TEXTURESTAGE(6,WINED3DTSS_TEXTURETRANSFORMFLAGS),  transform_texture   }, WINED3D_GL_EXT_NONE             },
-    { STATE_TRANSFORM(WINED3DTS_TEXTURE7),                { STATE_TEXTURESTAGE(7,WINED3DTSS_TEXTURETRANSFORMFLAGS),  transform_texture   }, WINED3D_GL_EXT_NONE             },
+    { STATE_TRANSFORM(WINED3DTS_TEXTURE0),                { STATE_TEXTURESTAGE(0,WINED3DTSS_TEXTURETRANSFORMFLAGS), NULL            }, WINED3D_GL_EXT_NONE             },
+    { STATE_TRANSFORM(WINED3DTS_TEXTURE1),                { STATE_TEXTURESTAGE(1,WINED3DTSS_TEXTURETRANSFORMFLAGS), NULL            }, WINED3D_GL_EXT_NONE             },
+    { STATE_TRANSFORM(WINED3DTS_TEXTURE2),                { STATE_TEXTURESTAGE(2,WINED3DTSS_TEXTURETRANSFORMFLAGS), NULL            }, WINED3D_GL_EXT_NONE             },
+    { STATE_TRANSFORM(WINED3DTS_TEXTURE3),                { STATE_TEXTURESTAGE(3,WINED3DTSS_TEXTURETRANSFORMFLAGS), NULL            }, WINED3D_GL_EXT_NONE             },
+    { STATE_TRANSFORM(WINED3DTS_TEXTURE4),                { STATE_TEXTURESTAGE(4,WINED3DTSS_TEXTURETRANSFORMFLAGS), NULL            }, WINED3D_GL_EXT_NONE             },
+    { STATE_TRANSFORM(WINED3DTS_TEXTURE5),                { STATE_TEXTURESTAGE(5,WINED3DTSS_TEXTURETRANSFORMFLAGS), NULL            }, WINED3D_GL_EXT_NONE             },
+    { STATE_TRANSFORM(WINED3DTS_TEXTURE6),                { STATE_TEXTURESTAGE(6,WINED3DTSS_TEXTURETRANSFORMFLAGS), NULL            }, WINED3D_GL_EXT_NONE             },
+    { STATE_TRANSFORM(WINED3DTS_TEXTURE7),                { STATE_TEXTURESTAGE(7,WINED3DTSS_TEXTURETRANSFORMFLAGS), NULL            }, WINED3D_GL_EXT_NONE             },
     { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(  0)),        { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(  0)),        transform_world     }, WINED3D_GL_EXT_NONE             },
     { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(  1)),        { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(  1)),        transform_worldex   }, WINED3D_GL_EXT_NONE             },
@@ -5477,10 +5379,10 @@
       /* Fog */
     { STATE_RENDER(WINED3DRS_FOGENABLE),                  { STATE_RENDER(WINED3DRS_FOGENABLE),                  state_fog_vertexpart}, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_FOGTABLEMODE),               { STATE_RENDER(WINED3DRS_FOGENABLE),                  state_fog_vertexpart}, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_FOGVERTEXMODE),              { STATE_RENDER(WINED3DRS_FOGENABLE),                  state_fog_vertexpart}, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_FOGTABLEMODE),               { STATE_RENDER(WINED3DRS_FOGENABLE),                  NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_FOGVERTEXMODE),              { STATE_RENDER(WINED3DRS_FOGENABLE),                  NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_RANGEFOGENABLE),             { STATE_RENDER(WINED3DRS_RANGEFOGENABLE),             state_rangefog      }, NV_FOG_DISTANCE                 },
     { STATE_RENDER(WINED3DRS_RANGEFOGENABLE),             { STATE_RENDER(WINED3DRS_RANGEFOGENABLE),             state_rangefog_w    }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_CLIPPING),                   { STATE_RENDER(WINED3DRS_CLIPPING),                   state_clipping      }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_CLIPPLANEENABLE),            { STATE_RENDER(WINED3DRS_CLIPPING),                   state_clipping      }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_CLIPPLANEENABLE),            { STATE_RENDER(WINED3DRS_CLIPPING),                   NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_LIGHTING),                   { STATE_RENDER(WINED3DRS_LIGHTING),                   state_lighting      }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_AMBIENT),                    { STATE_RENDER(WINED3DRS_AMBIENT),                    state_ambient       }, WINED3D_GL_EXT_NONE             },
@@ -5488,11 +5390,11 @@
     { STATE_RENDER(WINED3DRS_LOCALVIEWER),                { STATE_RENDER(WINED3DRS_LOCALVIEWER),                state_localviewer   }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_NORMALIZENORMALS),           { STATE_RENDER(WINED3DRS_NORMALIZENORMALS),           state_normalize     }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_DIFFUSEMATERIALSOURCE),      { STATE_RENDER(WINED3DRS_COLORVERTEX),                state_colormat      }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_SPECULARMATERIALSOURCE),     { STATE_RENDER(WINED3DRS_COLORVERTEX),                state_colormat      }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_AMBIENTMATERIALSOURCE),      { STATE_RENDER(WINED3DRS_COLORVERTEX),                state_colormat      }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_EMISSIVEMATERIALSOURCE),     { STATE_RENDER(WINED3DRS_COLORVERTEX),                state_colormat      }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_DIFFUSEMATERIALSOURCE),      { STATE_RENDER(WINED3DRS_COLORVERTEX),                NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_SPECULARMATERIALSOURCE),     { STATE_RENDER(WINED3DRS_COLORVERTEX),                NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_AMBIENTMATERIALSOURCE),      { STATE_RENDER(WINED3DRS_COLORVERTEX),                NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_EMISSIVEMATERIALSOURCE),     { STATE_RENDER(WINED3DRS_COLORVERTEX),                NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_VERTEXBLEND),                { STATE_RENDER(WINED3DRS_VERTEXBLEND),                state_vertexblend   }, ARB_VERTEX_BLEND                },
     { STATE_RENDER(WINED3DRS_VERTEXBLEND),                { STATE_RENDER(WINED3DRS_VERTEXBLEND),                state_vertexblend_w }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_POINTSIZE),                  { STATE_RENDER(WINED3DRS_POINTSCALEENABLE),           state_pscale        }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_POINTSIZE),                  { STATE_RENDER(WINED3DRS_POINTSCALEENABLE),           NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_POINTSIZE_MIN),              { STATE_RENDER(WINED3DRS_POINTSIZE_MIN),              state_psizemin_arb  }, ARB_POINT_PARAMETERS            },
     { STATE_RENDER(WINED3DRS_POINTSIZE_MIN),              { STATE_RENDER(WINED3DRS_POINTSIZE_MIN),              state_psizemin_ext  }, EXT_POINT_PARAMETERS            },
@@ -5501,10 +5403,13 @@
     { STATE_RENDER(WINED3DRS_POINTSPRITEENABLE),          { STATE_RENDER(WINED3DRS_POINTSPRITEENABLE),          state_pointsprite_w }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_POINTSCALEENABLE),           { STATE_RENDER(WINED3DRS_POINTSCALEENABLE),           state_pscale        }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_POINTSCALE_A),               { STATE_RENDER(WINED3DRS_POINTSCALEENABLE),           state_pscale        }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_POINTSCALE_B),               { STATE_RENDER(WINED3DRS_POINTSCALEENABLE),           state_pscale        }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_POINTSCALE_C),               { STATE_RENDER(WINED3DRS_POINTSCALEENABLE),           state_pscale        }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_POINTSIZE_MAX),              { STATE_RENDER(WINED3DRS_POINTSIZE_MIN),              state_psizemin_arb  }, ARB_POINT_PARAMETERS            },
-    { STATE_RENDER(WINED3DRS_POINTSIZE_MAX),              { STATE_RENDER(WINED3DRS_POINTSIZE_MIN),              state_psizemin_ext  }, EXT_POINT_PARAMETERS            },
-    { STATE_RENDER(WINED3DRS_POINTSIZE_MAX),              { STATE_RENDER(WINED3DRS_POINTSIZE_MIN),              state_psizemin_w    }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_POINTSCALE_A),               { STATE_RENDER(WINED3DRS_POINTSCALEENABLE),           NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_POINTSCALE_B),               { STATE_RENDER(WINED3DRS_POINTSCALEENABLE),           NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_POINTSCALE_C),               { STATE_RENDER(WINED3DRS_POINTSCALEENABLE),           NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_POINTSIZE_MAX),              { STATE_RENDER(WINED3DRS_POINTSIZE_MIN),              NULL                }, ARB_POINT_PARAMETERS            },
+    { STATE_RENDER(WINED3DRS_POINTSIZE_MAX),              { STATE_RENDER(WINED3DRS_POINTSIZE_MIN),              NULL                }, EXT_POINT_PARAMETERS            },
+    { STATE_RENDER(WINED3DRS_POINTSIZE_MAX),              { STATE_RENDER(WINED3DRS_POINTSIZE_MIN),              NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_TWEENFACTOR),                { STATE_RENDER(WINED3DRS_VERTEXBLEND),                NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_INDEXEDVERTEXBLENDENABLE),   { STATE_RENDER(WINED3DRS_VERTEXBLEND),                NULL                }, WINED3D_GL_EXT_NONE             },
+
     /* Samplers for NP2 texture matrix adjustions. They are not needed if GL_ARB_texture_non_power_of_two is supported,
      * so register a NULL state handler in that case to get the vertex part of sampler() skipped(VTF is handled in the misc states.
@@ -5540,94 +5445,93 @@
 static const struct StateEntryTemplate ffp_fragmentstate_template[] = {
     { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP),          { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(0, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(0, WINED3DTSS_CONSTANT),         { 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl          }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(0, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(0, WINED3DTSS_CONSTANT),         { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP),          { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP),          { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(1, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(1, WINED3DTSS_CONSTANT),         { 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl          }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(1, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(1, WINED3DTSS_CONSTANT),         { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP),          { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP),          { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(2, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(2, WINED3DTSS_CONSTANT),         { 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl          }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(2, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(2, WINED3DTSS_CONSTANT),         { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP),          { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP),          { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(3, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(3, WINED3DTSS_CONSTANT),         { 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl          }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(3, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(3, WINED3DTSS_CONSTANT),         { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP),          { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP),          { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(4, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(4, WINED3DTSS_CONSTANT),         { 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl          }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(4, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(4, WINED3DTSS_CONSTANT),         { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP),          { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP),          { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(5, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(5, WINED3DTSS_CONSTANT),         { 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl          }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(5, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(5, WINED3DTSS_CONSTANT),         { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP),          { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP),          { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(6, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(6, WINED3DTSS_CONSTANT),         { 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl          }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(6, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(6, WINED3DTSS_CONSTANT),         { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP),          { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP),          { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(7, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP),          tex_colorop         }, WINED3D_GL_EXT_NONE             },
-    { STATE_TEXTURESTAGE(7, WINED3DTSS_CONSTANT),         { 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl          }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(7, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP),          NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_TEXTURESTAGE(7, WINED3DTSS_CONSTANT),         { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_PIXELSHADER,                                  { STATE_PIXELSHADER,                                  apply_pixelshader   }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_SRGBWRITEENABLE),            { STATE_PIXELSHADER,                                  apply_pixelshader   }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_BORDERCOLOR),                { STATE_RENDER(WINED3DRS_BORDERCOLOR),                state_bordercolor   }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_SRGBWRITEENABLE),            { STATE_PIXELSHADER,                                  NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_TEXTUREFACTOR),              { STATE_RENDER(WINED3DRS_TEXTUREFACTOR),              state_texfactor     }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_FOGCOLOR),                   { STATE_RENDER(WINED3DRS_FOGCOLOR),                   state_fogcolor      }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_FOGDENSITY),                 { STATE_RENDER(WINED3DRS_FOGDENSITY),                 state_fogdensity    }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_FOGENABLE),                  { STATE_RENDER(WINED3DRS_FOGENABLE),                  state_fog_fragpart  }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_FOGTABLEMODE),               { STATE_RENDER(WINED3DRS_FOGENABLE),                  state_fog_fragpart  }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_FOGVERTEXMODE),              { STATE_RENDER(WINED3DRS_FOGENABLE),                  state_fog_fragpart  }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_FOGTABLEMODE),               { STATE_RENDER(WINED3DRS_FOGENABLE),                  NULL                }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_FOGVERTEXMODE),              { STATE_RENDER(WINED3DRS_FOGENABLE),                  NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_FOGSTART),                   { STATE_RENDER(WINED3DRS_FOGSTART),                   state_fogstartend   }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3DRS_FOGEND),                     { STATE_RENDER(WINED3DRS_FOGSTART),                   state_fogstartend   }, WINED3D_GL_EXT_NONE             },
+    { STATE_RENDER(WINED3DRS_FOGEND),                     { STATE_RENDER(WINED3DRS_FOGSTART),                   NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_SAMPLER(0),                                   { STATE_SAMPLER(0),                                   sampler_texdim      }, WINED3D_GL_EXT_NONE             },
     { STATE_SAMPLER(1),                                   { STATE_SAMPLER(1),                                   sampler_texdim      }, WINED3D_GL_EXT_NONE             },
@@ -5645,6 +5549,5 @@
 static void ffp_enable(IWineD3DDevice *iface, BOOL enable) { }
 
-static void ffp_fragment_get_caps(WINED3DDEVTYPE devtype,
-        const struct wined3d_gl_info *gl_info, struct fragment_caps *pCaps)
+static void ffp_fragment_get_caps(const struct wined3d_gl_info *gl_info, struct fragment_caps *pCaps)
 {
     pCaps->TextureOpCaps =  WINED3DTEXOPCAPS_ADD         |
@@ -5681,5 +5584,5 @@
         pCaps->TextureOpCaps |= WINED3DTEXOPCAPS_DOTPRODUCT3;
 
-    pCaps->MaxTextureBlendStages = gl_info->limits.texture_stages;
+    pCaps->MaxTextureBlendStages = gl_info->limits.textures;
     pCaps->MaxSimultaneousTextures = gl_info->limits.textures;
 }
@@ -5734,4 +5637,115 @@
     stateblock->device->multistate_funcs[state][1](state, stateblock, context);
     stateblock->device->multistate_funcs[state][2](state, stateblock, context);
+}
+
+static void prune_invalid_states(struct StateEntry *state_table, const struct wined3d_gl_info *gl_info)
+{
+    unsigned int start, last, i;
+
+    start = STATE_TEXTURESTAGE(gl_info->limits.texture_stages, 0);
+    last = STATE_TEXTURESTAGE(MAX_TEXTURES - 1, WINED3D_HIGHEST_TEXTURE_STATE);
+    for (i = start; i <= last; ++i)
+    {
+        state_table[i].representative = 0;
+        state_table[i].apply = state_undefined;
+    }
+
+    start = STATE_TRANSFORM(WINED3DTS_TEXTURE0 + gl_info->limits.texture_stages);
+    last = STATE_TRANSFORM(WINED3DTS_TEXTURE0 + MAX_TEXTURES - 1);
+    for (i = start; i <= last; ++i)
+    {
+        state_table[i].representative = 0;
+        state_table[i].apply = state_undefined;
+    }
+
+    start = STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(gl_info->limits.blends));
+    last = STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(255));
+    for (i = start; i <= last; ++i)
+    {
+        state_table[i].representative = 0;
+        state_table[i].apply = state_undefined;
+    }
+}
+
+static void validate_state_table(struct StateEntry *state_table)
+{
+    static const struct
+    {
+        DWORD first;
+        DWORD last;
+    }
+    rs_holes[] =
+    {
+        {  1,   1},
+        {  3,   3},
+        { 17,  18},
+        { 21,  21},
+        { 42,  45},
+        { 61, 127},
+        {149, 150},
+        {169, 169},
+        {177, 177},
+        {196, 197},
+        {  0,   0},
+    };
+    static const DWORD simple_states[] =
+    {
+        STATE_MATERIAL,
+        STATE_VDECL,
+        STATE_STREAMSRC,
+        STATE_INDEXBUFFER,
+        STATE_VERTEXSHADERCONSTANT,
+        STATE_PIXELSHADERCONSTANT,
+        STATE_VSHADER,
+        STATE_PIXELSHADER,
+        STATE_VIEWPORT,
+        STATE_SCISSORRECT,
+        STATE_FRONTFACE,
+    };
+    unsigned int i, current;
+
+    for (i = STATE_RENDER(1), current = 0; i <= STATE_RENDER(WINEHIGHEST_RENDER_STATE); ++i)
+    {
+        if (!rs_holes[current].first || i < STATE_RENDER(rs_holes[current].first))
+        {
+            if (!state_table[i].representative)
+                ERR("State %s (%#x) should have a representative.\n", debug_d3dstate(i), i);
+        }
+        else if (state_table[i].representative)
+            ERR("State %s (%#x) shouldn't have a representative.\n", debug_d3dstate(i), i);
+
+        if (i == STATE_RENDER(rs_holes[current].last)) ++current;
+    }
+
+    for (i = 0; i < sizeof(simple_states) / sizeof(*simple_states); ++i)
+    {
+        if (!state_table[simple_states[i]].representative)
+            ERR("State %s (%#x) should have a representative.\n",
+                    debug_d3dstate(simple_states[i]), simple_states[i]);
+    }
+
+    for (i = 0; i < STATE_HIGHEST + 1; ++i)
+    {
+        DWORD rep = state_table[i].representative;
+        if (rep)
+        {
+            if (state_table[rep].representative != rep)
+            {
+                ERR("State %s (%#x) has invalid representative %s (%#x).\n",
+                        debug_d3dstate(i), i, debug_d3dstate(rep), rep);
+                state_table[i].representative = 0;
+            }
+
+            if (rep != i)
+            {
+                if (state_table[i].apply)
+                    ERR("State %s (%#x) has both a handler and representative.\n", debug_d3dstate(i), i);
+            }
+            else if (!state_table[i].apply)
+            {
+                ERR("Self representing state %s (%#x) has no handler.\n", debug_d3dstate(i), i);
+            }
+        }
+    }
 }
 
@@ -5788,5 +5802,5 @@
              * table
              */
-            if(!cur[i].content.apply) continue;
+            if (!cur[i].content.representative) continue;
 
             handlers = num_handlers(multistate_funcs[cur[i].state]);
@@ -5835,4 +5849,7 @@
     }
 
+    prune_invalid_states(StateTable, gl_info);
+    validate_state_table(StateTable);
+
     return WINED3D_OK;
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/stateblock.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/stateblock.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/stateblock.c	(revision 28475)
@@ -767,5 +767,5 @@
         TRACE("Updating scissor rect.\n");
 
-        targetStateBlock->scissorRect = This->scissorRect;
+        This->scissorRect = targetStateBlock->scissorRect;
     }
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/surface.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/surface.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/surface.c	(revision 28475)
@@ -108,5 +108,5 @@
 }
 
-UINT surface_calculate_size(const struct GlPixelFormatDesc *format_desc, UINT alignment, UINT width, UINT height)
+UINT surface_calculate_size(const struct wined3d_format_desc *format_desc, UINT alignment, UINT width, UINT height)
 {
     UINT size;
@@ -131,4 +131,224 @@
 
     return size;
+}
+
+struct blt_info
+{
+    GLenum binding;
+    GLenum bind_target;
+    enum tex_types tex_type;
+    GLfloat coords[4][3];
+};
+
+struct float_rect
+{
+    float l;
+    float t;
+    float r;
+    float b;
+};
+
+static inline void cube_coords_float(const RECT *r, UINT w, UINT h, struct float_rect *f)
+{
+    f->l = ((r->left * 2.0f) / w) - 1.0f;
+    f->t = ((r->top * 2.0f) / h) - 1.0f;
+    f->r = ((r->right * 2.0f) / w) - 1.0f;
+    f->b = ((r->bottom * 2.0f) / h) - 1.0f;
+}
+
+static void surface_get_blt_info(GLenum target, const RECT *rect_in, GLsizei w, GLsizei h, struct blt_info *info)
+{
+    GLfloat (*coords)[3] = info->coords;
+    RECT rect;
+    struct float_rect f;
+
+    if (rect_in)
+        rect = *rect_in;
+    else
+    {
+        rect.left = 0;
+        rect.top = h;
+        rect.right = w;
+        rect.bottom = 0;
+    }
+
+    switch (target)
+    {
+        default:
+            FIXME("Unsupported texture target %#x\n", target);
+            /* Fall back to GL_TEXTURE_2D */
+        case GL_TEXTURE_2D:
+            info->binding = GL_TEXTURE_BINDING_2D;
+            info->bind_target = GL_TEXTURE_2D;
+            info->tex_type = tex_2d;
+            coords[0][0] = (float)rect.left / w;
+            coords[0][1] = (float)rect.top / h;
+            coords[0][2] = 0.0f;
+
+            coords[1][0] = (float)rect.right / w;
+            coords[1][1] = (float)rect.top / h;
+            coords[1][2] = 0.0f;
+
+            coords[2][0] = (float)rect.left / w;
+            coords[2][1] = (float)rect.bottom / h;
+            coords[2][2] = 0.0f;
+
+            coords[3][0] = (float)rect.right / w;
+            coords[3][1] = (float)rect.bottom / h;
+            coords[3][2] = 0.0f;
+            break;
+
+        case GL_TEXTURE_RECTANGLE_ARB:
+            info->binding = GL_TEXTURE_BINDING_RECTANGLE_ARB;
+            info->bind_target = GL_TEXTURE_RECTANGLE_ARB;
+            info->tex_type = tex_rect;
+            coords[0][0] = rect.left;   coords[0][1] = rect.top;     coords[0][2] = 0.0f;
+            coords[1][0] = rect.right;  coords[1][1] = rect.top;     coords[1][2] = 0.0f;
+            coords[2][0] = rect.left;   coords[2][1] = rect.bottom;  coords[2][2] = 0.0f;
+            coords[3][0] = rect.right;  coords[3][1] = rect.bottom;  coords[3][2] = 0.0f;
+            break;
+
+        case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+            info->binding = GL_TEXTURE_BINDING_CUBE_MAP_ARB;
+            info->bind_target = GL_TEXTURE_CUBE_MAP_ARB;
+            info->tex_type = tex_cube;
+            cube_coords_float(&rect, w, h, &f);
+
+            coords[0][0] =  1.0f;   coords[0][1] = -f.t;   coords[0][2] = -f.l;
+            coords[1][0] =  1.0f;   coords[1][1] = -f.t;   coords[1][2] = -f.r;
+            coords[2][0] =  1.0f;   coords[2][1] = -f.b;   coords[2][2] = -f.l;
+            coords[3][0] =  1.0f;   coords[3][1] = -f.b;   coords[3][2] = -f.r;
+            break;
+
+        case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+            info->binding = GL_TEXTURE_BINDING_CUBE_MAP_ARB;
+            info->bind_target = GL_TEXTURE_CUBE_MAP_ARB;
+            info->tex_type = tex_cube;
+            cube_coords_float(&rect, w, h, &f);
+
+            coords[0][0] = -1.0f;   coords[0][1] = -f.t;   coords[0][2] = f.l;
+            coords[1][0] = -1.0f;   coords[1][1] = -f.t;   coords[1][2] = f.r;
+            coords[2][0] = -1.0f;   coords[2][1] = -f.b;   coords[2][2] = f.l;
+            coords[3][0] = -1.0f;   coords[3][1] = -f.b;   coords[3][2] = f.r;
+            break;
+
+        case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+            info->binding = GL_TEXTURE_BINDING_CUBE_MAP_ARB;
+            info->bind_target = GL_TEXTURE_CUBE_MAP_ARB;
+            info->tex_type = tex_cube;
+            cube_coords_float(&rect, w, h, &f);
+
+            coords[0][0] = f.l;   coords[0][1] =  1.0f;   coords[0][2] = f.t;
+            coords[1][0] = f.r;   coords[1][1] =  1.0f;   coords[1][2] = f.t;
+            coords[2][0] = f.l;   coords[2][1] =  1.0f;   coords[2][2] = f.b;
+            coords[3][0] = f.r;   coords[3][1] =  1.0f;   coords[3][2] = f.b;
+            break;
+
+        case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+            info->binding = GL_TEXTURE_BINDING_CUBE_MAP_ARB;
+            info->bind_target = GL_TEXTURE_CUBE_MAP_ARB;
+            info->tex_type = tex_cube;
+            cube_coords_float(&rect, w, h, &f);
+
+            coords[0][0] = f.l;   coords[0][1] = -1.0f;   coords[0][2] = -f.t;
+            coords[1][0] = f.r;   coords[1][1] = -1.0f;   coords[1][2] = -f.t;
+            coords[2][0] = f.l;   coords[2][1] = -1.0f;   coords[2][2] = -f.b;
+            coords[3][0] = f.r;   coords[3][1] = -1.0f;   coords[3][2] = -f.b;
+            break;
+
+        case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+            info->binding = GL_TEXTURE_BINDING_CUBE_MAP_ARB;
+            info->bind_target = GL_TEXTURE_CUBE_MAP_ARB;
+            info->tex_type = tex_cube;
+            cube_coords_float(&rect, w, h, &f);
+
+            coords[0][0] = f.l;   coords[0][1] = -f.t;   coords[0][2] =  1.0f;
+            coords[1][0] = f.r;   coords[1][1] = -f.t;   coords[1][2] =  1.0f;
+            coords[2][0] = f.l;   coords[2][1] = -f.b;   coords[2][2] =  1.0f;
+            coords[3][0] = f.r;   coords[3][1] = -f.b;   coords[3][2] =  1.0f;
+            break;
+
+        case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+            info->binding = GL_TEXTURE_BINDING_CUBE_MAP_ARB;
+            info->bind_target = GL_TEXTURE_CUBE_MAP_ARB;
+            info->tex_type = tex_cube;
+            cube_coords_float(&rect, w, h, &f);
+
+            coords[0][0] = -f.l;   coords[0][1] = -f.t;   coords[0][2] = -1.0f;
+            coords[1][0] = -f.r;   coords[1][1] = -f.t;   coords[1][2] = -1.0f;
+            coords[2][0] = -f.l;   coords[2][1] = -f.b;   coords[2][2] = -1.0f;
+            coords[3][0] = -f.r;   coords[3][1] = -f.b;   coords[3][2] = -1.0f;
+            break;
+    }
+}
+
+static inline void surface_get_rect(IWineD3DSurfaceImpl *This, const RECT *rect_in, RECT *rect_out)
+{
+    if (rect_in)
+        *rect_out = *rect_in;
+    else
+    {
+        rect_out->left = 0;
+        rect_out->top = 0;
+        rect_out->right = This->currentDesc.Width;
+        rect_out->bottom = This->currentDesc.Height;
+    }
+}
+
+/* GL locking and context activation is done by the caller */
+void draw_textured_quad(IWineD3DSurfaceImpl *src_surface, const RECT *src_rect, const RECT *dst_rect, WINED3DTEXTUREFILTERTYPE Filter)
+{
+    IWineD3DBaseTextureImpl *texture;
+    struct blt_info info;
+
+    surface_get_blt_info(src_surface->texture_target, src_rect, src_surface->pow2Width, src_surface->pow2Height, &info);
+
+    glEnable(info.bind_target);
+    checkGLcall("glEnable(bind_target)");
+
+    /* Bind the texture */
+    glBindTexture(info.bind_target, src_surface->texture_name);
+    checkGLcall("glBindTexture");
+
+    /* Filtering for StretchRect */
+    glTexParameteri(info.bind_target, GL_TEXTURE_MAG_FILTER,
+            wined3d_gl_mag_filter(magLookup, Filter));
+    checkGLcall("glTexParameteri");
+    glTexParameteri(info.bind_target, GL_TEXTURE_MIN_FILTER,
+            wined3d_gl_min_mip_filter(minMipLookup, Filter, WINED3DTEXF_NONE));
+    checkGLcall("glTexParameteri");
+    glTexParameteri(info.bind_target, GL_TEXTURE_WRAP_S, GL_CLAMP);
+    glTexParameteri(info.bind_target, GL_TEXTURE_WRAP_T, GL_CLAMP);
+    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+    checkGLcall("glTexEnvi");
+
+    /* Draw a quad */
+    glBegin(GL_TRIANGLE_STRIP);
+    glTexCoord3fv(info.coords[0]);
+    glVertex2i(dst_rect->left, dst_rect->top);
+
+    glTexCoord3fv(info.coords[1]);
+    glVertex2i(dst_rect->right, dst_rect->top);
+
+    glTexCoord3fv(info.coords[2]);
+    glVertex2i(dst_rect->left, dst_rect->bottom);
+
+    glTexCoord3fv(info.coords[3]);
+    glVertex2i(dst_rect->right, dst_rect->bottom);
+    glEnd();
+
+    /* Unbind the texture */
+    glBindTexture(info.bind_target, 0);
+    checkGLcall("glBindTexture(info->bind_target, 0)");
+
+    /* We changed the filtering settings on the texture. Inform the
+     * container about this to get the filters reset properly next draw. */
+    if (SUCCEEDED(IWineD3DSurface_GetContainer((IWineD3DSurface *)src_surface, &IID_IWineD3DBaseTexture, (void **)&texture)))
+    {
+        texture->baseTexture.texture_rgb.states[WINED3DTEXSTA_MAGFILTER] = WINED3DTEXF_POINT;
+        texture->baseTexture.texture_rgb.states[WINED3DTEXSTA_MINFILTER] = WINED3DTEXF_POINT;
+        texture->baseTexture.texture_rgb.states[WINED3DTEXSTA_MIPFILTER] = WINED3DTEXF_NONE;
+        IWineD3DBaseTexture_Release((IWineD3DBaseTexture *)texture);
+    }
 }
 
@@ -139,5 +359,5 @@
 {
     const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
-    const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(format, gl_info);
+    const struct wined3d_format_desc *format_desc = getFormatDescEntry(format, gl_info);
     void (*cleanup)(IWineD3DSurfaceImpl *This);
     unsigned int resource_size;
@@ -353,13 +573,10 @@
 }
 
-#undef GLINFO_LOCATION
-
-#define GLINFO_LOCATION This->resource.device->adapter->gl_info
-
 /* This call just downloads data, the caller is responsible for binding the
  * correct texture. */
 /* Context activation is done by the caller. */
-static void surface_download_data(IWineD3DSurfaceImpl *This) {
-    const struct GlPixelFormatDesc *format_desc = This->resource.format_desc;
+static void surface_download_data(IWineD3DSurfaceImpl *This, const struct wined3d_gl_info *gl_info)
+{
+    const struct wined3d_format_desc *format_desc = This->resource.format_desc;
 
     /* Only support read back of converted P8 surfaces */
@@ -512,9 +729,27 @@
  * correct texture. */
 /* Context activation is done by the caller. */
-static void surface_upload_data(IWineD3DSurfaceImpl *This, GLenum internal, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *data) {
-    const struct GlPixelFormatDesc *format_desc = This->resource.format_desc;
+static void surface_upload_data(IWineD3DSurfaceImpl *This, const struct wined3d_gl_info *gl_info,
+        const struct wined3d_format_desc *format_desc, BOOL srgb, const GLvoid *data)
+{
+    GLsizei width = This->currentDesc.Width;
+    GLsizei height = This->currentDesc.Height;
+    GLenum internal;
+
+    if (srgb)
+    {
+        internal = format_desc->glGammaInternal;
+    }
+    else if (This->resource.usage & WINED3DUSAGE_RENDERTARGET
+            && surface_is_offscreen((IWineD3DSurface *)This))
+    {
+        internal = format_desc->rtInternal;
+    }
+    else
+    {
+        internal = format_desc->glInternal;
+    }
 
     TRACE("This %p, internal %#x, width %d, height %d, format %#x, type %#x, data %p.\n",
-            This, internal, width, height, format, type, data);
+            This, internal, width, height, format_desc->glFormat, format_desc->glType, data);
     TRACE("target %#x, level %u, resource size %u.\n",
             This->texture_target, This->texture_level, This->resource.size);
@@ -546,5 +781,5 @@
 
         glTexSubImage2D(This->texture_target, This->texture_level,
-                0, 0, width, height, format, type, data);
+                0, 0, width, height, format_desc->glFormat, format_desc->glType, data);
         checkGLcall("glTexSubImage2D");
     }
@@ -557,4 +792,15 @@
 
     LEAVE_GL();
+
+    if (gl_info->quirks & WINED3D_QUIRK_FBO_TEX_UPDATE)
+    {
+        IWineD3DDeviceImpl *device = This->resource.device;
+        unsigned int i;
+
+        for (i = 0; i < device->numContexts; ++i)
+        {
+            context_surface_update(device->contexts[i], This);
+        }
+    }
 }
 
@@ -562,9 +808,26 @@
  * the correct texture. */
 /* Context activation is done by the caller. */
-static void surface_allocate_surface(IWineD3DSurfaceImpl *This, GLenum internal, GLsizei width, GLsizei height, GLenum format, GLenum type) {
-    const struct wined3d_gl_info *gl_info = &This->resource.device->adapter->gl_info;
-    const struct GlPixelFormatDesc *format_desc = This->resource.format_desc;
+static void surface_allocate_surface(IWineD3DSurfaceImpl *This, const struct wined3d_gl_info *gl_info,
+        const struct wined3d_format_desc *format_desc, BOOL srgb)
+{
     BOOL enable_client_storage = FALSE;
+    GLsizei width = This->pow2Width;
+    GLsizei height = This->pow2Height;
     const BYTE *mem = NULL;
+    GLenum internal;
+
+    if (srgb)
+    {
+        internal = format_desc->glGammaInternal;
+    }
+    else if (This->resource.usage & WINED3DUSAGE_RENDERTARGET
+            && surface_is_offscreen((IWineD3DSurface *)This))
+    {
+        internal = format_desc->rtInternal;
+    }
+    else
+    {
+        internal = format_desc->glInternal;
+    }
 
     if (format_desc->heightscale != 1.0f && format_desc->heightscale != 0.0f) height *= format_desc->heightscale;
@@ -572,5 +835,5 @@
     TRACE("(%p) : Creating surface (target %#x)  level %d, d3d format %s, internal format %#x, width %d, height %d, gl format %#x, gl type=%#x\n",
             This, This->texture_target, This->texture_level, debug_d3dformat(format_desc->format),
-            internal, width, height, format, type);
+            internal, width, height, format_desc->glFormat, format_desc->glType);
 
     ENTER_GL();
@@ -578,9 +841,8 @@
     if (gl_info->supported[APPLE_CLIENT_STORAGE])
     {
-        if(This->Flags & (SFLAG_NONPOW2 | SFLAG_DIBSECTION | SFLAG_OVERSIZE | SFLAG_CONVERTED) || This->resource.allocatedMemory == NULL) {
+        if(This->Flags & (SFLAG_NONPOW2 | SFLAG_DIBSECTION | SFLAG_CONVERTED) || This->resource.allocatedMemory == NULL) {
             /* In some cases we want to disable client storage.
              * SFLAG_NONPOW2 has a bigger opengl texture than the client memory, and different pitches
              * SFLAG_DIBSECTION: Dibsections may have read / write protections on the memory. Avoid issues...
-             * SFLAG_OVERSIZE: The gl texture is smaller than the allocated memory
              * SFLAG_CONVERTED: The conversion destination memory is freed after loading the surface
              * allocatedMemory == NULL: Not defined in the extension. Seems to disable client storage effectively
@@ -608,5 +870,5 @@
     {
         glTexImage2D(This->texture_target, This->texture_level,
-                internal, width, height, 0, format, type, mem);
+                internal, width, height, 0, format_desc->glFormat, format_desc->glType, mem);
         checkGLcall("glTexImage2D");
     }
@@ -741,13 +1003,57 @@
 }
 
-static inline BOOL surface_can_stretch_rect(IWineD3DSurfaceImpl *src, IWineD3DSurfaceImpl *dst)
-{
-    return ((src->resource.format_desc->Flags & WINED3DFMT_FLAG_FBO_ATTACHABLE)
-            || (src->resource.usage & WINED3DUSAGE_RENDERTARGET))
-            && ((dst->resource.format_desc->Flags & WINED3DFMT_FLAG_FBO_ATTACHABLE)
-            || (dst->resource.usage & WINED3DUSAGE_RENDERTARGET))
-            && (src->resource.format_desc->format == dst->resource.format_desc->format
-            || (is_identity_fixup(src->resource.format_desc->color_fixup)
-            && is_identity_fixup(dst->resource.format_desc->color_fixup)));
+static BOOL surface_convert_color_to_argb(IWineD3DSurfaceImpl *This, DWORD color, DWORD *argb_color)
+{
+    IWineD3DDeviceImpl *device = This->resource.device;
+
+    switch(This->resource.format_desc->format)
+    {
+        case WINED3DFMT_P8_UINT:
+            {
+                DWORD alpha;
+
+                if (primary_render_target_is_p8(device))
+                    alpha = color << 24;
+                else
+                    alpha = 0xFF000000;
+
+                if (This->palette) {
+                    *argb_color = (alpha |
+                            (This->palette->palents[color].peRed << 16) |
+                            (This->palette->palents[color].peGreen << 8) |
+                            (This->palette->palents[color].peBlue));
+                } else {
+                    *argb_color = alpha;
+                }
+            }
+            break;
+
+        case WINED3DFMT_B5G6R5_UNORM:
+            {
+                if (color == 0xFFFF) {
+                    *argb_color = 0xFFFFFFFF;
+                } else {
+                    *argb_color = ((0xFF000000) |
+                            ((color & 0xF800) << 8) |
+                            ((color & 0x07E0) << 5) |
+                            ((color & 0x001F) << 3));
+                }
+            }
+            break;
+
+        case WINED3DFMT_B8G8R8_UNORM:
+        case WINED3DFMT_B8G8R8X8_UNORM:
+            *argb_color = 0xFF000000 | color;
+            break;
+
+        case WINED3DFMT_B8G8R8A8_UNORM:
+            *argb_color = color;
+            break;
+
+        default:
+            ERR("Unhandled conversion from %s to ARGB!\n", debug_d3dformat(This->resource.format_desc->format));
+            return FALSE;
+    }
+    return TRUE;
 }
 
@@ -826,5 +1132,6 @@
 
 /* Context activation is done by the caller. */
-static void surface_remove_pbo(IWineD3DSurfaceImpl *This) {
+static void surface_remove_pbo(IWineD3DSurfaceImpl *This, const struct wined3d_gl_info *gl_info)
+{
     This->resource.heapMemory = HeapAlloc(GetProcessHeap() ,0 , This->resource.size + RESOURCE_ALIGNMENT);
     This->resource.allocatedMemory =
@@ -903,7 +1210,6 @@
 
     /* Destroy PBOs, but load them into real sysmem before */
-    if(This->Flags & SFLAG_PBO) {
-        surface_remove_pbo(This);
-    }
+    if (This->Flags & SFLAG_PBO)
+        surface_remove_pbo(This, gl_info);
 
     /* Destroy fbo render buffers. This is needed for implicit render targets, for
@@ -947,4 +1253,5 @@
 {
     IWineD3DDeviceImpl *myDevice = This->resource.device;
+    const struct wined3d_gl_info *gl_info;
     struct wined3d_context *context;
     BYTE *mem;
@@ -975,4 +1282,6 @@
      */
     context = context_acquire(myDevice, (IWineD3DSurface *) This, CTXUSAGE_BLIT);
+    gl_info = context->gl_info;
+
     ENTER_GL();
 
@@ -1190,12 +1499,8 @@
 {
     IWineD3DDeviceImpl *device = This->resource.device;
+    const struct wined3d_gl_info *gl_info;
     struct wined3d_context *context;
-    int bpp;
-    GLenum format, internal, type;
-    CONVERT_TYPES convert;
     GLint prevRead;
     BOOL alloc_flag = srgb ? SFLAG_SRGBALLOCATED : SFLAG_ALLOCATED;
-
-    d3dfmt_get_conv(This, TRUE /* We need color keying */, TRUE /* We will use textures */, &format, &internal, &type, &convert, &bpp, srgb);
 
     /* Activate the surface to read from. In some situations it isn't the currently active target(e.g. backbuffer
@@ -1204,4 +1509,6 @@
      */
     context = context_acquire(device, (IWineD3DSurface *) This, CTXUSAGE_RESOURCELOAD);
+    gl_info = context->gl_info;
+
     surface_bind_and_dirtify(This, srgb);
 
@@ -1236,7 +1543,7 @@
     }
 
-    if(!(This->Flags & alloc_flag)) {
-        surface_allocate_surface(This, internal, This->pow2Width,
-                                 This->pow2Height, format, type);
+    if (!(This->Flags & alloc_flag))
+    {
+        surface_allocate_surface(This, gl_info, This->resource.format_desc, srgb);
         This->Flags |= alloc_flag;
     }
@@ -1261,4 +1568,22 @@
 
     TRACE("Updated target %d\n", This->texture_target);
+}
+
+/* Context activation is done by the caller. */
+void surface_prepare_texture(IWineD3DSurfaceImpl *surface, const struct wined3d_gl_info *gl_info, BOOL srgb)
+{
+    DWORD alloc_flag = srgb ? SFLAG_SRGBALLOCATED : SFLAG_ALLOCATED;
+    CONVERT_TYPES convert;
+    struct wined3d_format_desc desc;
+
+    if (surface->Flags & alloc_flag) return;
+
+    d3dfmt_get_conv(surface, TRUE, TRUE, &desc, &convert);
+    if(convert != NO_CONVERSION) surface->Flags |= SFLAG_CONVERTED;
+    else surface->Flags &= ~SFLAG_CONVERTED;
+
+    surface_bind_and_dirtify(surface, srgb);
+    surface_allocate_surface(surface, gl_info, &desc, srgb);
+    surface->Flags |= alloc_flag;
 }
 
@@ -1391,7 +1716,10 @@
     if (This->Flags & SFLAG_PBO)
     {
+        const struct wined3d_gl_info *gl_info;
         struct wined3d_context *context;
 
         context = context_acquire(myDevice, NULL, CTXUSAGE_RESOURCELOAD);
+        gl_info = context->gl_info;
+
         ENTER_GL();
         GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, This->pbo));
@@ -1443,8 +1771,11 @@
     UINT pitch = IWineD3DSurface_GetPitch((IWineD3DSurface *) This);    /* target is argb, 4 byte */
     IWineD3DDeviceImpl *myDevice = This->resource.device;
+    const struct wined3d_gl_info *gl_info;
     struct wined3d_context *context;
 
     /* Activate the correct context for the render target */
     context = context_acquire(myDevice, (IWineD3DSurface *) This, CTXUSAGE_BLIT);
+    gl_info = context->gl_info;
+
     ENTER_GL();
 
@@ -1542,4 +1873,5 @@
     if (This->Flags & SFLAG_PBO)
     {
+        const struct wined3d_gl_info *gl_info;
         struct wined3d_context *context;
 
@@ -1547,4 +1879,6 @@
 
         context = context_acquire(myDevice, NULL, CTXUSAGE_RESOURCELOAD);
+        gl_info = context->gl_info;
+
         ENTER_GL();
         GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, This->pbo));
@@ -1794,26 +2128,15 @@
    ****************************************************** */
 
-HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_texturing, GLenum *format, GLenum *internal, GLenum *type, CONVERT_TYPES *convert, int *target_bpp, BOOL srgb_mode) {
+HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_texturing, struct wined3d_format_desc *desc, CONVERT_TYPES *convert)
+{
     BOOL colorkey_active = need_alpha_ck && (This->CKeyFlags & WINEDDSD_CKSRCBLT);
-    const struct GlPixelFormatDesc *glDesc = This->resource.format_desc;
     IWineD3DDeviceImpl *device = This->resource.device;
-    const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
-
-    /* Default values: From the surface */
-    *format = glDesc->glFormat;
-    *type = glDesc->glType;
+    BOOL blit_supported = FALSE;
+    RECT rect = {0, 0, This->pow2Width, This->pow2Height};
+
+    /* Copy the default values from the surface. Below we might perform fixups */
+    /* TODO: get rid of color keying desc fixups by using e.g. a table. */
+    *desc = *This->resource.format_desc;
     *convert = NO_CONVERSION;
-    *target_bpp = glDesc->byte_count;
-
-    if(srgb_mode) {
-        *internal = glDesc->glGammaInternal;
-    }
-    else if (This->resource.usage & WINED3DUSAGE_RENDERTARGET
-            && surface_is_offscreen((IWineD3DSurface *) This))
-    {
-        *internal = glDesc->rtInternal;
-    } else {
-        *internal = glDesc->glInternal;
-    }
 
     /* Ok, now look if we have to do any conversion */
@@ -1825,19 +2148,22 @@
                 **************** */
 
-             /* Use conversion when the paletted texture extension OR fragment shaders are available. When either
-             * of the two is available make sure texturing is requested as neither of the two works in
-             * conjunction with calls like glDraw-/glReadPixels. Further also use conversion in case of color keying.
+            blit_supported = device->blitter->blit_supported(&device->adapter->gl_info, BLIT_OP_BLIT,
+                                                             &rect, This->resource.usage, This->resource.pool,
+                                                             This->resource.format_desc, &rect, This->resource.usage,
+                                                             This->resource.pool, This->resource.format_desc);
+
+            /* Use conversion when the blit_shader backend supports it. It only supports this in case of
+             * texturing. Further also use conversion in case of color keying.
              * Paletted textures can be emulated using shaders but only do that for 2D purposes e.g. situations
              * in which the main render target uses p8. Some games like GTA Vice City use P8 for texturing which
              * conflicts with this.
              */
-            if (!(gl_info->supported[EXT_PALETTED_TEXTURE] || (gl_info->supported[ARB_FRAGMENT_PROGRAM]
-                    && device->render_targets && This == (IWineD3DSurfaceImpl*)device->render_targets[0]))
+            if (!((blit_supported && device->render_targets && This == (IWineD3DSurfaceImpl*)device->render_targets[0]))
                     || colorkey_active || !use_texturing)
             {
-                *format = GL_RGBA;
-                *internal = GL_RGBA;
-                *type = GL_UNSIGNED_BYTE;
-                *target_bpp = 4;
+                desc->glFormat = GL_RGBA;
+                desc->glInternal = GL_RGBA;
+                desc->glType = GL_UNSIGNED_BYTE;
+                desc->conv_byte_count = 4;
                 if(colorkey_active) {
                     *convert = CONVERT_PALETTED_CK;
@@ -1846,11 +2172,4 @@
                 }
             }
-            else if (!gl_info->supported[EXT_PALETTED_TEXTURE] && gl_info->supported[ARB_FRAGMENT_PROGRAM])
-            {
-                *format = GL_ALPHA;
-                *type = GL_UNSIGNED_BYTE;
-                *target_bpp = 1;
-            }
-
             break;
 
@@ -1869,7 +2188,8 @@
             if (colorkey_active) {
                 *convert = CONVERT_CK_565;
-                *format = GL_RGBA;
-                *internal = GL_RGB5_A1;
-                *type = GL_UNSIGNED_SHORT_5_5_5_1;
+                desc->glFormat = GL_RGBA;
+                desc->glInternal = GL_RGB5_A1;
+                desc->glType = GL_UNSIGNED_SHORT_5_5_5_1;
+                desc->conv_byte_count = 2;
             }
             break;
@@ -1878,7 +2198,8 @@
             if (colorkey_active) {
                 *convert = CONVERT_CK_5551;
-                *format = GL_BGRA;
-                *internal = GL_RGB5_A1;
-                *type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
+                desc->glFormat = GL_BGRA;
+                desc->glInternal = GL_RGB5_A1;
+                desc->glType = GL_UNSIGNED_SHORT_1_5_5_5_REV;
+                desc->conv_byte_count = 2;
             }
             break;
@@ -1887,8 +2208,8 @@
             if (colorkey_active) {
                 *convert = CONVERT_CK_RGB24;
-                *format = GL_RGBA;
-                *internal = GL_RGBA8;
-                *type = GL_UNSIGNED_INT_8_8_8_8;
-                *target_bpp = 4;
+                desc->glFormat = GL_RGBA;
+                desc->glInternal = GL_RGBA8;
+                desc->glType = GL_UNSIGNED_INT_8_8_8_8;
+                desc->conv_byte_count = 4;
             }
             break;
@@ -1897,119 +2218,8 @@
             if (colorkey_active) {
                 *convert = CONVERT_RGB32_888;
-                *format = GL_RGBA;
-                *internal = GL_RGBA8;
-                *type = GL_UNSIGNED_INT_8_8_8_8;
-            }
-            break;
-
-        case WINED3DFMT_R8G8_SNORM:
-            if (gl_info->supported[NV_TEXTURE_SHADER]) break;
-            *convert = CONVERT_V8U8;
-            *format = GL_BGR;
-            *type = GL_UNSIGNED_BYTE;
-            *target_bpp = 3;
-            break;
-
-        case WINED3DFMT_R5G5_SNORM_L6_UNORM:
-            *convert = CONVERT_L6V5U5;
-            if (gl_info->supported[NV_TEXTURE_SHADER])
-            {
-                *target_bpp = 3;
-                /* Use format and types from table */
-            } else {
-                /* Load it into unsigned R5G6B5, swap L and V channels, and revert that in the shader */
-                *target_bpp = 2;
-                *format = GL_RGB;
-                *type = GL_UNSIGNED_SHORT_5_6_5;
-            }
-            break;
-
-        case WINED3DFMT_R8G8_SNORM_L8X8_UNORM:
-            *convert = CONVERT_X8L8V8U8;
-            *target_bpp = 4;
-            if (gl_info->supported[NV_TEXTURE_SHADER])
-            {
-                /* Use formats from gl table. It is a bit unfortunate, but the conversion
-                 * is needed to set the X format to 255 to get 1.0 for alpha when sampling
-                 * the texture. OpenGL can't use GL_DSDT8_MAG8_NV as internal format with
-                 * the needed type and format parameter, so the internal format contains a
-                 * 4th component, which is returned as alpha
-                 */
-            } else {
-                *format = GL_BGRA;
-                *type = GL_UNSIGNED_INT_8_8_8_8_REV;
-            }
-            break;
-
-        case WINED3DFMT_R8G8B8A8_SNORM:
-            if (gl_info->supported[NV_TEXTURE_SHADER]) break;
-            *convert = CONVERT_Q8W8V8U8;
-            *format = GL_BGRA;
-            *type = GL_UNSIGNED_BYTE;
-            *target_bpp = 4;
-            break;
-
-        case WINED3DFMT_R16G16_SNORM:
-            if (gl_info->supported[NV_TEXTURE_SHADER]) break;
-            *convert = CONVERT_V16U16;
-            *format = GL_BGR;
-            *type = GL_UNSIGNED_SHORT;
-            *target_bpp = 6;
-            break;
-
-        case WINED3DFMT_L4A4_UNORM:
-            /* WINED3DFMT_L4A4_UNORM exists as an internal gl format, but for some reason there is not
-             * format+type combination to load it. Thus convert it to A8L8, then load it
-             * with A4L4 internal, but A8L8 format+type
-             */
-            *convert = CONVERT_A4L4;
-            *format = GL_LUMINANCE_ALPHA;
-            *type = GL_UNSIGNED_BYTE;
-            *target_bpp = 2;
-            break;
-
-        case WINED3DFMT_R16G16_UNORM:
-            *convert = CONVERT_G16R16;
-            *format = GL_RGB;
-            *type = GL_UNSIGNED_SHORT;
-            *target_bpp = 6;
-            break;
-
-        case WINED3DFMT_R16G16_FLOAT:
-            *convert = CONVERT_R16G16F;
-            *format = GL_RGB;
-            *type = GL_HALF_FLOAT_ARB;
-            *target_bpp = 6;
-            break;
-
-        case WINED3DFMT_R32G32_FLOAT:
-            *convert = CONVERT_R32G32F;
-            *format = GL_RGB;
-            *type = GL_FLOAT;
-            *target_bpp = 12;
-            break;
-
-        case WINED3DFMT_S1_UINT_D15_UNORM:
-            if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT]
-                    || gl_info->supported[EXT_PACKED_DEPTH_STENCIL])
-            {
-                *convert = CONVERT_D15S1;
-                *target_bpp = 4;
-            }
-            break;
-
-        case WINED3DFMT_S4X4_UINT_D24_UNORM:
-            if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT]
-                    || gl_info->supported[EXT_PACKED_DEPTH_STENCIL])
-            {
-                *convert = CONVERT_D24X4S4;
-            }
-            break;
-
-        case WINED3DFMT_S8_UINT_D24_FLOAT:
-            if (gl_info->supported[ARB_DEPTH_BUFFER_FLOAT])
-            {
-                *convert = CONVERT_D24FS8;
-                *target_bpp = 8;
+                desc->glFormat = GL_RGBA;
+                desc->glInternal = GL_RGBA8;
+                desc->glType = GL_UNSIGNED_INT_8_8_8_8;
+                desc->conv_byte_count = 4;
             }
             break;
@@ -2022,5 +2232,5 @@
 }
 
-static void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *This, BYTE table[256][4], BOOL colorkey)
+void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *This, BYTE table[256][4], BOOL colorkey)
 {
     IWineD3DDeviceImpl *device = This->resource.device;
@@ -2105,6 +2315,4 @@
         UINT height, UINT outpitch, CONVERT_TYPES convert, IWineD3DSurfaceImpl *This)
 {
-    IWineD3DDeviceImpl *device = This->resource.device;
-    const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
     const BYTE *source;
     BYTE *dest;
@@ -2252,359 +2460,8 @@
         break;
 
-        case CONVERT_V8U8:
-        {
-            unsigned int x, y;
-            const short *Source;
-            unsigned char *Dest;
-            for(y = 0; y < height; y++) {
-                Source = (const short *)(src + y * pitch);
-                Dest = dst + y * outpitch;
-                for (x = 0; x < width; x++ ) {
-                    long color = (*Source++);
-                    /* B */ Dest[0] = 0xff;
-                    /* G */ Dest[1] = (color >> 8) + 128; /* V */
-                    /* R */ Dest[2] = (color) + 128;      /* U */
-                    Dest += 3;
-                }
-            }
-            break;
-        }
-
-        case CONVERT_V16U16:
-        {
-            unsigned int x, y;
-            const DWORD *Source;
-            unsigned short *Dest;
-            for(y = 0; y < height; y++) {
-                Source = (const DWORD *)(src + y * pitch);
-                Dest = (unsigned short *) (dst + y * outpitch);
-                for (x = 0; x < width; x++ ) {
-                    DWORD color = (*Source++);
-                    /* B */ Dest[0] = 0xffff;
-                    /* G */ Dest[1] = (color >> 16) + 32768; /* V */
-                    /* R */ Dest[2] = (color      ) + 32768; /* U */
-                    Dest += 3;
-                }
-            }
-            break;
-        }
-
-        case CONVERT_Q8W8V8U8:
-        {
-            unsigned int x, y;
-            const DWORD *Source;
-            unsigned char *Dest;
-            for(y = 0; y < height; y++) {
-                Source = (const DWORD *)(src + y * pitch);
-                Dest = dst + y * outpitch;
-                for (x = 0; x < width; x++ ) {
-                    long color = (*Source++);
-                    /* B */ Dest[0] = ((color >> 16) & 0xff) + 128; /* W */
-                    /* G */ Dest[1] = ((color >> 8 ) & 0xff) + 128; /* V */
-                    /* R */ Dest[2] = (color         & 0xff) + 128; /* U */
-                    /* A */ Dest[3] = ((color >> 24) & 0xff) + 128; /* Q */
-                    Dest += 4;
-                }
-            }
-            break;
-        }
-
-        case CONVERT_L6V5U5:
-        {
-            unsigned int x, y;
-            const WORD *Source;
-            unsigned char *Dest;
-
-            if (gl_info->supported[NV_TEXTURE_SHADER])
-            {
-                /* This makes the gl surface bigger(24 bit instead of 16), but it works with
-                 * fixed function and shaders without further conversion once the surface is
-                 * loaded
-                 */
-                for(y = 0; y < height; y++) {
-                    Source = (const WORD *)(src + y * pitch);
-                    Dest = dst + y * outpitch;
-                    for (x = 0; x < width; x++ ) {
-                        short color = (*Source++);
-                        unsigned char l = ((color >> 10) & 0xfc);
-                                  char v = ((color >>  5) & 0x3e);
-                                  char u = ((color      ) & 0x1f);
-
-                        /* 8 bits destination, 6 bits source, 8th bit is the sign. gl ignores the sign
-                         * and doubles the positive range. Thus shift left only once, gl does the 2nd
-                         * shift. GL reads a signed value and converts it into an unsigned value.
-                         */
-                        /* M */ Dest[2] = l << 1;
-
-                        /* Those are read as signed, but kept signed. Just left-shift 3 times to scale
-                         * from 5 bit values to 8 bit values.
-                         */
-                        /* V */ Dest[1] = v << 3;
-                        /* U */ Dest[0] = u << 3;
-                        Dest += 3;
-                    }
-                }
-            } else {
-                for(y = 0; y < height; y++) {
-                    unsigned short *Dest_s = (unsigned short *) (dst + y * outpitch);
-                    Source = (const WORD *)(src + y * pitch);
-                    for (x = 0; x < width; x++ ) {
-                        short color = (*Source++);
-                        unsigned char l = ((color >> 10) & 0xfc);
-                                 short v = ((color >>  5) & 0x3e);
-                                 short u = ((color      ) & 0x1f);
-                        short v_conv = v + 16;
-                        short u_conv = u + 16;
-
-                        *Dest_s = ((v_conv << 11) & 0xf800) | ((l << 5) & 0x7e0) | (u_conv & 0x1f);
-                        Dest_s += 1;
-                    }
-                }
-            }
-            break;
-        }
-
-        case CONVERT_X8L8V8U8:
-        {
-            unsigned int x, y;
-            const DWORD *Source;
-            unsigned char *Dest;
-
-            if (gl_info->supported[NV_TEXTURE_SHADER])
-            {
-                /* This implementation works with the fixed function pipeline and shaders
-                 * without further modification after converting the surface.
-                 */
-                for(y = 0; y < height; y++) {
-                    Source = (const DWORD *)(src + y * pitch);
-                    Dest = dst + y * outpitch;
-                    for (x = 0; x < width; x++ ) {
-                        long color = (*Source++);
-                        /* L */ Dest[2] = ((color >> 16) & 0xff);   /* L */
-                        /* V */ Dest[1] = ((color >> 8 ) & 0xff);   /* V */
-                        /* U */ Dest[0] = (color         & 0xff);   /* U */
-                        /* I */ Dest[3] = 255;                      /* X */
-                        Dest += 4;
-                    }
-                }
-            } else {
-                /* Doesn't work correctly with the fixed function pipeline, but can work in
-                 * shaders if the shader is adjusted. (There's no use for this format in gl's
-                 * standard fixed function pipeline anyway).
-                 */
-                for(y = 0; y < height; y++) {
-                    Source = (const DWORD *)(src + y * pitch);
-                    Dest = dst + y * outpitch;
-                    for (x = 0; x < width; x++ ) {
-                        long color = (*Source++);
-                        /* B */ Dest[0] = ((color >> 16) & 0xff);       /* L */
-                        /* G */ Dest[1] = ((color >> 8 ) & 0xff) + 128; /* V */
-                        /* R */ Dest[2] = (color         & 0xff) + 128;  /* U */
-                        Dest += 4;
-                    }
-                }
-            }
-            break;
-        }
-
-        case CONVERT_A4L4:
-        {
-            unsigned int x, y;
-            const unsigned char *Source;
-            unsigned char *Dest;
-            for(y = 0; y < height; y++) {
-                Source = src + y * pitch;
-                Dest = dst + y * outpitch;
-                for (x = 0; x < width; x++ ) {
-                    unsigned char color = (*Source++);
-                    /* A */ Dest[1] = (color & 0xf0) << 0;
-                    /* L */ Dest[0] = (color & 0x0f) << 4;
-                    Dest += 2;
-                }
-            }
-            break;
-        }
-
-        case CONVERT_G16R16:
-        case CONVERT_R16G16F:
-        {
-            unsigned int x, y;
-            const WORD *Source;
-            WORD *Dest;
-
-            for(y = 0; y < height; y++) {
-                Source = (const WORD *)(src + y * pitch);
-                Dest = (WORD *) (dst + y * outpitch);
-                for (x = 0; x < width; x++ ) {
-                    WORD green = (*Source++);
-                    WORD red = (*Source++);
-                    Dest[0] = green;
-                    Dest[1] = red;
-                    /* Strictly speaking not correct for R16G16F, but it doesn't matter because the
-                     * shader overwrites it anyway
-                     */
-                    Dest[2] = 0xffff;
-                    Dest += 3;
-                }
-            }
-            break;
-        }
-
-        case CONVERT_R32G32F:
-        {
-            unsigned int x, y;
-            const float *Source;
-            float *Dest;
-            for(y = 0; y < height; y++) {
-                Source = (const float *)(src + y * pitch);
-                Dest = (float *) (dst + y * outpitch);
-                for (x = 0; x < width; x++ ) {
-                    float green = (*Source++);
-                    float red = (*Source++);
-                    Dest[0] = green;
-                    Dest[1] = red;
-                    Dest[2] = 1.0f;
-                    Dest += 3;
-                }
-            }
-            break;
-        }
-
-        case CONVERT_D15S1:
-        {
-            unsigned int x, y;
-
-            for (y = 0; y < height; ++y)
-            {
-                const WORD *source = (const WORD *)(src + y * pitch);
-                DWORD *dest = (DWORD *)(dst + y * outpitch);
-
-                for (x = 0; x < width; ++x)
-                {
-                    /* The depth data is normalized, so needs to be scaled,
-                     * the stencil data isn't.  Scale depth data by
-                     *      (2^24-1)/(2^15-1) ~~ (2^9 + 2^-6). */
-                    WORD d15 = source[x] >> 1;
-                    DWORD d24 = (d15 << 9) + (d15 >> 6);
-                    dest[x] = (d24 << 8) | (source[x] & 0x1);
-                }
-            }
-            break;
-        }
-
-        case CONVERT_D24X4S4:
-        {
-            unsigned int x, y;
-
-            for (y = 0; y < height; ++y)
-            {
-                const DWORD *source = (const DWORD *)(src + y * pitch);
-                DWORD *dest = (DWORD *)(dst + y * outpitch);
-
-                for (x = 0; x < width; ++x)
-                {
-                    /* Just need to clear out the X4 part. */
-                    dest[x] = source[x] & ~0xf0;
-                }
-            }
-            break;
-        }
-
-        case CONVERT_D24FS8:
-        {
-            unsigned int x, y;
-
-            for (y = 0; y < height; ++y)
-            {
-                const DWORD *source = (const DWORD *)(src + y * pitch);
-                float *dest_f = (float *)(dst + y * outpitch);
-                DWORD *dest_s = (DWORD *)(dst + y * outpitch);
-
-                for (x = 0; x < width; ++x)
-                {
-                    dest_f[x * 2] = float_24_to_32((source[x] & 0xffffff00) >> 8);
-                    dest_s[x * 2 + 1] = source[x] & 0xff;
-                }
-            }
-            break;
-        }
-
         default:
             ERR("Unsupported conversion type %#x.\n", convert);
     }
     return WINED3D_OK;
-}
-
-/* This function is used in case of 8bit paletted textures to upload the palette.
-   It supports GL_EXT_paletted_texture and GL_ARB_fragment_program, support for other
-   extensions like ATI_fragment_shaders is possible.
-*/
-/* Context activation is done by the caller. */
-static void d3dfmt_p8_upload_palette(IWineD3DSurface *iface, CONVERT_TYPES convert) {
-    IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
-    BYTE table[256][4];
-    IWineD3DDeviceImpl *device = This->resource.device;
-    const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
-
-    d3dfmt_p8_init_palette(This, table, (convert == CONVERT_PALETTED_CK));
-
-    /* Try to use the paletted texture extension */
-    if (gl_info->supported[EXT_PALETTED_TEXTURE])
-    {
-        TRACE("Using GL_EXT_PALETTED_TEXTURE for 8-bit paletted texture support\n");
-        ENTER_GL();
-        GL_EXTCALL(glColorTableEXT(This->texture_target, GL_RGBA, 256, GL_RGBA, GL_UNSIGNED_BYTE, table));
-        LEAVE_GL();
-    }
-    else
-    {
-        /* Let a fragment shader do the color conversion by uploading the palette to a 1D texture.
-         * The 8bit pixel data will be used as an index in this palette texture to retrieve the final color. */
-        TRACE("Using fragment shaders for emulating 8-bit paletted texture support\n");
-
-        ENTER_GL();
-
-        /* Create the fragment program if we don't have it */
-        if(!device->paletteConversionShader)
-        {
-            const char *fragment_palette_conversion =
-                "!!ARBfp1.0\n"
-                "TEMP index;\n"
-                /* { 255/256, 0.5/255*255/256, 0, 0 } */
-                "PARAM constants = { 0.996, 0.00195, 0, 0 };\n"
-                /* The alpha-component contains the palette index */
-                "TEX index, fragment.texcoord[0], texture[0], 2D;\n"
-                /* Scale the index by 255/256 and add a bias of '0.5' in order to sample in the middle */
-                "MAD index.a, index.a, constants.x, constants.y;\n"
-                /* Use the alpha-component as an index in the palette to get the final color */
-                "TEX result.color, index.a, texture[1], 1D;\n"
-                "END";
-
-            glEnable(GL_FRAGMENT_PROGRAM_ARB);
-            GL_EXTCALL(glGenProgramsARB(1, &device->paletteConversionShader));
-            GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, device->paletteConversionShader));
-            GL_EXTCALL(glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, strlen(fragment_palette_conversion), fragment_palette_conversion));
-            glDisable(GL_FRAGMENT_PROGRAM_ARB);
-        }
-
-        glEnable(GL_FRAGMENT_PROGRAM_ARB);
-        GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, device->paletteConversionShader));
-
-        GL_EXTCALL(glActiveTextureARB(GL_TEXTURE1));
-        glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-
-        glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-        glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); /* Make sure we have discrete color levels. */
-        glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-        glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, table); /* Upload the palette */
-
-        /* Switch back to unit 0 in which the 2D texture will be stored. */
-        GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0));
-
-        /* Rebind the texture because it isn't bound anymore */
-        glBindTexture(This->texture_target, This->texture_name);
-
-        LEAVE_GL();
-    }
 }
 
@@ -2710,5 +2567,4 @@
     /* TODO: check for locks */
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
-    IWineD3DDeviceImpl *device = This->resource.device;
     IWineD3DBaseTexture *baseTexture = NULL;
 
@@ -2721,5 +2577,4 @@
     else
     {
-        struct wined3d_context *context = NULL;
         GLuint *name;
 
@@ -2727,5 +2582,4 @@
 
         name = srgb ? &This->texture_name_srgb : &This->texture_name;
-        if (!device->isInDraw) context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
 
         ENTER_GL();
@@ -2761,6 +2615,4 @@
 
         LEAVE_GL();
-
-        if (context) context_release(context);
     }
 }
@@ -3108,5 +2960,6 @@
 
     /* Flipping a OpenGL surface -> Use WineD3DDevice::Present */
-    hr = IWineD3DSwapChain_Present((IWineD3DSwapChain *) swapchain, NULL, NULL, 0, NULL, 0);
+    hr = IWineD3DSwapChain_Present((IWineD3DSwapChain *)swapchain,
+            NULL, NULL, swapchain->win_handle, NULL, 0);
     IWineD3DSwapChain_Release((IWineD3DSwapChain *) swapchain);
     return hr;
@@ -3117,5 +2970,5 @@
  */
 static inline void fb_copy_to_texture_direct(IWineD3DSurfaceImpl *This, IWineD3DSurface *SrcSurface,
-        const WINED3DRECT *srect, const WINED3DRECT *drect, BOOL upsidedown, WINED3DTEXTUREFILTERTYPE Filter)
+        const RECT *src_rect, const RECT *dst_rect_in, WINED3DTEXTUREFILTERTYPE Filter)
 {
     IWineD3DDeviceImpl *myDevice = This->resource.device;
@@ -3124,5 +2977,16 @@
     IWineD3DSurfaceImpl *Src = (IWineD3DSurfaceImpl *) SrcSurface;
     struct wined3d_context *context;
-
+    BOOL upsidedown = FALSE;
+    RECT dst_rect = *dst_rect_in;
+
+    /* Make sure that the top pixel is always above the bottom pixel, and keep a separate upside down flag
+     * glCopyTexSubImage is a bit picky about the parameters we pass to it
+     */
+    if(dst_rect.top > dst_rect.bottom) {
+        UINT tmp = dst_rect.bottom;
+        dst_rect.bottom = dst_rect.top;
+        dst_rect.top = tmp;
+        upsidedown = TRUE;
+    }
 
     context = context_acquire(myDevice, SrcSurface, CTXUSAGE_BLIT);
@@ -3144,6 +3008,6 @@
     checkGLcall("glReadBuffer");
 
-    xrel = (float) (srect->x2 - srect->x1) / (float) (drect->x2 - drect->x1);
-    yrel = (float) (srect->y2 - srect->y1) / (float) (drect->y2 - drect->y1);
+    xrel = (float) (src_rect->right - src_rect->left) / (float) (dst_rect.right - dst_rect.left);
+    yrel = (float) (src_rect->bottom - src_rect->top) / (float) (dst_rect.bottom - dst_rect.top);
 
     if ((xrel - 1.0f < -eps) || (xrel - 1.0f > eps))
@@ -3168,9 +3032,9 @@
 
         glCopyTexSubImage2D(This->texture_target, This->texture_level,
-                drect->x1 /*xoffset */, drect->y1 /* y offset */,
-                srect->x1, Src->currentDesc.Height - srect->y2,
-                drect->x2 - drect->x1, drect->y2 - drect->y1);
+                dst_rect.left /*xoffset */, dst_rect.top /* y offset */,
+                src_rect->left, Src->currentDesc.Height - src_rect->bottom,
+                dst_rect.right - dst_rect.left, dst_rect.bottom - dst_rect.top);
     } else {
-        UINT yoffset = Src->currentDesc.Height - srect->y1 + drect->y1 - 1;
+        UINT yoffset = Src->currentDesc.Height - src_rect->top + dst_rect.top - 1;
         /* I have to process this row by row to swap the image,
          * otherwise it would be upside down, so stretching in y direction
@@ -3179,5 +3043,5 @@
          * However, stretching in x direction can be avoided if not necessary
          */
-        for(row = drect->y1; row < drect->y2; row++) {
+        for(row = dst_rect.top; row < dst_rect.bottom; row++) {
             if ((xrel - 1.0f < -eps) || (xrel - 1.0f > eps))
             {
@@ -3187,13 +3051,13 @@
                 UINT col;
 
-                for(col = drect->x1; col < drect->x2; col++) {
+                for(col = dst_rect.left; col < dst_rect.right; col++) {
                     glCopyTexSubImage2D(This->texture_target, This->texture_level,
-                            drect->x1 + col /* x offset */, row /* y offset */,
-                            srect->x1 + col * xrel, yoffset - (int) (row * yrel), 1, 1);
+                            dst_rect.left + col /* x offset */, row /* y offset */,
+                            src_rect->left + col * xrel, yoffset - (int) (row * yrel), 1, 1);
                 }
             } else {
                 glCopyTexSubImage2D(This->texture_target, This->texture_level,
-                        drect->x1 /* x offset */, row /* y offset */,
-                        srect->x1, yoffset - (int) (row * yrel), drect->x2-drect->x1, 1);
+                        dst_rect.left /* x offset */, row /* y offset */,
+                        src_rect->left, yoffset - (int) (row * yrel), dst_rect.right - dst_rect.left, 1);
             }
         }
@@ -3212,10 +3076,10 @@
 /* Uses the hardware to stretch and flip the image */
 static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWineD3DSurface *SrcSurface,
-        IWineD3DSwapChainImpl *swapchain, const WINED3DRECT *srect, const WINED3DRECT *drect,
-        BOOL upsidedown, WINED3DTEXTUREFILTERTYPE Filter)
+        const RECT *src_rect, const RECT *dst_rect_in, WINED3DTEXTUREFILTERTYPE Filter)
 {
     IWineD3DDeviceImpl *myDevice = This->resource.device;
     GLuint src, backup = 0;
     IWineD3DSurfaceImpl *Src = (IWineD3DSurfaceImpl *) SrcSurface;
+    IWineD3DSwapChainImpl *src_swapchain = NULL;
     float left, right, top, bottom; /* Texture coordinates */
     UINT fbwidth = Src->currentDesc.Width;
@@ -3226,4 +3090,6 @@
     BOOL noBackBufferBackup;
     BOOL src_offscreen;
+    BOOL upsidedown = FALSE;
+    RECT dst_rect = *dst_rect_in;
 
     TRACE("Using hwstretch blit\n");
@@ -3275,4 +3141,14 @@
     }
 
+    /* Make sure that the top pixel is always above the bottom pixel, and keep a separate upside down flag
+     * glCopyTexSubImage is a bit picky about the parameters we pass to it
+     */
+    if(dst_rect.top > dst_rect.bottom) {
+        UINT tmp = dst_rect.bottom;
+        dst_rect.bottom = dst_rect.top;
+        dst_rect.top = tmp;
+        upsidedown = TRUE;
+    }
+
     if (src_offscreen)
     {
@@ -3303,5 +3179,7 @@
     checkGLcall("glTexParameteri");
 
-    if(!swapchain || (IWineD3DSurface *) Src == swapchain->backBuffer[0]) {
+    IWineD3DSurface_GetContainer((IWineD3DSurface *)SrcSurface, &IID_IWineD3DSwapChain, (void **)&src_swapchain);
+    if (src_swapchain) IWineD3DSwapChain_Release((IWineD3DSwapChain *)src_swapchain);
+    if (!src_swapchain || (IWineD3DSurface *) Src == src_swapchain->backBuffer[0]) {
         src = backup ? backup : Src->texture_name;
     } else {
@@ -3314,5 +3192,5 @@
         checkGLcall("glBindTexture(GL_TEXTURE_2D, src)");
 
-        /* TODO: Only copy the part that will be read. Use srect->x1, srect->y2 as origin, but with the width watch
+        /* TODO: Only copy the part that will be read. Use src_rect->left, src_rect->bottom as origin, but with the width watch
          * out for power of 2 sizes
          */
@@ -3342,13 +3220,13 @@
     checkGLcall("glEnd and previous");
 
-    left = srect->x1;
-    right = srect->x2;
+    left = src_rect->left;
+    right = src_rect->right;
 
     if(upsidedown) {
-        top = Src->currentDesc.Height - srect->y1;
-        bottom = Src->currentDesc.Height - srect->y2;
+        top = Src->currentDesc.Height - src_rect->top;
+        bottom = Src->currentDesc.Height - src_rect->bottom;
     } else {
-        top = Src->currentDesc.Height - srect->y2;
-        bottom = Src->currentDesc.Height - srect->y1;
+        top = Src->currentDesc.Height - src_rect->bottom;
+        bottom = Src->currentDesc.Height - src_rect->top;
     }
 
@@ -3374,13 +3252,13 @@
         /* top left */
         glTexCoord2f(left, top);
-        glVertex2i(0, fbheight - drect->y2 - drect->y1);
+        glVertex2i(0, fbheight - dst_rect.bottom - dst_rect.top);
 
         /* top right */
         glTexCoord2f(right, top);
-        glVertex2i(drect->x2 - drect->x1, fbheight - drect->y2 - drect->y1);
+        glVertex2i(dst_rect.right - dst_rect.left, fbheight - dst_rect.bottom - dst_rect.top);
 
         /* bottom right */
         glTexCoord2f(right, bottom);
-        glVertex2i(drect->x2 - drect->x1, fbheight);
+        glVertex2i(dst_rect.right - dst_rect.left, fbheight);
     glEnd();
     checkGLcall("glEnd and previous");
@@ -3398,7 +3276,7 @@
     glCopyTexSubImage2D(texture_target,
                         0,
-                        drect->x1, drect->y1, /* xoffset, yoffset */
+                        dst_rect.left, dst_rect.top, /* xoffset, yoffset */
                         0, 0, /* We blitted the image to the origin */
-                        drect->x2 - drect->x1, drect->y2 - drect->y1);
+                        dst_rect.right - dst_rect.left, dst_rect.bottom - dst_rect.top);
     checkGLcall("glCopyTexSubImage2D");
 
@@ -3457,4 +3335,7 @@
 
     LEAVE_GL();
+
+    if (wined3d_settings.strict_draw_ordering) wglFlush(); /* Flush to ensure ordering across contexts. */
+
     context_release(context);
 
@@ -3465,4 +3346,11 @@
 }
 
+/* Until the blit_shader is ready, define some prototypes here. */
+static BOOL fbo_blit_supported(const struct wined3d_gl_info *gl_info, enum blit_operation blit_op,
+                               const RECT *src_rect, DWORD src_usage, WINED3DPOOL src_pool,
+                               const struct wined3d_format_desc *src_format_desc,
+                               const RECT *dst_rect, DWORD dst_usage, WINED3DPOOL dst_pool,
+                               const struct wined3d_format_desc *dst_format_desc);
+
 /* Not called from the VTable */
 static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const RECT *DestRect,
@@ -3471,7 +3359,7 @@
 {
     IWineD3DDeviceImpl *myDevice = This->resource.device;
-    WINED3DRECT rect;
     IWineD3DSwapChainImpl *srcSwapchain = NULL, *dstSwapchain = NULL;
     IWineD3DSurfaceImpl *Src = (IWineD3DSurfaceImpl *) SrcSurface;
+    RECT dst_rect, src_rect;
 
     TRACE("(%p)->(%p,%p,%p,%08x,%p)\n", This, DestRect, SrcSurface, SrcRect, Flags, DDBltFx);
@@ -3507,15 +3395,6 @@
     }
 
-    if (DestRect) {
-        rect.x1 = DestRect->left;
-        rect.y1 = DestRect->top;
-        rect.x2 = DestRect->right;
-        rect.y2 = DestRect->bottom;
-    } else {
-        rect.x1 = 0;
-        rect.y1 = 0;
-        rect.x2 = This->currentDesc.Width;
-        rect.y2 = This->currentDesc.Height;
-    }
+    surface_get_rect(This, DestRect, &dst_rect);
+    if(Src) surface_get_rect(Src, SrcRect, &src_rect);
 
     /* The only case where both surfaces on a swapchain are supported is a back buffer -> front buffer blit on the same swapchain */
@@ -3531,22 +3410,15 @@
         while(1)
         {
-            RECT mySrcRect;
             TRACE("Looking if a Present can be done...\n");
             /* Source Rectangle must be full surface */
-            if( SrcRect ) {
-                if(SrcRect->left != 0 || SrcRect->top != 0 ||
-                   SrcRect->right != Src->currentDesc.Width || SrcRect->bottom != Src->currentDesc.Height) {
-                    TRACE("No, Source rectangle doesn't match\n");
-                    break;
-                }
-            }
-            mySrcRect.left = 0;
-            mySrcRect.top = 0;
-            mySrcRect.right = Src->currentDesc.Width;
-            mySrcRect.bottom = Src->currentDesc.Height;
+            if(src_rect.left != 0 || src_rect.top != 0 ||
+                src_rect.right != Src->currentDesc.Width || src_rect.bottom != Src->currentDesc.Height) {
+                TRACE("No, Source rectangle doesn't match\n");
+                break;
+            }
 
             /* No stretching may occur */
-            if(mySrcRect.right != rect.x2 - rect.x1 ||
-               mySrcRect.bottom != rect.y2 - rect.y1) {
+            if(src_rect.right != dst_rect.right - dst_rect.left ||
+               src_rect.bottom != dst_rect.bottom - dst_rect.top) {
                 TRACE("No, stretching is done\n");
                 break;
@@ -3559,8 +3431,8 @@
                 POINT pos[2];
                 GetClientRect(((IWineD3DClipperImpl *) This->clipper)->hWnd, &cliprect);
-                pos[0].x = rect.x1;
-                pos[0].y = rect.y1;
-                pos[1].x = rect.x2;
-                pos[1].y = rect.y2;
+                pos[0].x = dst_rect.left;
+                pos[0].y = dst_rect.top;
+                pos[1].x = dst_rect.right;
+                pos[1].y = dst_rect.bottom;
                 MapWindowPoints(GetDesktopWindow(), ((IWineD3DClipperImpl *) This->clipper)->hWnd,
                                 pos, 2);
@@ -3570,6 +3442,6 @@
                 {
                     TRACE("No, dest rectangle doesn't match(clipper)\n");
-                    TRACE("Clip rect at (%d,%d)-(%d,%d)\n", cliprect.left, cliprect.top, cliprect.right, cliprect.bottom);
-                    TRACE("Blt dest: (%d,%d)-(%d,%d)\n", rect.x1, rect.y1, rect.x2, rect.y2);
+                    TRACE("Clip rect at %s\n", wine_dbgstr_rect(&cliprect));
+                    TRACE("Blt dest: %s\n", wine_dbgstr_rect(&dst_rect));
                     break;
                 }
@@ -3577,6 +3449,6 @@
             else
             {
-                if(rect.x1 != 0 || rect.y1 != 0 ||
-                   rect.x2 != This->currentDesc.Width || rect.y2 != This->currentDesc.Height) {
+                if(dst_rect.left != 0 || dst_rect.top != 0 ||
+                   dst_rect.right != This->currentDesc.Width || dst_rect.bottom != This->currentDesc.Height) {
                     TRACE("No, dest rectangle doesn't match(surface size)\n");
                     break;
@@ -3609,5 +3481,6 @@
 
                 TRACE("Full screen back buffer -> front buffer blt, performing a flip instead\n");
-                IWineD3DSwapChain_Present((IWineD3DSwapChain *) dstSwapchain, NULL, NULL, 0, NULL, 0);
+                IWineD3DSwapChain_Present((IWineD3DSwapChain *)dstSwapchain,
+                        NULL, NULL, dstSwapchain->win_handle, NULL, 0);
 
                 dstSwapchain->presentParms.SwapEffect = orig_swap;
@@ -3638,7 +3511,13 @@
     if((srcSwapchain || SrcSurface == myDevice->render_targets[0]) && !dstSwapchain) {
         /* Blit from render target to texture */
-        WINED3DRECT srect;
-        BOOL upsideDown, stretchx;
-        BOOL paletteOverride = FALSE;
+        BOOL stretchx;
+
+        /* P8 read back is not implemented */
+        if (Src->resource.format_desc->format == WINED3DFMT_P8_UINT ||
+            This->resource.format_desc->format == WINED3DFMT_P8_UINT)
+        {
+            TRACE("P8 read back not supported by frame buffer to texture blit\n");
+            return WINED3DERR_INVALIDCALL;
+        }
 
         if(Flags & (WINEDDBLT_KEYSRC | WINEDDBLT_KEYSRCOVERRIDE)) {
@@ -3648,46 +3527,8 @@
         }
 
-        /* Make sure that the top pixel is always above the bottom pixel, and keep a separate upside down flag
-         * glCopyTexSubImage is a bit picky about the parameters we pass to it
-         */
-        if(SrcRect) {
-            if(SrcRect->top < SrcRect->bottom) {
-                srect.y1 = SrcRect->top;
-                srect.y2 = SrcRect->bottom;
-                upsideDown = FALSE;
-            } else {
-                srect.y1 = SrcRect->bottom;
-                srect.y2 = SrcRect->top;
-                upsideDown = TRUE;
-            }
-            srect.x1 = SrcRect->left;
-            srect.x2 = SrcRect->right;
-        } else {
-            srect.x1 = 0;
-            srect.y1 = 0;
-            srect.x2 = Src->currentDesc.Width;
-            srect.y2 = Src->currentDesc.Height;
-            upsideDown = FALSE;
-        }
-        if(rect.x1 > rect.x2) {
-            UINT tmp = rect.x2;
-            rect.x2 = rect.x1;
-            rect.x1 = tmp;
-            upsideDown = !upsideDown;
-        }
-
-        if(rect.x2 - rect.x1 != srect.x2 - srect.x1) {
+        if(dst_rect.right - dst_rect.left != src_rect.right - src_rect.left) {
             stretchx = TRUE;
         } else {
             stretchx = FALSE;
-        }
-
-        /* When blitting from a render target a texture, the texture isn't required to have a palette.
-         * In this case grab the palette from the render target. */
-        if (This->resource.format_desc->format == WINED3DFMT_P8_UINT && !This->palette)
-        {
-            paletteOverride = TRUE;
-            TRACE("Source surface (%p) lacks palette, overriding palette with palette %p of destination surface (%p)\n", Src, This->palette, This);
-            This->palette = Src->palette;
         }
 
@@ -3707,22 +3548,18 @@
          * backends.
          */
-        if (wined3d_settings.offscreen_rendering_mode == ORM_FBO
-                && myDevice->adapter->gl_info.fbo_ops.glBlitFramebuffer
-                && surface_can_stretch_rect(Src, This))
+        if (fbo_blit_supported(&myDevice->adapter->gl_info, BLIT_OP_BLIT,
+                               &src_rect, Src->resource.usage, Src->resource.pool, Src->resource.format_desc,
+                               &dst_rect, This->resource.usage, This->resource.pool, This->resource.format_desc))
         {
-            stretch_rect_fbo((IWineD3DDevice *)myDevice, SrcSurface, &srect,
-                    (IWineD3DSurface *)This, &rect, Filter, upsideDown);
-        } else if((!stretchx) || rect.x2 - rect.x1 > Src->currentDesc.Width ||
-                                    rect.y2 - rect.y1 > Src->currentDesc.Height) {
+            stretch_rect_fbo((IWineD3DDevice *)myDevice, SrcSurface, &src_rect,
+                    (IWineD3DSurface *)This, &dst_rect, Filter);
+        } else if((!stretchx) || dst_rect.right - dst_rect.left > Src->currentDesc.Width ||
+                                    dst_rect.bottom - dst_rect.top > Src->currentDesc.Height) {
             TRACE("No stretching in x direction, using direct framebuffer -> texture copy\n");
-            fb_copy_to_texture_direct(This, SrcSurface, &srect, &rect, upsideDown, Filter);
+            fb_copy_to_texture_direct(This, SrcSurface, &src_rect, &dst_rect, Filter);
         } else {
             TRACE("Using hardware stretching to flip / stretch the texture\n");
-            fb_copy_to_texture_hwstretch(This, SrcSurface, srcSwapchain, &srect, &rect, upsideDown, Filter);
-        }
-
-        /* Clear the palette as the surface didn't have a palette attached, it would confuse GetPalette and other calls */
-        if(paletteOverride)
-            This->palette = NULL;
+            fb_copy_to_texture_hwstretch(This, SrcSurface, &src_rect, &dst_rect, Filter);
+        }
 
         if(!(This->Flags & SFLAG_DONOTFREE)) {
@@ -3737,40 +3574,14 @@
     } else if(Src) {
         /* Blit from offscreen surface to render target */
-        float glTexCoord[4];
         DWORD oldCKeyFlags = Src->CKeyFlags;
         WINEDDCOLORKEY oldBltCKey = Src->SrcBltCKey;
         struct wined3d_context *context;
-        RECT SourceRectangle;
-        BOOL paletteOverride = FALSE;
 
         TRACE("Blt from surface %p to rendertarget %p\n", Src, This);
 
-        if(SrcRect) {
-            SourceRectangle.left = SrcRect->left;
-            SourceRectangle.right = SrcRect->right;
-            SourceRectangle.top = SrcRect->top;
-            SourceRectangle.bottom = SrcRect->bottom;
-        } else {
-            SourceRectangle.left = 0;
-            SourceRectangle.right = Src->currentDesc.Width;
-            SourceRectangle.top = 0;
-            SourceRectangle.bottom = Src->currentDesc.Height;
-        }
-
-        /* When blitting from an offscreen surface to a rendertarget, the source
-         * surface is not required to have a palette. Our rendering / conversion
-         * code further down the road retrieves the palette from the surface, so
-         * it must have a palette set. */
-        if (Src->resource.format_desc->format == WINED3DFMT_P8_UINT && !Src->palette)
-        {
-            paletteOverride = TRUE;
-            TRACE("Source surface (%p) lacks palette, overriding palette with palette %p of destination surface (%p)\n", Src, This->palette, This);
-            Src->palette = This->palette;
-        }
-
-        if (wined3d_settings.offscreen_rendering_mode == ORM_FBO
-                && myDevice->adapter->gl_info.fbo_ops.glBlitFramebuffer
-                && !(Flags & (WINEDDBLT_KEYSRC | WINEDDBLT_KEYSRCOVERRIDE))
-                && surface_can_stretch_rect(Src, This))
+        if (!(Flags & (WINEDDBLT_KEYSRC | WINEDDBLT_KEYSRCOVERRIDE))
+            && fbo_blit_supported(&myDevice->adapter->gl_info, BLIT_OP_BLIT,
+                                  &src_rect, Src->resource.usage, Src->resource.pool, Src->resource.format_desc,
+                                  &dst_rect, This->resource.usage, This->resource.pool, This->resource.format_desc))
         {
             TRACE("Using stretch_rect_fbo\n");
@@ -3778,19 +3589,15 @@
              * contents are never upside down
              */
-            stretch_rect_fbo((IWineD3DDevice *)myDevice, SrcSurface, (WINED3DRECT *) &SourceRectangle,
-                              (IWineD3DSurface *)This, &rect, Filter, FALSE);
-
-            /* Clear the palette as the surface didn't have a palette attached, it would confuse GetPalette and other calls */
-            if(paletteOverride)
-                Src->palette = NULL;
+            stretch_rect_fbo((IWineD3DDevice *)myDevice, SrcSurface, &src_rect,
+                              (IWineD3DSurface *)This, &dst_rect, Filter);
             return WINED3D_OK;
         }
 
-        if(!CalculateTexRect(Src, &SourceRectangle, glTexCoord)) {
-            /* Fall back to software */
-            WARN("(%p) Source texture area (%d,%d)-(%d,%d) is too big\n", Src,
-                    SourceRectangle.left, SourceRectangle.top,
-                    SourceRectangle.right, SourceRectangle.bottom);
-            return WINED3DERR_INVALIDCALL;
+        if (!(Flags & (WINEDDBLT_KEYSRC | WINEDDBLT_KEYSRCOVERRIDE))
+            && arbfp_blit.blit_supported(&myDevice->adapter->gl_info, BLIT_OP_BLIT,
+                                         &src_rect, Src->resource.usage, Src->resource.pool, Src->resource.format_desc,
+                                         &dst_rect, This->resource.usage, This->resource.pool, This->resource.format_desc))
+        {
+            return arbfp_blit_surface(myDevice, Src, &src_rect, This, &dst_rect, BLIT_OP_BLIT, Filter);
         }
 
@@ -3829,46 +3636,23 @@
             POINT offset = {0,0};
             UINT h;
-            ClientToScreen(dstSwapchain->win_handle, &offset);
-            GetClientRect(dstSwapchain->win_handle, &windowsize);
+            ClientToScreen(context->win_handle, &offset);
+            GetClientRect(context->win_handle, &windowsize);
             h = windowsize.bottom - windowsize.top;
-            rect.x1 -= offset.x; rect.x2 -=offset.x;
-            rect.y1 -= offset.y; rect.y2 -=offset.y;
-            rect.y1 += This->currentDesc.Height - h; rect.y2 += This->currentDesc.Height - h;
-        }
-
-        if (!is_identity_fixup(This->resource.format_desc->color_fixup))
+            dst_rect.left -= offset.x; dst_rect.right -=offset.x;
+            dst_rect.top -= offset.y; dst_rect.bottom -=offset.y;
+            dst_rect.top += This->currentDesc.Height - h; dst_rect.bottom += This->currentDesc.Height - h;
+        }
+
+        if (!myDevice->blitter->blit_supported(&myDevice->adapter->gl_info, BLIT_OP_BLIT,
+                                               &src_rect, Src->resource.usage, Src->resource.pool, Src->resource.format_desc,
+                                               &dst_rect, This->resource.usage, This->resource.pool, This->resource.format_desc))
         {
-            FIXME("Destination format %s has a fixup, this is not supported.\n",
-                    debug_d3dformat(This->resource.format_desc->format));
-            dump_color_fixup_desc(This->resource.format_desc->color_fixup);
-        }
-
-        if (!myDevice->blitter->color_fixup_supported(Src->resource.format_desc->color_fixup))
-        {
-            FIXME("Source format %s has an unsupported fixup:\n",
-                    debug_d3dformat(Src->resource.format_desc->format));
-            dump_color_fixup_desc(Src->resource.format_desc->color_fixup);
-        }
-
-        myDevice->blitter->set_shader((IWineD3DDevice *) myDevice, Src->resource.format_desc,
-                Src->texture_target, Src->pow2Width, Src->pow2Height);
+            FIXME("Unsupported blit operation falling back to software\n");
+            return WINED3DERR_INVALIDCALL;
+        }
+
+        myDevice->blitter->set_shader((IWineD3DDevice *) myDevice, Src);
 
         ENTER_GL();
-
-        /* Bind the texture */
-        glBindTexture(Src->texture_target, Src->texture_name);
-        checkGLcall("glBindTexture");
-
-        /* Filtering for StretchRect */
-        glTexParameteri(Src->texture_target, GL_TEXTURE_MAG_FILTER,
-                wined3d_gl_mag_filter(magLookup, Filter));
-        checkGLcall("glTexParameteri");
-        glTexParameteri(Src->texture_target, GL_TEXTURE_MIN_FILTER,
-                wined3d_gl_min_mip_filter(minMipLookup, Filter, WINED3DTEXF_NONE));
-        checkGLcall("glTexParameteri");
-        glTexParameteri(Src->texture_target, GL_TEXTURE_WRAP_S, GL_CLAMP);
-        glTexParameteri(Src->texture_target, GL_TEXTURE_WRAP_T, GL_CLAMP);
-        glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-        checkGLcall("glTexEnvi");
 
         /* This is for color keying */
@@ -3892,21 +3676,5 @@
         /* Draw a textured quad
          */
-        glBegin(GL_QUADS);
-
-        glColor3f(1.0f, 1.0f, 1.0f);
-        glTexCoord2f(glTexCoord[0], glTexCoord[2]);
-        glVertex3f(rect.x1, rect.y1, 0.0f);
-
-        glTexCoord2f(glTexCoord[0], glTexCoord[3]);
-        glVertex3f(rect.x1, rect.y2, 0.0f);
-
-        glTexCoord2f(glTexCoord[1], glTexCoord[3]);
-        glVertex3f(rect.x2, rect.y2, 0.0f);
-
-        glTexCoord2f(glTexCoord[1], glTexCoord[2]);
-        glVertex3f(rect.x2, rect.y1, 0.0f);
-
-        glEnd();
-        checkGLcall("glEnd");
+        draw_textured_quad(Src, &src_rect, &dst_rect, Filter);
 
         if(Flags & (WINEDDBLT_KEYSRC | WINEDDBLT_KEYSRCOVERRIDE)) {
@@ -3915,15 +3683,8 @@
         }
 
-        glBindTexture(Src->texture_target, 0);
-        checkGLcall("glBindTexture(Src->texture_target, 0)");
-
         /* Restore the color key parameters */
         Src->CKeyFlags = oldCKeyFlags;
         Src->SrcBltCKey = oldBltCKey;
 
-        /* Clear the palette as the surface didn't have a palette attached, it would confuse GetPalette and other calls */
-        if(paletteOverride)
-            Src->palette = NULL;
-
         LEAVE_GL();
 
@@ -3931,7 +3692,8 @@
         myDevice->blitter->unset_shader((IWineD3DDevice *) myDevice);
 
-        /* Flush in case the drawable is used by multiple GL contexts */
-        if(dstSwapchain && (This == (IWineD3DSurfaceImpl *) dstSwapchain->frontBuffer || dstSwapchain->num_contexts >= 2))
-            wglFlush();
+        if (wined3d_settings.strict_draw_ordering || (dstSwapchain
+                && ((IWineD3DSurface *)This == dstSwapchain->frontBuffer
+                || dstSwapchain->num_contexts > 1)))
+            wglFlush(); /* Flush to ensure ordering across contexts. */
 
         context_release(context);
@@ -3947,66 +3709,30 @@
         /* Source-Less Blit to render target */
         if (Flags & WINEDDBLT_COLORFILL) {
-            /* This is easy to handle for the D3D Device... */
             DWORD color;
 
             TRACE("Colorfill\n");
-
-            /* This == (IWineD3DSurfaceImpl *) myDevice->render_targets[0] || dstSwapchain
-                must be true if we are here */
-            if (This != (IWineD3DSurfaceImpl *) myDevice->render_targets[0] &&
-                    !(This == (IWineD3DSurfaceImpl*) dstSwapchain->frontBuffer ||
-                      (dstSwapchain->backBuffer && This == (IWineD3DSurfaceImpl*) dstSwapchain->backBuffer[0]))) {
-                TRACE("Surface is higher back buffer, falling back to software\n");
-                return WINED3DERR_INVALIDCALL;
-            }
 
             /* The color as given in the Blt function is in the format of the frame-buffer...
              * 'clear' expect it in ARGB format => we need to do some conversion :-)
              */
-            if (This->resource.format_desc->format == WINED3DFMT_P8_UINT)
+            if (!surface_convert_color_to_argb(This, DDBltFx->u5.dwFillColor, &color))
             {
-                DWORD alpha;
-
-                if (primary_render_target_is_p8(myDevice)) alpha = DDBltFx->u5.dwFillColor << 24;
-                else alpha = 0xFF000000;
-
-                if (This->palette) {
-                    color = (alpha |
-                            (This->palette->palents[DDBltFx->u5.dwFillColor].peRed << 16) |
-                            (This->palette->palents[DDBltFx->u5.dwFillColor].peGreen << 8) |
-                            (This->palette->palents[DDBltFx->u5.dwFillColor].peBlue));
-                } else {
-                    color = alpha;
-                }
-            }
-            else if (This->resource.format_desc->format == WINED3DFMT_B5G6R5_UNORM)
+                /* The color conversion function already prints an error, so need to do it here */
+                return WINED3DERR_INVALIDCALL;
+            }
+
+            if (ffp_blit.blit_supported(&myDevice->adapter->gl_info, BLIT_OP_COLOR_FILL,
+                                        NULL, 0, 0, NULL,
+                                        &dst_rect, This->resource.usage, This->resource.pool, This->resource.format_desc))
             {
-                if (DDBltFx->u5.dwFillColor == 0xFFFF) {
-                    color = 0xFFFFFFFF;
-                } else {
-                    color = ((0xFF000000) |
-                            ((DDBltFx->u5.dwFillColor & 0xF800) << 8) |
-                            ((DDBltFx->u5.dwFillColor & 0x07E0) << 5) |
-                            ((DDBltFx->u5.dwFillColor & 0x001F) << 3));
-                }
-            }
-            else if (This->resource.format_desc->format == WINED3DFMT_B8G8R8_UNORM
-                    || This->resource.format_desc->format == WINED3DFMT_B8G8R8X8_UNORM)
+                return ffp_blit.color_fill(myDevice, This, &dst_rect, color);
+            }
+            else if (cpu_blit.blit_supported(&myDevice->adapter->gl_info, BLIT_OP_COLOR_FILL,
+                                             NULL, 0, 0, NULL,
+                                             &dst_rect, This->resource.usage, This->resource.pool, This->resource.format_desc))
             {
-                color = 0xFF000000 | DDBltFx->u5.dwFillColor;
-            }
-            else if (This->resource.format_desc->format == WINED3DFMT_B8G8R8A8_UNORM)
-            {
-                color = DDBltFx->u5.dwFillColor;
-            }
-            else {
-                ERR("Wrong surface type for BLT override(Format doesn't match) !\n");
-                return WINED3DERR_INVALIDCALL;
-            }
-
-            TRACE("(%p) executing Render Target override, color = %x\n", This, color);
-            IWineD3DDeviceImpl_ClearSurface(myDevice, This, 1 /* Number of rectangles */,
-                    &rect, WINED3DCLEAR_TARGET, color, 0.0f /* Z */, 0 /* Stencil */);
-            return WINED3D_OK;
+                return cpu_blit.color_fill(myDevice, This, &dst_rect, color);
+            }
+            return WINED3DERR_INVALIDCALL;
         }
     }
@@ -4127,15 +3853,5 @@
         DWORD Flags=0;
 
-        if(rsrc) {
-            SrcRect.left = rsrc->left;
-            SrcRect.top= rsrc->top;
-            SrcRect.bottom = rsrc->bottom;
-            SrcRect.right = rsrc->right;
-        } else {
-            SrcRect.left = 0;
-            SrcRect.top = 0;
-            SrcRect.right = srcImpl->currentDesc.Width;
-            SrcRect.bottom = srcImpl->currentDesc.Height;
-        }
+        surface_get_rect(srcImpl, rsrc, &SrcRect);
 
         DstRect.left = dstx;
@@ -4174,19 +3890,6 @@
             || This->resource.format_desc->format == WINED3DFMT_P8_UINT_A8_UNORM)
     {
-        int bpp;
-        GLenum format, internal, type;
-        CONVERT_TYPES convert;
-
-        /* Check if we are using a RTL mode which uses texturing for uploads */
-        BOOL use_texture = (wined3d_settings.rendertargetlock_mode == RTL_READTEX);
-
-        /* Check if we have hardware palette conversion if we have convert is set to NO_CONVERSION */
-        d3dfmt_get_conv(This, TRUE, use_texture, &format, &internal, &type, &convert, &bpp, FALSE);
-
-        if((This->resource.usage & WINED3DUSAGE_RENDERTARGET) && (convert == NO_CONVERSION))
+        if(This->resource.usage & WINED3DUSAGE_RENDERTARGET)
         {
-            IWineD3DDeviceImpl *device = This->resource.device;
-            struct wined3d_context *context;
-
             /* Make sure the texture is up to date. This call doesn't do anything if the texture is already up to date. */
             IWineD3DSurface_LoadLocation(iface, SFLAG_INTEXTURE, NULL);
@@ -4194,9 +3897,4 @@
             /* We want to force a palette refresh, so mark the drawable as not being up to date */
             IWineD3DSurface_ModifyLocation(iface, SFLAG_INDRAWABLE, FALSE);
-
-            /* Re-upload the palette */
-            context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
-            d3dfmt_p8_upload_palette(iface, convert);
-            context_release(context);
         } else {
             if(!(This->Flags & SFLAG_INSYSMEM)) {
@@ -4277,16 +3975,16 @@
         4: Create the surface, but allow it to be used only for DirectDraw Blts. Some apps(e.g. Swat 3) create textures with a Height of 16 and a Width > 3000 and blt 16x16 letter areas from them to the render target.
         */
-        WARN("(%p) Creating an oversized surface: %ux%u (texture is %ux%u)\n",
-             This, This->pow2Width, This->pow2Height, This->currentDesc.Width, This->currentDesc.Height);
-        This->Flags |= SFLAG_OVERSIZE;
-
-        /* This will be initialized on the first blt */
-        This->glRect.left = 0;
-        This->glRect.top = 0;
-        This->glRect.right = 0;
-        This->glRect.bottom = 0;
-    } else {
-        /* Check this after the oversize check - do not make an oversized surface a texture_rectangle one.
-           Second also don't use ARB_TEXTURE_RECTANGLE in case the surface format is P8 and EXT_PALETTED_TEXTURE
+        if(This->resource.pool == WINED3DPOOL_DEFAULT || This->resource.pool == WINED3DPOOL_MANAGED)
+        {
+            WARN("(%p) Unable to allocate a surface which exceeds the maximum OpenGL texture size\n", This);
+            return WINED3DERR_NOTAVAILABLE;
+        }
+
+        /* We should never use this surface in combination with OpenGL! */
+        TRACE("(%p) Creating an oversized surface: %ux%u\n", This, This->pow2Width, This->pow2Height);
+    }
+    else
+    {
+        /* Don't use ARB_TEXTURE_RECTANGLE in case the surface format is P8 and EXT_PALETTED_TEXTURE
            is used in combination with texture uploads (RTL_READTEX/RTL_TEXTEX). The reason is that EXT_PALETTED_TEXTURE
            doesn't work in combination with ARB_TEXTURE_RECTANGLE.
@@ -4302,11 +4000,4 @@
             This->Flags &= ~(SFLAG_NONPOW2 | SFLAG_NORMCOORD);
         }
-
-        /* No oversize, gl rect is the full texture size */
-        This->Flags &= ~SFLAG_OVERSIZE;
-        This->glRect.left = 0;
-        This->glRect.top = 0;
-        This->glRect.right = This->pow2Width;
-        This->glRect.bottom = This->pow2Height;
     }
 
@@ -4314,5 +4005,4 @@
         switch(wined3d_settings.offscreen_rendering_mode) {
             case ORM_FBO:        This->get_drawable_size = get_drawable_size_fbo;        break;
-            case ORM_PBUFFER:    This->get_drawable_size = get_drawable_size_pbuffer;    break;
             case ORM_BACKBUFFER: This->get_drawable_size = get_drawable_size_backbuffer; break;
         }
@@ -4324,102 +4014,10 @@
 }
 
-struct depth_blt_info
-{
-    GLenum binding;
-    GLenum bind_target;
-    enum tex_types tex_type;
-    GLfloat coords[4][3];
-};
-
-static void surface_get_depth_blt_info(GLenum target, GLsizei w, GLsizei h, struct depth_blt_info *info)
-{
-    GLfloat (*coords)[3] = info->coords;
-
-    switch (target)
-    {
-        default:
-            FIXME("Unsupported texture target %#x\n", target);
-            /* Fall back to GL_TEXTURE_2D */
-        case GL_TEXTURE_2D:
-            info->binding = GL_TEXTURE_BINDING_2D;
-            info->bind_target = GL_TEXTURE_2D;
-            info->tex_type = tex_2d;
-            coords[0][0] = 0.0f;    coords[0][1] = 1.0f;    coords[0][2] = 0.0f;
-            coords[1][0] = 1.0f;    coords[1][1] = 1.0f;    coords[1][2] = 0.0f;
-            coords[2][0] = 0.0f;    coords[2][1] = 0.0f;    coords[2][2] = 0.0f;
-            coords[3][0] = 1.0f;    coords[3][1] = 0.0f;    coords[3][2] = 0.0f;
-            break;
-
-        case GL_TEXTURE_RECTANGLE_ARB:
-            info->binding = GL_TEXTURE_BINDING_RECTANGLE_ARB;
-            info->bind_target = GL_TEXTURE_RECTANGLE_ARB;
-            info->tex_type = tex_rect;
-            coords[0][0] = 0.0f;    coords[0][1] = h;       coords[0][2] = 0.0f;
-            coords[1][0] = w;       coords[1][1] = h;       coords[1][2] = 0.0f;
-            coords[2][0] = 0.0f;    coords[2][1] = 0.0f;    coords[2][2] = 0.0f;
-            coords[3][0] = w;       coords[3][1] = 0.0f;    coords[3][2] = 0.0f;
-            break;
-
-        case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
-            info->binding = GL_TEXTURE_BINDING_CUBE_MAP_ARB;
-            info->bind_target = GL_TEXTURE_CUBE_MAP_ARB;
-            info->tex_type = tex_cube;
-            coords[0][0] =  1.0f;   coords[0][1] = -1.0f;   coords[0][2] =  1.0f;
-            coords[1][0] =  1.0f;   coords[1][1] = -1.0f;   coords[1][2] = -1.0f;
-            coords[2][0] =  1.0f;   coords[2][1] =  1.0f;   coords[2][2] =  1.0f;
-            coords[3][0] =  1.0f;   coords[3][1] =  1.0f;   coords[3][2] = -1.0f;
-
-        case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
-            info->binding = GL_TEXTURE_BINDING_CUBE_MAP_ARB;
-            info->bind_target = GL_TEXTURE_CUBE_MAP_ARB;
-            info->tex_type = tex_cube;
-            coords[0][0] = -1.0f;   coords[0][1] = -1.0f;   coords[0][2] = -1.0f;
-            coords[1][0] = -1.0f;   coords[1][1] = -1.0f;   coords[1][2] =  1.0f;
-            coords[2][0] = -1.0f;   coords[2][1] =  1.0f;   coords[2][2] = -1.0f;
-            coords[3][0] = -1.0f;   coords[3][1] =  1.0f;   coords[3][2] =  1.0f;
-
-        case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
-            info->binding = GL_TEXTURE_BINDING_CUBE_MAP_ARB;
-            info->bind_target = GL_TEXTURE_CUBE_MAP_ARB;
-            info->tex_type = tex_cube;
-            coords[0][0] = -1.0f;   coords[0][1] =  1.0f;   coords[0][2] =  1.0f;
-            coords[1][0] =  1.0f;   coords[1][1] =  1.0f;   coords[1][2] =  1.0f;
-            coords[2][0] = -1.0f;   coords[2][1] =  1.0f;   coords[2][2] = -1.0f;
-            coords[3][0] =  1.0f;   coords[3][1] =  1.0f;   coords[3][2] = -1.0f;
-
-        case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
-            info->binding = GL_TEXTURE_BINDING_CUBE_MAP_ARB;
-            info->bind_target = GL_TEXTURE_CUBE_MAP_ARB;
-            info->tex_type = tex_cube;
-            coords[0][0] = -1.0f;   coords[0][1] = -1.0f;   coords[0][2] = -1.0f;
-            coords[1][0] =  1.0f;   coords[1][1] = -1.0f;   coords[1][2] = -1.0f;
-            coords[2][0] = -1.0f;   coords[2][1] = -1.0f;   coords[2][2] =  1.0f;
-            coords[3][0] =  1.0f;   coords[3][1] = -1.0f;   coords[3][2] =  1.0f;
-
-        case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
-            info->binding = GL_TEXTURE_BINDING_CUBE_MAP_ARB;
-            info->bind_target = GL_TEXTURE_CUBE_MAP_ARB;
-            info->tex_type = tex_cube;
-            coords[0][0] = -1.0f;   coords[0][1] = -1.0f;   coords[0][2] =  1.0f;
-            coords[1][0] =  1.0f;   coords[1][1] = -1.0f;   coords[1][2] =  1.0f;
-            coords[2][0] = -1.0f;   coords[2][1] =  1.0f;   coords[2][2] =  1.0f;
-            coords[3][0] =  1.0f;   coords[3][1] =  1.0f;   coords[3][2] =  1.0f;
-
-        case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
-            info->binding = GL_TEXTURE_BINDING_CUBE_MAP_ARB;
-            info->bind_target = GL_TEXTURE_CUBE_MAP_ARB;
-            info->tex_type = tex_cube;
-            coords[0][0] =  1.0f;   coords[0][1] = -1.0f;   coords[0][2] = -1.0f;
-            coords[1][0] = -1.0f;   coords[1][1] = -1.0f;   coords[1][2] = -1.0f;
-            coords[2][0] =  1.0f;   coords[2][1] =  1.0f;   coords[2][2] = -1.0f;
-            coords[3][0] = -1.0f;   coords[3][1] =  1.0f;   coords[3][2] = -1.0f;
-    }
-}
-
 /* GL locking is done by the caller */
-static void surface_depth_blt(IWineD3DSurfaceImpl *This, GLuint texture, GLsizei w, GLsizei h, GLenum target)
+static void surface_depth_blt(IWineD3DSurfaceImpl *This, const struct wined3d_gl_info *gl_info,
+        GLuint texture, GLsizei w, GLsizei h, GLenum target)
 {
     IWineD3DDeviceImpl *device = This->resource.device;
-    struct depth_blt_info info;
+    struct blt_info info;
     GLint old_binding = 0;
 
@@ -4437,5 +4035,5 @@
     glViewport(0, 0, w, h);
 
-    surface_get_depth_blt_info(target, w, h, &info);
+    surface_get_blt_info(target, NULL, w, h, &info);
     GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB));
     glGetIntegerv(info.binding, &old_binding);
@@ -4552,8 +4150,9 @@
                     GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, device->depth_blt_rb);
             checkGLcall("glFramebufferRenderbufferEXT");
-            context_attach_depth_stencil_fbo(context, GL_FRAMEBUFFER, iface, FALSE);
+            context_attach_depth_stencil_fbo(context, GL_FRAMEBUFFER, This, FALSE);
 
             /* Do the actual blit */
-            surface_depth_blt(This, device->depth_blt_texture, This->currentDesc.Width, This->currentDesc.Height, bind_target);
+            surface_depth_blt(This, gl_info, device->depth_blt_texture,
+                    This->currentDesc.Width, This->currentDesc.Height, bind_target);
             checkGLcall("depth_blt");
 
@@ -4562,5 +4161,9 @@
 
             LEAVE_GL();
-        } else {
+
+            if (wined3d_settings.strict_draw_ordering) wglFlush(); /* Flush to ensure ordering across contexts. */
+        }
+        else
+        {
             FIXME("No up to date depth stencil location\n");
         }
@@ -4572,6 +4175,6 @@
 
             context_bind_fbo(context, GL_FRAMEBUFFER, NULL);
-            surface_depth_blt(This, This->texture_name, This->currentDesc.Width,
-                    This->currentDesc.Height, This->texture_target);
+            surface_depth_blt(This, gl_info, This->texture_name,
+                    This->currentDesc.Width, This->currentDesc.Height, This->texture_target);
             checkGLcall("depth_blt");
 
@@ -4579,5 +4182,9 @@
 
             LEAVE_GL();
-        } else {
+
+            if (wined3d_settings.strict_draw_ordering) wglFlush(); /* Flush to ensure ordering across contexts. */
+        }
+        else
+        {
             FIXME("No up to date depth stencil location\n");
         }
@@ -4643,193 +4250,39 @@
 }
 
-struct coords {
-    GLfloat x, y, z;
-};
-
-struct float_rect
-{
-    float l;
-    float t;
-    float r;
-    float b;
-};
-
-static inline void cube_coords_float(const RECT *r, UINT w, UINT h, struct float_rect *f)
-{
-    f->l = ((r->left * 2.0f) / w) - 1.0f;
-    f->t = ((r->top * 2.0f) / h) - 1.0f;
-    f->r = ((r->right * 2.0f) / w) - 1.0f;
-    f->b = ((r->bottom * 2.0f) / h) - 1.0f;
-}
-
 static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT *rect_in)
 {
     IWineD3DDeviceImpl *device = This->resource.device;
+    IWineD3DSwapChainImpl *swapchain;
     struct wined3d_context *context;
-    struct coords coords[4];
-    RECT rect;
-    IWineD3DSwapChain *swapchain;
-    IWineD3DBaseTexture *texture;
-    GLenum bind_target;
-    struct float_rect f;
-
-    if(rect_in) {
-        rect = *rect_in;
-    } else {
-        rect.left = 0;
-        rect.top = 0;
-        rect.right = This->currentDesc.Width;
-        rect.bottom = This->currentDesc.Height;
-    }
-
-    switch (This->texture_target)
-    {
-        case GL_TEXTURE_2D:
-            bind_target = GL_TEXTURE_2D;
-
-            coords[0].x = (float)rect.left / This->pow2Width;
-            coords[0].y = (float)rect.top / This->pow2Height;
-            coords[0].z = 0;
-
-            coords[1].x = (float)rect.left / This->pow2Width;
-            coords[1].y = (float)rect.bottom / This->pow2Height;
-            coords[1].z = 0;
-
-            coords[2].x = (float)rect.right / This->pow2Width;
-            coords[2].y = (float)rect.bottom / This->pow2Height;
-            coords[2].z = 0;
-
-            coords[3].x = (float)rect.right / This->pow2Width;
-            coords[3].y = (float)rect.top / This->pow2Height;
-            coords[3].z = 0;
-            break;
-
-        case GL_TEXTURE_RECTANGLE_ARB:
-            bind_target = GL_TEXTURE_RECTANGLE_ARB;
-            coords[0].x = rect.left;    coords[0].y = rect.top;     coords[0].z = 0;
-            coords[1].x = rect.left;    coords[1].y = rect.bottom;  coords[1].z = 0;
-            coords[2].x = rect.right;   coords[2].y = rect.bottom;  coords[2].z = 0;
-            coords[3].x = rect.right;   coords[3].y = rect.top;     coords[3].z = 0;
-            break;
-
-        case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
-            bind_target = GL_TEXTURE_CUBE_MAP_ARB;
-            cube_coords_float(&rect, This->pow2Width, This->pow2Height, &f);
-            coords[0].x =    1; coords[0].y = -f.t; coords[0].z = -f.l;
-            coords[1].x =    1; coords[1].y = -f.b; coords[1].z = -f.l;
-            coords[2].x =    1; coords[2].y = -f.b; coords[2].z = -f.r;
-            coords[3].x =    1; coords[3].y = -f.t; coords[3].z = -f.r;
-            break;
-
-        case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
-            bind_target = GL_TEXTURE_CUBE_MAP_ARB;
-            cube_coords_float(&rect, This->pow2Width, This->pow2Height, &f);
-            coords[0].x =   -1; coords[0].y = -f.t; coords[0].z =  f.l;
-            coords[1].x =   -1; coords[1].y = -f.b; coords[1].z =  f.l;
-            coords[2].x =   -1; coords[2].y = -f.b; coords[2].z =  f.r;
-            coords[3].x =   -1; coords[3].y = -f.t; coords[3].z =  f.r;
-            break;
-
-        case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
-            bind_target = GL_TEXTURE_CUBE_MAP_ARB;
-            cube_coords_float(&rect, This->pow2Width, This->pow2Height, &f);
-            coords[0].x =  f.l; coords[0].y =    1; coords[0].z =  f.t;
-            coords[1].x =  f.l; coords[1].y =    1; coords[1].z =  f.b;
-            coords[2].x =  f.r; coords[2].y =    1; coords[2].z =  f.b;
-            coords[3].x =  f.r; coords[3].y =    1; coords[3].z =  f.t;
-            break;
-
-        case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
-            bind_target = GL_TEXTURE_CUBE_MAP_ARB;
-            cube_coords_float(&rect, This->pow2Width, This->pow2Height, &f);
-            coords[0].x =  f.l; coords[0].y =   -1; coords[0].z = -f.t;
-            coords[1].x =  f.l; coords[1].y =   -1; coords[1].z = -f.b;
-            coords[2].x =  f.r; coords[2].y =   -1; coords[2].z = -f.b;
-            coords[3].x =  f.r; coords[3].y =   -1; coords[3].z = -f.t;
-            break;
-
-        case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
-            bind_target = GL_TEXTURE_CUBE_MAP_ARB;
-            cube_coords_float(&rect, This->pow2Width, This->pow2Height, &f);
-            coords[0].x =  f.l; coords[0].y = -f.t; coords[0].z =    1;
-            coords[1].x =  f.l; coords[1].y = -f.b; coords[1].z =    1;
-            coords[2].x =  f.r; coords[2].y = -f.b; coords[2].z =    1;
-            coords[3].x =  f.r; coords[3].y = -f.t; coords[3].z =    1;
-            break;
-
-        case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
-            bind_target = GL_TEXTURE_CUBE_MAP_ARB;
-            cube_coords_float(&rect, This->pow2Width, This->pow2Height, &f);
-            coords[0].x = -f.l; coords[0].y = -f.t; coords[0].z =   -1;
-            coords[1].x = -f.l; coords[1].y = -f.b; coords[1].z =   -1;
-            coords[2].x = -f.r; coords[2].y = -f.b; coords[2].z =   -1;
-            coords[3].x = -f.r; coords[3].y = -f.t; coords[3].z =   -1;
-            break;
-
-        default:
-            ERR("Unexpected texture target %#x\n", This->texture_target);
-            return;
-    }
+    RECT src_rect, dst_rect;
+
+    surface_get_rect(This, rect_in, &src_rect);
 
     context = context_acquire(device, (IWineD3DSurface*)This, CTXUSAGE_BLIT);
+    if (context->render_offscreen)
+    {
+        dst_rect.left = src_rect.left;
+        dst_rect.right = src_rect.right;
+        dst_rect.top = src_rect.bottom;
+        dst_rect.bottom = src_rect.top;
+    }
+    else
+    {
+        dst_rect = src_rect;
+    }
+
+    device->blitter->set_shader((IWineD3DDevice *) device, This);
 
     ENTER_GL();
-
-    glEnable(bind_target);
-    checkGLcall("glEnable(bind_target)");
-    glBindTexture(bind_target, This->texture_name);
-    checkGLcall("glBindTexture(bind_target, This->texture_name)");
-    glTexParameteri(bind_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-    checkGLcall("glTexParameteri");
-    glTexParameteri(bind_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-    checkGLcall("glTexParameteri");
-
-    if (context->render_offscreen)
-    {
-        LONG tmp = rect.top;
-        rect.top = rect.bottom;
-        rect.bottom = tmp;
-    }
-
-    glBegin(GL_QUADS);
-    glTexCoord3fv(&coords[0].x);
-    glVertex2i(rect.left, rect.top);
-
-    glTexCoord3fv(&coords[1].x);
-    glVertex2i(rect.left, rect.bottom);
-
-    glTexCoord3fv(&coords[2].x);
-    glVertex2i(rect.right, rect.bottom);
-
-    glTexCoord3fv(&coords[3].x);
-    glVertex2i(rect.right, rect.top);
-    glEnd();
-    checkGLcall("glEnd");
-
-    glDisable(bind_target);
-    checkGLcall("glDisable(bind_target)");
-
+    draw_textured_quad(This, &src_rect, &dst_rect, WINED3DTEXF_POINT);
     LEAVE_GL();
 
-    if(SUCCEEDED(IWineD3DSurface_GetContainer((IWineD3DSurface*)This, &IID_IWineD3DSwapChain, (void **) &swapchain)))
-    {
-        /* Make sure to flush the buffers. This is needed in apps like Red Alert II and Tiberian SUN that use multiple WGL contexts. */
-        if(((IWineD3DSwapChainImpl*)swapchain)->frontBuffer == (IWineD3DSurface*)This ||
-           ((IWineD3DSwapChainImpl*)swapchain)->num_contexts >= 2)
-            wglFlush();
-
-        IWineD3DSwapChain_Release(swapchain);
-    } else {
-        /* We changed the filtering settings on the texture. Inform the container about this to get the filters
-         * reset properly next draw
-         */
-        if(SUCCEEDED(IWineD3DSurface_GetContainer((IWineD3DSurface*)This, &IID_IWineD3DBaseTexture, (void **) &texture)))
-        {
-            ((IWineD3DBaseTextureImpl *) texture)->baseTexture.texture_rgb.states[WINED3DTEXSTA_MAGFILTER] = WINED3DTEXF_POINT;
-            ((IWineD3DBaseTextureImpl *) texture)->baseTexture.texture_rgb.states[WINED3DTEXSTA_MINFILTER] = WINED3DTEXF_POINT;
-            ((IWineD3DBaseTextureImpl *) texture)->baseTexture.texture_rgb.states[WINED3DTEXSTA_MIPFILTER] = WINED3DTEXF_NONE;
-            IWineD3DBaseTexture_Release(texture);
-        }
-    }
+    device->blitter->set_shader((IWineD3DDevice *) device, This);
+
+    swapchain = (This->Flags & SFLAG_SWAPCHAIN) ? (IWineD3DSwapChainImpl *)This->container : NULL;
+    if (wined3d_settings.strict_draw_ordering || (swapchain
+            && ((IWineD3DSurface *)This == swapchain->frontBuffer
+            || swapchain->num_contexts > 1)))
+        wglFlush(); /* Flush to ensure ordering across contexts. */
 
     context_release(context);
@@ -4861,7 +4314,6 @@
     IWineD3DDeviceImpl *device = This->resource.device;
     const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
-    GLenum format, internal, type;
+    struct wined3d_format_desc desc;
     CONVERT_TYPES convert;
-    int bpp;
     int width, pitch, outpitch;
     BYTE *mem;
@@ -4911,5 +4363,5 @@
 
             surface_bind_and_dirtify(This, !(This->Flags & SFLAG_INTEXTURE));
-            surface_download_data(This);
+            surface_download_data(This, gl_info);
 
             if (context) context_release(context);
@@ -4926,4 +4378,5 @@
             surface_blt_to_drawable(This, rect);
         } else {
+            int byte_count;
             if((This->Flags & SFLAG_LOCATIONS) == SFLAG_INSRGBTEX) {
                 /* This needs a shader to convert the srgb data sampled from the GL texture into RGB
@@ -4934,5 +4387,5 @@
             }
 
-            d3dfmt_get_conv(This, TRUE /* We need color keying */, FALSE /* We won't use textures */, &format, &internal, &type, &convert, &bpp, FALSE);
+            d3dfmt_get_conv(This, FALSE /* We need color keying */, FALSE /* We won't use textures */, &desc, &convert);
 
             /* The width is in 'length' not in bytes */
@@ -4949,5 +4402,5 @@
 
                 if (!device->isInDraw) context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
-                surface_remove_pbo(This);
+                surface_remove_pbo(This, gl_info);
                 if (context) context_release(context);
             }
@@ -4955,7 +4408,8 @@
             if((convert != NO_CONVERSION) && This->resource.allocatedMemory) {
                 int height = This->currentDesc.Height;
+                byte_count = desc.conv_byte_count;
 
                 /* Stick to the alignment for the converted surface too, makes it easier to load the surface */
-                outpitch = width * bpp;
+                outpitch = width * byte_count;
                 outpitch = (outpitch + device->surface_alignment - 1) & ~(device->surface_alignment - 1);
 
@@ -4971,7 +4425,8 @@
                 This->Flags &= ~SFLAG_CONVERTED;
                 mem = This->resource.allocatedMemory;
-            }
-
-            flush_to_framebuffer_drawpixels(This, format, type, bpp, mem);
+                byte_count = desc.byte_count;
+            }
+
+            flush_to_framebuffer_drawpixels(This, desc.glFormat, desc.glType, byte_count, mem);
 
             /* Don't delete PBO memory */
@@ -4987,9 +4442,8 @@
             /* Upload from system memory */
             BOOL srgb = flag == SFLAG_INSRGBTEX;
-            DWORD alloc_flag = srgb ? SFLAG_SRGBALLOCATED : SFLAG_ALLOCATED;
             struct wined3d_context *context = NULL;
 
             d3dfmt_get_conv(This, TRUE /* We need color keying */, TRUE /* We will use textures */,
-                    &format, &internal, &type, &convert, &bpp, srgb);
+                    &desc, &convert);
 
             if(srgb) {
@@ -5014,4 +4468,6 @@
 
             if (!device->isInDraw) context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
+
+            surface_prepare_texture(This, gl_info, srgb);
             surface_bind_and_dirtify(This, srgb);
 
@@ -5030,12 +4486,28 @@
             if((convert != NO_CONVERSION) && (This->Flags & SFLAG_PBO)) {
                 TRACE("Removing the pbo attached to surface %p\n", This);
-                surface_remove_pbo(This);
-            }
-
-            if((convert != NO_CONVERSION) && This->resource.allocatedMemory) {
+                surface_remove_pbo(This, gl_info);
+            }
+
+            if(desc.convert) {
+                /* This code is entered for texture formats which need a fixup. */
                 int height = This->currentDesc.Height;
 
                 /* Stick to the alignment for the converted surface too, makes it easier to load the surface */
-                outpitch = width * bpp;
+                outpitch = width * desc.conv_byte_count;
+                outpitch = (outpitch + device->surface_alignment - 1) & ~(device->surface_alignment - 1);
+
+                mem = HeapAlloc(GetProcessHeap(), 0, outpitch * height);
+                if(!mem) {
+                    ERR("Out of memory %d, %d!\n", outpitch, height);
+                    if (context) context_release(context);
+                    return WINED3DERR_OUTOFVIDEOMEMORY;
+                }
+                desc.convert(This->resource.allocatedMemory, mem, pitch, width, height);
+            } else if((convert != NO_CONVERSION) && This->resource.allocatedMemory) {
+                /* This code is only entered for color keying fixups */
+                int height = This->currentDesc.Height;
+
+                /* Stick to the alignment for the converted surface too, makes it easier to load the surface */
+                outpitch = width * desc.conv_byte_count;
                 outpitch = (outpitch + device->surface_alignment - 1) & ~(device->surface_alignment - 1);
 
@@ -5047,15 +4519,5 @@
                 }
                 d3dfmt_convert_surface(This->resource.allocatedMemory, mem, pitch, width, height, outpitch, convert, This);
-
-                This->Flags |= SFLAG_CONVERTED;
-            }
-            else if (This->resource.format_desc->format == WINED3DFMT_P8_UINT
-                    && (gl_info->supported[EXT_PALETTED_TEXTURE] || gl_info->supported[ARB_FRAGMENT_PROGRAM]))
-            {
-                d3dfmt_p8_upload_palette(iface, convert);
-                This->Flags &= ~SFLAG_CONVERTED;
-                mem = This->resource.allocatedMemory;
             } else {
-                This->Flags &= ~SFLAG_CONVERTED;
                 mem = This->resource.allocatedMemory;
             }
@@ -5066,25 +4528,6 @@
             LEAVE_GL();
 
-            if ((This->Flags & SFLAG_NONPOW2) && !(This->Flags & SFLAG_OVERSIZE)) {
-                TRACE("non power of two support\n");
-                if(!(This->Flags & alloc_flag)) {
-                    surface_allocate_surface(This, internal, This->pow2Width, This->pow2Height, format, type);
-                    This->Flags |= alloc_flag;
-                }
-                if (mem || (This->Flags & SFLAG_PBO)) {
-                    surface_upload_data(This, internal, This->currentDesc.Width, This->currentDesc.Height, format, type, mem);
-                }
-            } else {
-                /* When making the realloc conditional, keep in mind that GL_APPLE_client_storage may be in use, and This->resource.allocatedMemory
-                 * changed. So also keep track of memory changes. In this case the texture has to be reallocated
-                 */
-                if(!(This->Flags & alloc_flag)) {
-                    surface_allocate_surface(This, internal, This->glRect.right - This->glRect.left, This->glRect.bottom - This->glRect.top, format, type);
-                    This->Flags |= alloc_flag;
-                }
-                if (mem || (This->Flags & SFLAG_PBO)) {
-                    surface_upload_data(This, internal, This->glRect.right - This->glRect.left, This->glRect.bottom - This->glRect.top, format, type, mem);
-                }
-            }
+            if (mem || (This->Flags & SFLAG_PBO))
+                surface_upload_data(This, gl_info, &desc, srgb, mem);
 
             /* Restore the default pitch */
@@ -5128,5 +4571,4 @@
         switch(wined3d_settings.offscreen_rendering_mode) {
             case ORM_FBO:        This->get_drawable_size = get_drawable_size_fbo;        break;
-            case ORM_PBUFFER:    This->get_drawable_size = get_drawable_size_pbuffer;    break;
             case ORM_BACKBUFFER: This->get_drawable_size = get_drawable_size_backbuffer; break;
         }
@@ -5233,18 +4675,40 @@
     IWineD3DSurfaceImpl_DrawOverlay
 };
-#undef GLINFO_LOCATION
-
-#define GLINFO_LOCATION device->adapter->gl_info
+
 static HRESULT ffp_blit_alloc(IWineD3DDevice *iface) { return WINED3D_OK; }
 /* Context activation is done by the caller. */
 static void ffp_blit_free(IWineD3DDevice *iface) { }
 
+/* This function is used in case of 8bit paletted textures using GL_EXT_paletted_texture */
 /* Context activation is done by the caller. */
-static HRESULT ffp_blit_set(IWineD3DDevice *iface, const struct GlPixelFormatDesc *format_desc,
-        GLenum textype, UINT width, UINT height)
-{
+static void ffp_blit_p8_upload_palette(IWineD3DSurfaceImpl *surface, const struct wined3d_gl_info *gl_info)
+{
+    BYTE table[256][4];
+    BOOL colorkey_active = (surface->CKeyFlags & WINEDDSD_CKSRCBLT) ? TRUE : FALSE;
+
+    d3dfmt_p8_init_palette(surface, table, colorkey_active);
+
+    TRACE("Using GL_EXT_PALETTED_TEXTURE for 8-bit paletted texture support\n");
     ENTER_GL();
-    glEnable(textype);
-    checkGLcall("glEnable(textype)");
+    GL_EXTCALL(glColorTableEXT(surface->texture_target, GL_RGBA, 256, GL_RGBA, GL_UNSIGNED_BYTE, table));
+    LEAVE_GL();
+}
+
+/* Context activation is done by the caller. */
+static HRESULT ffp_blit_set(IWineD3DDevice *iface, IWineD3DSurfaceImpl *surface)
+{
+    IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) iface;
+    const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
+    enum complex_fixup fixup = get_complex_fixup(surface->resource.format_desc->color_fixup);
+
+    /* When EXT_PALETTED_TEXTURE is around, palette conversion is done by the GPU
+     * else the surface is converted in software at upload time in LoadLocation.
+     */
+    if(fixup == COMPLEX_FIXUP_P8 && gl_info->supported[EXT_PALETTED_TEXTURE])
+        ffp_blit_p8_upload_palette(surface, gl_info);
+
+    ENTER_GL();
+    glEnable(surface->texture_target);
+    checkGLcall("glEnable(surface->texture_target)");
     LEAVE_GL();
     return WINED3D_OK;
@@ -5273,14 +4737,50 @@
 }
 
-static BOOL ffp_blit_color_fixup_supported(struct color_fixup_desc fixup)
-{
+static BOOL ffp_blit_supported(const struct wined3d_gl_info *gl_info, enum blit_operation blit_op,
+                               const RECT *src_rect, DWORD src_usage, WINED3DPOOL src_pool,
+                               const struct wined3d_format_desc *src_format_desc,
+                               const RECT *dst_rect, DWORD dst_usage, WINED3DPOOL dst_pool,
+                               const struct wined3d_format_desc *dst_format_desc)
+{
+    enum complex_fixup src_fixup;
+
+    if (blit_op == BLIT_OP_COLOR_FILL)
+    {
+        if (!(dst_usage & WINED3DUSAGE_RENDERTARGET))
+        {
+            TRACE("Color fill not supported\n");
+            return FALSE;
+        }
+
+        return TRUE;
+    }
+
+    src_fixup = get_complex_fixup(src_format_desc->color_fixup);
     if (TRACE_ON(d3d_surface) && TRACE_ON(d3d))
     {
         TRACE("Checking support for fixup:\n");
-        dump_color_fixup_desc(fixup);
+        dump_color_fixup_desc(src_format_desc->color_fixup);
+    }
+
+    if (blit_op != BLIT_OP_BLIT)
+    {
+        TRACE("Unsupported blit_op=%d\n", blit_op);
+        return FALSE;
+     }
+
+    if (!is_identity_fixup(dst_format_desc->color_fixup))
+    {
+        TRACE("Destination fixups are not supported\n");
+        return FALSE;
+    }
+
+    if (src_fixup == COMPLEX_FIXUP_P8 && gl_info->supported[EXT_PALETTED_TEXTURE])
+    {
+        TRACE("P8 fixup supported\n");
+        return TRUE;
     }
 
     /* We only support identity conversions. */
-    if (is_identity_fixup(fixup))
+    if (is_identity_fixup(src_format_desc->color_fixup))
     {
         TRACE("[OK]\n");
@@ -5290,4 +4790,10 @@
     TRACE("[FAILED]\n");
     return FALSE;
+}
+
+static HRESULT ffp_blit_color_fill(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *dst_surface, const RECT *dst_rect, DWORD fill_color)
+{
+    return IWineD3DDeviceImpl_ClearSurface(device, dst_surface, 1 /* Number of rectangles */,
+                                           (const WINED3DRECT*)dst_rect, WINED3DCLEAR_TARGET, fill_color, 0.0f /* Z */, 0 /* Stencil */);
 }
 
@@ -5297,4 +4803,93 @@
     ffp_blit_set,
     ffp_blit_unset,
-    ffp_blit_color_fixup_supported
+    ffp_blit_supported,
+    ffp_blit_color_fill
 };
+
+static HRESULT cpu_blit_alloc(IWineD3DDevice *iface)
+{
+    return WINED3D_OK;
+}
+
+/* Context activation is done by the caller. */
+static void cpu_blit_free(IWineD3DDevice *iface)
+{
+}
+
+/* Context activation is done by the caller. */
+static HRESULT cpu_blit_set(IWineD3DDevice *iface, IWineD3DSurfaceImpl *surface)
+{
+    return WINED3D_OK;
+}
+
+/* Context activation is done by the caller. */
+static void cpu_blit_unset(IWineD3DDevice *iface)
+{
+}
+
+static BOOL cpu_blit_supported(const struct wined3d_gl_info *gl_info, enum blit_operation blit_op,
+                               const RECT *src_rect, DWORD src_usage, WINED3DPOOL src_pool,
+                               const struct wined3d_format_desc *src_format_desc,
+                               const RECT *dst_rect, DWORD dst_usage, WINED3DPOOL dst_pool,
+                               const struct wined3d_format_desc *dst_format_desc)
+{
+    if (blit_op == BLIT_OP_COLOR_FILL)
+    {
+        return TRUE;
+    }
+
+    return FALSE;
+}
+
+static HRESULT cpu_blit_color_fill(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *dst_surface, const RECT *dst_rect, DWORD fill_color)
+{
+    WINEDDBLTFX BltFx;
+    memset(&BltFx, 0, sizeof(BltFx));
+    BltFx.dwSize = sizeof(BltFx);
+    BltFx.u5.dwFillColor = color_convert_argb_to_fmt(fill_color, dst_surface->resource.format_desc->format);
+    return IWineD3DBaseSurfaceImpl_Blt((IWineD3DSurface*)dst_surface, dst_rect, NULL, NULL, WINEDDBLT_COLORFILL, &BltFx, WINED3DTEXF_POINT);
+}
+
+const struct blit_shader cpu_blit =  {
+    cpu_blit_alloc,
+    cpu_blit_free,
+    cpu_blit_set,
+    cpu_blit_unset,
+    cpu_blit_supported,
+    cpu_blit_color_fill
+};
+
+static BOOL fbo_blit_supported(const struct wined3d_gl_info *gl_info, enum blit_operation blit_op,
+                               const RECT *src_rect, DWORD src_usage, WINED3DPOOL src_pool,
+                               const struct wined3d_format_desc *src_format_desc,
+                               const RECT *dst_rect, DWORD dst_usage, WINED3DPOOL dst_pool,
+                               const struct wined3d_format_desc *dst_format_desc)
+{
+    if ((wined3d_settings.offscreen_rendering_mode != ORM_FBO) || !gl_info->fbo_ops.glBlitFramebuffer)
+        return FALSE;
+
+    /* We only support blitting. Things like color keying / color fill should
+     * be handled by other blitters.
+     */
+    if (blit_op != BLIT_OP_BLIT)
+        return FALSE;
+
+    /* Source and/or destination need to be on the GL side */
+    if (src_pool == WINED3DPOOL_SYSTEMMEM || dst_pool == WINED3DPOOL_SYSTEMMEM)
+        return FALSE;
+
+    if(!((src_format_desc->Flags & WINED3DFMT_FLAG_FBO_ATTACHABLE) || (src_usage & WINED3DUSAGE_RENDERTARGET))
+        && ((dst_format_desc->Flags & WINED3DFMT_FLAG_FBO_ATTACHABLE) || (dst_usage & WINED3DUSAGE_RENDERTARGET)))
+        return FALSE;
+
+    if (!is_identity_fixup(src_format_desc->color_fixup) ||
+        !is_identity_fixup(dst_format_desc->color_fixup))
+        return FALSE;
+
+    if (!(src_format_desc->format == dst_format_desc->format
+        || (is_identity_fixup(src_format_desc->color_fixup)
+        && is_identity_fixup(dst_format_desc->color_fixup))))
+        return FALSE;
+
+    return TRUE;
+}
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/surface_base.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/surface_base.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/surface_base.c	(revision 28475)
@@ -336,5 +336,5 @@
 DWORD WINAPI IWineD3DBaseSurfaceImpl_GetPitch(IWineD3DSurface *iface) {
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
-    const struct GlPixelFormatDesc *format_desc = This->resource.format_desc;
+    const struct wined3d_format_desc *format_desc = This->resource.format_desc;
     DWORD ret;
     TRACE("(%p)\n", This);
@@ -512,5 +512,5 @@
 HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetFormat(IWineD3DSurface *iface, WINED3DFORMAT format) {
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
-    const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(format,
+    const struct wined3d_format_desc *format_desc = getFormatDescEntry(format,
             &This->resource.device->adapter->gl_info);
 
@@ -537,5 +537,5 @@
 HRESULT IWineD3DBaseSurfaceImpl_CreateDIBSection(IWineD3DSurface *iface) {
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
-    const struct GlPixelFormatDesc *format_desc = This->resource.format_desc;
+    const struct wined3d_format_desc *format_desc = This->resource.format_desc;
     int extraline = 0;
     SYSTEM_INFO sysInfo;
@@ -752,4 +752,53 @@
 }
 
+static inline BYTE cliptobyte(int x)
+{
+    return (BYTE) ((x < 0) ? 0 : ((x > 255) ? 255 : x));
+}
+
+static void convert_yuy2_x8r8g8b8(const BYTE *src, BYTE *dst,
+        DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
+{
+    unsigned int x, y;
+    int c2, d, e, r2 = 0, g2 = 0, b2 = 0;
+
+    TRACE("Converting %ux%u pixels, pitches %u %u\n", w, h, pitch_in, pitch_out);
+
+    for (y = 0; y < h; ++y)
+    {
+        const BYTE *src_line = src + y * pitch_in;
+        DWORD *dst_line = (DWORD *)(dst + y * pitch_out);
+        for (x = 0; x < w; ++x)
+        {
+            /* YUV to RGB conversion formulas from http://en.wikipedia.org/wiki/YUV:
+             *     C = Y - 16; D = U - 128; E = V - 128;
+             *     R = cliptobyte((298 * C + 409 * E + 128) >> 8);
+             *     G = cliptobyte((298 * C - 100 * D - 208 * E + 128) >> 8);
+             *     B = cliptobyte((298 * C + 516 * D + 128) >> 8);
+             * Two adjacent YUY2 pixels are stored as four bytes: Y0 U Y1 V .
+             * U and V are shared between the pixels.
+             */
+            if (!(x & 1))         /* for every even pixel, read new U and V */
+            {
+                d = (int) src_line[1] - 128;
+                e = (int) src_line[3] - 128;
+                r2 = 409 * e + 128;
+                g2 = - 100 * d - 208 * e + 128;
+                b2 = 516 * d + 128;
+            }
+            c2 = 298 * ((int) src_line[0] - 16);
+            dst_line[x] = 0xff000000
+                | cliptobyte((c2 + r2) >> 8) << 16    /* red   */
+                | cliptobyte((c2 + g2) >> 8) << 8     /* green */
+                | cliptobyte((c2 + b2) >> 8);         /* blue  */
+                /* Scale RGB values to 0..255 range,
+                 * then clip them if still not in range (may be negative),
+                 * then shift them within DWORD if necessary.
+                 */
+            src_line += 2;
+        }
+    }
+}
+
 struct d3dfmt_convertor_desc {
     WINED3DFORMAT from, to;
@@ -762,4 +811,5 @@
     {WINED3DFMT_B5G6R5_UNORM,   WINED3DFMT_B8G8R8X8_UNORM,  convert_r5g6b5_x8r8g8b8},
     {WINED3DFMT_B8G8R8A8_UNORM, WINED3DFMT_B8G8R8X8_UNORM,  convert_a8r8g8b8_x8r8g8b8},
+    {WINED3DFMT_YUY2,           WINED3DFMT_B8G8R8X8_UNORM,  convert_yuy2_x8r8g8b8},
 };
 
@@ -919,5 +969,5 @@
     WINED3DLOCKED_RECT  dlock, slock;
     int bpp, srcheight, srcwidth, dstheight, dstwidth, width;
-    const struct GlPixelFormatDesc *sEntry, *dEntry;
+    const struct wined3d_format_desc *sEntry, *dEntry;
     int x, y;
     const BYTE *sbuf;
@@ -1562,5 +1612,5 @@
     const BYTE          *sbuf;
     BYTE                *dbuf;
-    const struct GlPixelFormatDesc *sEntry, *dEntry;
+    const struct wined3d_format_desc *sEntry, *dEntry;
 
     if (TRACE_ON(d3d_surface))
@@ -1843,5 +1893,5 @@
     else
     {
-        const struct GlPixelFormatDesc *format_desc = This->resource.format_desc;
+        const struct wined3d_format_desc *format_desc = This->resource.format_desc;
 
         TRACE("Lock Rect (%p) = l %d, t %d, r %d, b %d\n",
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/surface_gdi.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/surface_gdi.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/surface_gdi.c	(revision 28475)
@@ -250,5 +250,6 @@
     }
 
-    hr = IWineD3DSwapChain_Present((IWineD3DSwapChain *) swapchain, NULL, NULL, 0, NULL, 0);
+    hr = IWineD3DSwapChain_Present((IWineD3DSwapChain *)swapchain,
+            NULL, NULL, swapchain->win_handle, NULL, 0);
     IWineD3DSwapChain_Release((IWineD3DSwapChain *) swapchain);
     return hr;
@@ -306,7 +307,7 @@
     UINT y = 0, x = 0;
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
+    const struct wined3d_format_desc *format_desc = This->resource.format_desc;
     static char *output = NULL;
     static UINT size = 0;
-    const struct GlPixelFormatDesc *format_desc = This->resource.format_desc;
 
     if (This->pow2Width > size) {
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/swapchain.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/swapchain.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/swapchain.c	(revision 28475)
@@ -124,9 +124,9 @@
         gl_filter = GL_LINEAR;
 
-    if (gl_info->fbo_ops.glBlitFramebuffer)
+    if (gl_info->fbo_ops.glBlitFramebuffer && is_identity_fixup(backbuffer->resource.format_desc->color_fixup))
     {
         ENTER_GL();
         context_bind_fbo(context, GL_READ_FRAMEBUFFER, &context->src_fbo);
-        context_attach_surface_fbo(context, GL_READ_FRAMEBUFFER, 0, This->backBuffer[0]);
+        context_attach_surface_fbo(context, GL_READ_FRAMEBUFFER, 0, backbuffer);
         context_attach_depth_stencil_fbo(context, GL_READ_FRAMEBUFFER, NULL, FALSE);
 
@@ -162,4 +162,7 @@
         }
 
+        if (is_complex_fixup(backbuffer->resource.format_desc->color_fixup))
+            gl_filter = GL_NEAREST;
+
         ENTER_GL();
         context_bind_fbo(context2, GL_DRAW_FRAMEBUFFER, NULL);
@@ -168,9 +171,7 @@
          * so there are no d3d texture settings to dirtify
          */
-        device->blitter->set_shader((IWineD3DDevice *) device, backbuffer->resource.format_desc,
-                                    backbuffer->texture_target, backbuffer->pow2Width,
-                                    backbuffer->pow2Height);
-        glTexParameteri(backbuffer->texture_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-        glTexParameteri(backbuffer->texture_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+        device->blitter->set_shader((IWineD3DDevice *) device, backbuffer);
+        glTexParameteri(backbuffer->texture_target, GL_TEXTURE_MIN_FILTER, gl_filter);
+        glTexParameteri(backbuffer->texture_target, GL_TEXTURE_MAG_FILTER, gl_filter);
 
         context_set_draw_buffer(context, GL_BACK);
@@ -227,5 +228,13 @@
     int retval;
 
+    IWineD3DSwapChain_SetDestWindowOverride(iface, hDestWindowOverride);
+
     context = context_acquire(This->device, This->backBuffer[0], CTXUSAGE_RESOURCELOAD);
+    if (!context->valid)
+    {
+        context_release(context);
+        WARN("Invalid context, skipping present.\n");
+        return WINED3D_OK;
+    }
 
     /* Render the cursor onto the back buffer, using our nifty directdraw blitting code :-) */
@@ -257,8 +266,4 @@
         cursor.currentDesc.Width = This->device->cursorWidth;
         cursor.currentDesc.Height = This->device->cursorHeight;
-        cursor.glRect.left = 0;
-        cursor.glRect.top = 0;
-        cursor.glRect.right = cursor.currentDesc.Width;
-        cursor.glRect.bottom = cursor.currentDesc.Height;
         /* The cursor must have pow2 sizes */
         cursor.pow2Width = cursor.currentDesc.Width;
@@ -282,10 +287,5 @@
     }
 
-    TRACE("presetting HDC %p\n", This->context[0]->hdc);
-
-    /* Don't call checkGLcall, as glGetError is not applicable here */
-    if (hDestWindowOverride && This->win_handle != hDestWindowOverride) {
-        IWineD3DSwapChain_SetDestWindowOverride(iface, hDestWindowOverride);
-    }
+    TRACE("Presenting HDC %p.\n", context->hdc);
 
     render_to_fbo = This->render_to_fbo;
@@ -353,5 +353,6 @@
     }
 
-    SwapBuffers(This->context[0]->hdc); /* TODO: cycle through the swapchain buffers */
+    if (This->num_contexts > 1) wglFinish();
+    SwapBuffers(context->hdc); /* TODO: cycle through the swapchain buffers */
 
     TRACE("SwapBuffers called, Starting new frame\n");
@@ -526,45 +527,14 @@
 }
 
-static HRESULT WINAPI IWineD3DSwapChainImpl_SetDestWindowOverride(IWineD3DSwapChain *iface, HWND window) {
-    IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
-    WINED3DLOCKED_RECT r;
-    BYTE *mem;
-
-    if(window == This->win_handle) return WINED3D_OK;
-
-    TRACE("Performing dest override of swapchain %p from window %p to %p\n", This, This->win_handle, window);
-    if (This->context[0] == This->device->contexts[0])
-    {
-        /* The primary context 'owns' all the opengl resources. Destroying and recreating that context requires downloading
-         * all opengl resources, deleting the gl resources, destroying all other contexts, then recreating all other contexts
-         * and reload the resources
-         */
-        delete_opengl_contexts((IWineD3DDevice *)This->device, iface);
-        This->win_handle = window;
-        create_primary_opengl_context((IWineD3DDevice *)This->device, iface);
-    }
-    else
-    {
-        This->win_handle = window;
-
-        /* The old back buffer has to be copied over to the new back buffer. A lockrect - switchcontext - unlockrect
-         * would suffice in theory, but it is rather nasty and may cause troubles with future changes of the locking code
-         * So lock read only, copy the surface out, then lock with the discard flag and write back
-         */
-        IWineD3DSurface_LockRect(This->backBuffer[0], &r, NULL, WINED3DLOCK_READONLY);
-        mem = HeapAlloc(GetProcessHeap(), 0, r.Pitch * ((IWineD3DSurfaceImpl *) This->backBuffer[0])->currentDesc.Height);
-        memcpy(mem, r.pBits, r.Pitch * ((IWineD3DSurfaceImpl *) This->backBuffer[0])->currentDesc.Height);
-        IWineD3DSurface_UnlockRect(This->backBuffer[0]);
-
-        context_destroy(This->device, This->context[0]);
-        This->context[0] = context_create(This->device, (IWineD3DSurfaceImpl *)This->frontBuffer,
-                This->win_handle, FALSE /* pbuffer */, &This->presentParms);
-        context_release(This->context[0]);
-
-        IWineD3DSurface_LockRect(This->backBuffer[0], &r, NULL, WINED3DLOCK_DISCARD);
-        memcpy(r.pBits, mem, r.Pitch * ((IWineD3DSurfaceImpl *) This->backBuffer[0])->currentDesc.Height);
-        HeapFree(GetProcessHeap(), 0, mem);
-        IWineD3DSurface_UnlockRect(This->backBuffer[0]);
-    }
+static HRESULT WINAPI IWineD3DSwapChainImpl_SetDestWindowOverride(IWineD3DSwapChain *iface, HWND window)
+{
+    IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *)iface;
+
+    if (!window) window = swapchain->device_window;
+    if (window == swapchain->win_handle) return WINED3D_OK;
+
+    TRACE("Setting swapchain %p window from %p to %p\n", swapchain, swapchain->win_handle, window);
+    swapchain->win_handle = window;
+
     return WINED3D_OK;
 }
@@ -611,5 +581,5 @@
 {
     IWineD3DDeviceImpl *device = swapchain->device;
-    HWND window = swapchain->win_handle;
+    HWND window = swapchain->device_window;
     BOOL filter_messages;
     LONG style, exstyle;
@@ -645,5 +615,5 @@
 {
     IWineD3DDeviceImpl *device = swapchain->device;
-    HWND window = swapchain->win_handle;
+    HWND window = swapchain->device_window;
     BOOL filter_messages;
     LONG style, exstyle;
@@ -683,5 +653,5 @@
 {
     const struct wined3d_adapter *adapter = device->adapter;
-    const struct GlPixelFormatDesc *format_desc;
+    const struct wined3d_format_desc *format_desc;
     BOOL displaymode_set = FALSE;
     WINED3DDISPLAYMODE mode;
@@ -725,4 +695,5 @@
     swapchain->ref = 1;
     swapchain->win_handle = window;
+    swapchain->device_window = window;
 
     if (!present_parameters->Windowed && window)
@@ -828,6 +799,25 @@
     if (surface_type == SURFACE_OPENGL)
     {
-        swapchain->context[0] = context_create(device, (IWineD3DSurfaceImpl *)swapchain->frontBuffer,
-                window, FALSE /* pbuffer */, present_parameters);
+        const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
+
+        /* In WGL both color, depth and stencil are features of a pixel format. In case of D3D they are separate.
+         * You are able to add a depth + stencil surface at a later stage when you need it.
+         * In order to support this properly in WineD3D we need the ability to recreate the opengl context and
+         * drawable when this is required. This is very tricky as we need to reapply ALL opengl states for the new
+         * context, need torecreate shaders, textures and other resources.
+         *
+         * The context manager already takes care of the state problem and for the other tasks code from Reset
+         * can be used. These changes are way to risky during the 1.0 code freeze which is taking place right now.
+         * Likely a lot of other new bugs will be exposed. For that reason request a depth stencil surface all the
+         * time. It can cause a slight performance hit but fixes a lot of regressions. A fixme reminds of that this
+         * issue needs to be fixed. */
+        if (!present_parameters->EnableAutoDepthStencil
+                || swapchain->presentParms.AutoDepthStencilFormat != WINED3DFMT_D24_UNORM_S8_UINT)
+        {
+            FIXME("Add OpenGL context recreation support to context_validate_onscreen_formats\n");
+        }
+        swapchain->ds_format = getFormatDescEntry(WINED3DFMT_D24_UNORM_S8_UINT, gl_info);
+        swapchain->context[0] = context_create(swapchain, (IWineD3DSurfaceImpl *)swapchain->frontBuffer,
+                swapchain->ds_format);
         if (!swapchain->context[0])
         {
@@ -923,8 +913,13 @@
     }
 
-    if (swapchain->context && swapchain->context[0])
-    {
-        context_release(swapchain->context[0]);
-        context_destroy(device, swapchain->context[0]);
+    if (swapchain->context)
+    {
+        if (swapchain->context[0])
+        {
+            context_release(swapchain->context[0]);
+            context_destroy(device, swapchain->context[0]);
+            swapchain->num_contexts = 0;
+        }
+        HeapFree(GetProcessHeap(), 0, swapchain->context);
     }
 
@@ -942,7 +937,5 @@
     TRACE("Creating a new context for swapchain %p, thread %d\n", This, GetCurrentThreadId());
 
-    ctx = context_create(This->device, (IWineD3DSurfaceImpl *)This->frontBuffer,
-            This->context[0]->win_handle, FALSE /* pbuffer */, &This->presentParms);
-    if (!ctx)
+    if (!(ctx = context_create(This, (IWineD3DSurfaceImpl *)This->frontBuffer, This->ds_format)))
     {
         ERR("Failed to create a new context for the swapchain\n");
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/swapchain_base.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/swapchain_base.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/swapchain_base.c	(revision 28475)
@@ -181,7 +181,7 @@
     HDC hDC;
     TRACE("(%p) : pRamp@%p flags(%d)\n", This, pRamp, Flags);
-    hDC = GetDC(This->win_handle);
+    hDC = GetDC(This->device_window);
     SetDeviceGammaRamp(hDC, (LPVOID)pRamp);
-    ReleaseDC(This->win_handle, hDC);
+    ReleaseDC(This->device_window, hDC);
     return WINED3D_OK;
 
@@ -193,8 +193,8 @@
     HDC hDC;
     TRACE("(%p) : pRamp@%p\n", This, pRamp);
-    hDC = GetDC(This->win_handle);
+    hDC = GetDC(This->device_window);
     GetDeviceGammaRamp(hDC, pRamp);
-    ReleaseDC(This->win_handle, hDC);
-    return WINED3D_OK;
-
-}
+    ReleaseDC(This->device_window, hDC);
+    return WINED3D_OK;
+
+}
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/texture.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/texture.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/texture.c	(revision 28475)
@@ -444,5 +444,5 @@
 {
     const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
-    const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(format, gl_info);
+    const struct wined3d_format_desc *format_desc = getFormatDescEntry(format, gl_info);
     UINT pow2_width, pow2_height;
     UINT tmp_w, tmp_h;
@@ -580,5 +580,5 @@
         hr = IWineD3DDeviceParent_CreateSurface(device->device_parent, parent, tmp_w, tmp_h, format_desc->format,
                 usage, pool, i, WINED3DCUBEMAP_FACE_POSITIVE_X, &texture->surfaces[i]);
-        if (FAILED(hr) || ((IWineD3DSurfaceImpl *)texture->surfaces[i])->Flags & SFLAG_OVERSIZE)
+        if (FAILED(hr))
         {
             FIXME("Failed to create surface %p, hr %#x\n", texture, hr);
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/utils.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/utils.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/utils.c	(revision 28475)
@@ -151,29 +151,38 @@
 static const struct wined3d_format_base_flags format_base_flags[] =
 {
-    {WINED3DFMT_UYVY,           WINED3DFMT_FLAG_FOURCC},
-    {WINED3DFMT_YUY2,           WINED3DFMT_FLAG_FOURCC},
-    {WINED3DFMT_YV12,           WINED3DFMT_FLAG_FOURCC},
-    {WINED3DFMT_DXT1,           WINED3DFMT_FLAG_FOURCC},
-    {WINED3DFMT_DXT2,           WINED3DFMT_FLAG_FOURCC},
-    {WINED3DFMT_DXT3,           WINED3DFMT_FLAG_FOURCC},
-    {WINED3DFMT_DXT4,           WINED3DFMT_FLAG_FOURCC},
-    {WINED3DFMT_DXT5,           WINED3DFMT_FLAG_FOURCC},
-    {WINED3DFMT_MULTI2_ARGB8,   WINED3DFMT_FLAG_FOURCC},
-    {WINED3DFMT_G8R8_G8B8,      WINED3DFMT_FLAG_FOURCC},
-    {WINED3DFMT_R8G8_B8G8,      WINED3DFMT_FLAG_FOURCC},
-    {WINED3DFMT_P8_UINT,        WINED3DFMT_FLAG_GETDC},
-    {WINED3DFMT_B8G8R8_UNORM,   WINED3DFMT_FLAG_GETDC},
-    {WINED3DFMT_B8G8R8A8_UNORM, WINED3DFMT_FLAG_GETDC},
-    {WINED3DFMT_B8G8R8X8_UNORM, WINED3DFMT_FLAG_GETDC},
-    {WINED3DFMT_B5G6R5_UNORM,   WINED3DFMT_FLAG_GETDC},
-    {WINED3DFMT_B5G5R5X1_UNORM, WINED3DFMT_FLAG_GETDC},
-    {WINED3DFMT_B5G5R5A1_UNORM, WINED3DFMT_FLAG_GETDC},
-    {WINED3DFMT_B4G4R4A4_UNORM, WINED3DFMT_FLAG_GETDC},
-    {WINED3DFMT_B4G4R4X4_UNORM, WINED3DFMT_FLAG_GETDC},
-    {WINED3DFMT_R8G8B8A8_UNORM, WINED3DFMT_FLAG_GETDC},
-    {WINED3DFMT_R8G8B8X8_UNORM, WINED3DFMT_FLAG_GETDC},
-    {WINED3DFMT_ATI2N,          WINED3DFMT_FLAG_FOURCC},
-    {WINED3DFMT_NVHU,           WINED3DFMT_FLAG_FOURCC},
-    {WINED3DFMT_NVHS,           WINED3DFMT_FLAG_FOURCC},
+    {WINED3DFMT_UYVY,               WINED3DFMT_FLAG_FOURCC},
+    {WINED3DFMT_YUY2,               WINED3DFMT_FLAG_FOURCC},
+    {WINED3DFMT_YV12,               WINED3DFMT_FLAG_FOURCC},
+    {WINED3DFMT_DXT1,               WINED3DFMT_FLAG_FOURCC},
+    {WINED3DFMT_DXT2,               WINED3DFMT_FLAG_FOURCC},
+    {WINED3DFMT_DXT3,               WINED3DFMT_FLAG_FOURCC},
+    {WINED3DFMT_DXT4,               WINED3DFMT_FLAG_FOURCC},
+    {WINED3DFMT_DXT5,               WINED3DFMT_FLAG_FOURCC},
+    {WINED3DFMT_MULTI2_ARGB8,       WINED3DFMT_FLAG_FOURCC},
+    {WINED3DFMT_G8R8_G8B8,          WINED3DFMT_FLAG_FOURCC},
+    {WINED3DFMT_R8G8_B8G8,          WINED3DFMT_FLAG_FOURCC},
+    {WINED3DFMT_P8_UINT,            WINED3DFMT_FLAG_GETDC},
+    {WINED3DFMT_B8G8R8_UNORM,       WINED3DFMT_FLAG_GETDC},
+    {WINED3DFMT_B8G8R8A8_UNORM,     WINED3DFMT_FLAG_GETDC},
+    {WINED3DFMT_B8G8R8X8_UNORM,     WINED3DFMT_FLAG_GETDC},
+    {WINED3DFMT_B5G6R5_UNORM,       WINED3DFMT_FLAG_GETDC},
+    {WINED3DFMT_B5G5R5X1_UNORM,     WINED3DFMT_FLAG_GETDC},
+    {WINED3DFMT_B5G5R5A1_UNORM,     WINED3DFMT_FLAG_GETDC},
+    {WINED3DFMT_B4G4R4A4_UNORM,     WINED3DFMT_FLAG_GETDC},
+    {WINED3DFMT_B4G4R4X4_UNORM,     WINED3DFMT_FLAG_GETDC},
+    {WINED3DFMT_R8G8B8A8_UNORM,     WINED3DFMT_FLAG_GETDC},
+    {WINED3DFMT_R8G8B8X8_UNORM,     WINED3DFMT_FLAG_GETDC},
+    {WINED3DFMT_ATI2N,              WINED3DFMT_FLAG_FOURCC},
+    {WINED3DFMT_NVHU,               WINED3DFMT_FLAG_FOURCC},
+    {WINED3DFMT_NVHS,               WINED3DFMT_FLAG_FOURCC},
+    {WINED3DFMT_R32_FLOAT,          WINED3DFMT_FLAG_FLOAT},
+    {WINED3DFMT_R32G32_FLOAT,       WINED3DFMT_FLAG_FLOAT},
+    {WINED3DFMT_R32G32B32_FLOAT,    WINED3DFMT_FLAG_FLOAT},
+    {WINED3DFMT_R32G32B32A32_FLOAT, WINED3DFMT_FLAG_FLOAT},
+    {WINED3DFMT_R16_FLOAT,          WINED3DFMT_FLAG_FLOAT},
+    {WINED3DFMT_R16G16_FLOAT,       WINED3DFMT_FLAG_FLOAT},
+    {WINED3DFMT_R16G16B16A16_FLOAT, WINED3DFMT_FLAG_FLOAT},
+    {WINED3DFMT_D32_FLOAT,          WINED3DFMT_FLAG_FLOAT},
+    {WINED3DFMT_S8_UINT_D24_FLOAT,  WINED3DFMT_FLAG_FLOAT},
 };
 
@@ -193,5 +202,5 @@
     {WINED3DFMT_DXT4,   4,  4,  16},
     {WINED3DFMT_DXT5,   4,  4,  16},
-    {WINED3DFMT_ATI2N,  4,  4,  16},
+    {WINED3DFMT_ATI2N,  1,  1,  1},
 };
 
@@ -228,18 +237,326 @@
 };
 
-typedef struct {
-    WINED3DFORMAT           fmt;
-    GLint                   glInternal, glGammaInternal, rtInternal, glFormat, glType;
-    unsigned int            Flags;
+struct wined3d_format_texture_info
+{
+    WINED3DFORMAT format;
+    GLint gl_internal;
+    GLint gl_srgb_internal;
+    GLint gl_rt_internal;
+    GLint gl_format;
+    GLint gl_type;
+    unsigned int conv_byte_count;
+    unsigned int flags;
     GL_SupportedExt extension;
-} GlPixelFormatDescTemplate;
-
-/*****************************************************************************
- * OpenGL format template. Contains unexciting formats which do not need
- * extension checks. The order in this table is independent of the order in
- * the table StaticPixelFormatDesc above. Not all formats have to be in this
- * table.
- */
-static const GlPixelFormatDescTemplate gl_formats_template[] = {
+    void (*convert)(const BYTE *src, BYTE *dst, UINT pitch, UINT width, UINT height);
+};
+
+static void convert_l4a4_unorm(const BYTE *src, BYTE *dst, UINT pitch, UINT width, UINT height)
+{
+    /* WINED3DFMT_L4A4_UNORM exists as an internal gl format, but for some reason there is not
+     * format+type combination to load it. Thus convert it to A8L8, then load it
+     * with A4L4 internal, but A8L8 format+type
+     */
+    unsigned int x, y;
+    const unsigned char *Source;
+    unsigned char *Dest;
+    UINT outpitch = pitch * 2;
+
+    for(y = 0; y < height; y++) {
+        Source = src + y * pitch;
+        Dest = dst + y * outpitch;
+        for (x = 0; x < width; x++ ) {
+            unsigned char color = (*Source++);
+            /* A */ Dest[1] = (color & 0xf0) << 0;
+            /* L */ Dest[0] = (color & 0x0f) << 4;
+            Dest += 2;
+        }
+    }
+}
+
+static void convert_r5g5_snorm_l6_unorm(const BYTE *src, BYTE *dst, UINT pitch, UINT width, UINT height)
+{
+    unsigned int x, y;
+    const WORD *Source;
+
+    for(y = 0; y < height; y++)
+    {
+        unsigned short *Dest_s = (unsigned short *) (dst + y * pitch);
+        Source = (const WORD *)(src + y * pitch);
+        for (x = 0; x < width; x++ )
+        {
+            short color = (*Source++);
+            unsigned char l = ((color >> 10) & 0xfc);
+                    short v = ((color >>  5) & 0x3e);
+                    short u = ((color      ) & 0x1f);
+            short v_conv = v + 16;
+            short u_conv = u + 16;
+
+            *Dest_s = ((v_conv << 11) & 0xf800) | ((l << 5) & 0x7e0) | (u_conv & 0x1f);
+            Dest_s += 1;
+        }
+    }
+}
+
+static void convert_r5g5_snorm_l6_unorm_nv(const BYTE *src, BYTE *dst, UINT pitch, UINT width, UINT height)
+{
+    unsigned int x, y;
+    const WORD *Source;
+    unsigned char *Dest;
+    UINT outpitch = (pitch * 3)/2;
+
+    /* This makes the gl surface bigger(24 bit instead of 16), but it works with
+     * fixed function and shaders without further conversion once the surface is
+     * loaded
+     */
+    for(y = 0; y < height; y++) {
+        Source = (const WORD *)(src + y * pitch);
+        Dest = dst + y * outpitch;
+        for (x = 0; x < width; x++ ) {
+            short color = (*Source++);
+            unsigned char l = ((color >> 10) & 0xfc);
+                     char v = ((color >>  5) & 0x3e);
+                     char u = ((color      ) & 0x1f);
+
+            /* 8 bits destination, 6 bits source, 8th bit is the sign. gl ignores the sign
+             * and doubles the positive range. Thus shift left only once, gl does the 2nd
+             * shift. GL reads a signed value and converts it into an unsigned value.
+             */
+            /* M */ Dest[2] = l << 1;
+
+            /* Those are read as signed, but kept signed. Just left-shift 3 times to scale
+             * from 5 bit values to 8 bit values.
+             */
+            /* V */ Dest[1] = v << 3;
+            /* U */ Dest[0] = u << 3;
+            Dest += 3;
+        }
+    }
+}
+
+static void convert_r8g8_snorm(const BYTE *src, BYTE *dst, UINT pitch, UINT width, UINT height)
+{
+    unsigned int x, y;
+    const short *Source;
+    unsigned char *Dest;
+    UINT outpitch = (pitch * 3)/2;
+
+    for(y = 0; y < height; y++)
+    {
+        Source = (const short *)(src + y * pitch);
+        Dest = dst + y * outpitch;
+        for (x = 0; x < width; x++ )
+        {
+            long color = (*Source++);
+            /* B */ Dest[0] = 0xff;
+            /* G */ Dest[1] = (color >> 8) + 128; /* V */
+            /* R */ Dest[2] = (color) + 128;      /* U */
+            Dest += 3;
+        }
+    }
+}
+
+static void convert_r8g8_snorm_l8x8_unorm(const BYTE *src, BYTE *dst, UINT pitch, UINT width, UINT height)
+{
+    unsigned int x, y;
+    const DWORD *Source;
+    unsigned char *Dest;
+
+    /* Doesn't work correctly with the fixed function pipeline, but can work in
+     * shaders if the shader is adjusted. (There's no use for this format in gl's
+     * standard fixed function pipeline anyway).
+     */
+    for(y = 0; y < height; y++)
+    {
+        Source = (const DWORD *)(src + y * pitch);
+        Dest = dst + y * pitch;
+        for (x = 0; x < width; x++ )
+        {
+            long color = (*Source++);
+            /* B */ Dest[0] = ((color >> 16) & 0xff);       /* L */
+            /* G */ Dest[1] = ((color >> 8 ) & 0xff) + 128; /* V */
+            /* R */ Dest[2] = (color         & 0xff) + 128; /* U */
+            Dest += 4;
+        }
+    }
+}
+
+static void convert_r8g8_snorm_l8x8_unorm_nv(const BYTE *src, BYTE *dst, UINT pitch, UINT width, UINT height)
+{
+    unsigned int x, y;
+    const DWORD *Source;
+    unsigned char *Dest;
+
+    /* This implementation works with the fixed function pipeline and shaders
+     * without further modification after converting the surface.
+     */
+    for(y = 0; y < height; y++)
+    {
+        Source = (const DWORD *)(src + y * pitch);
+        Dest = dst + y * pitch;
+        for (x = 0; x < width; x++ )
+        {
+            long color = (*Source++);
+            /* L */ Dest[2] = ((color >> 16) & 0xff);   /* L */
+            /* V */ Dest[1] = ((color >> 8 ) & 0xff);   /* V */
+            /* U */ Dest[0] = (color         & 0xff);   /* U */
+            /* I */ Dest[3] = 255;                      /* X */
+            Dest += 4;
+        }
+    }
+}
+
+static void convert_r8g8b8a8_snorm(const BYTE *src, BYTE *dst, UINT pitch, UINT width, UINT height)
+{
+    unsigned int x, y;
+    const DWORD *Source;
+    unsigned char *Dest;
+
+    for(y = 0; y < height; y++)
+    {
+        Source = (const DWORD *)(src + y * pitch);
+        Dest = dst + y * pitch;
+        for (x = 0; x < width; x++ )
+        {
+            long color = (*Source++);
+            /* B */ Dest[0] = ((color >> 16) & 0xff) + 128; /* W */
+            /* G */ Dest[1] = ((color >> 8 ) & 0xff) + 128; /* V */
+            /* R */ Dest[2] = (color         & 0xff) + 128; /* U */
+            /* A */ Dest[3] = ((color >> 24) & 0xff) + 128; /* Q */
+            Dest += 4;
+        }
+    }
+}
+
+static void convert_r16g16_snorm(const BYTE *src, BYTE *dst, UINT pitch, UINT width, UINT height)
+{
+    unsigned int x, y;
+    const DWORD *Source;
+    unsigned short *Dest;
+    UINT outpitch = (pitch * 3)/2;
+
+    for(y = 0; y < height; y++)
+    {
+        Source = (const DWORD *)(src + y * pitch);
+        Dest = (unsigned short *) (dst + y * outpitch);
+        for (x = 0; x < width; x++ )
+        {
+            DWORD color = (*Source++);
+            /* B */ Dest[0] = 0xffff;
+            /* G */ Dest[1] = (color >> 16) + 32768; /* V */
+            /* R */ Dest[2] = (color      ) + 32768; /* U */
+            Dest += 3;
+        }
+    }
+}
+
+static void convert_r16g16(const BYTE *src, BYTE *dst, UINT pitch, UINT width, UINT height)
+{
+    unsigned int x, y;
+    const WORD *Source;
+    WORD *Dest;
+    UINT outpitch = (pitch * 3)/2;
+
+    for(y = 0; y < height; y++)
+    {
+        Source = (const WORD *)(src + y * pitch);
+        Dest = (WORD *) (dst + y * outpitch);
+        for (x = 0; x < width; x++ )
+        {
+            WORD green = (*Source++);
+            WORD red = (*Source++);
+            Dest[0] = green;
+            Dest[1] = red;
+            /* Strictly speaking not correct for R16G16F, but it doesn't matter because the
+             * shader overwrites it anyway
+             */
+            Dest[2] = 0xffff;
+            Dest += 3;
+        }
+    }
+}
+
+static void convert_r32g32_float(const BYTE *src, BYTE *dst, UINT pitch, UINT width, UINT height)
+{
+    unsigned int x, y;
+    const float *Source;
+    float *Dest;
+    UINT outpitch = (pitch * 3)/2;
+
+    for(y = 0; y < height; y++)
+    {
+        Source = (const float *)(src + y * pitch);
+        Dest = (float *) (dst + y * outpitch);
+        for (x = 0; x < width; x++ )
+        {
+            float green = (*Source++);
+            float red = (*Source++);
+            Dest[0] = green;
+            Dest[1] = red;
+            Dest[2] = 1.0f;
+            Dest += 3;
+        }
+    }
+}
+
+static void convert_s1_uint_d15_unorm(const BYTE *src, BYTE *dst, UINT pitch, UINT width, UINT height)
+{
+    unsigned int x, y;
+    UINT outpitch = pitch * 2;
+
+    for (y = 0; y < height; ++y)
+    {
+        const WORD *source = (const WORD *)(src + y * pitch);
+        DWORD *dest = (DWORD *)(dst + y * outpitch);
+
+        for (x = 0; x < width; ++x)
+        {
+            /* The depth data is normalized, so needs to be scaled,
+             * the stencil data isn't.  Scale depth data by
+             *      (2^24-1)/(2^15-1) ~~ (2^9 + 2^-6). */
+            WORD d15 = source[x] >> 1;
+            DWORD d24 = (d15 << 9) + (d15 >> 6);
+            dest[x] = (d24 << 8) | (source[x] & 0x1);
+        }
+    }
+}
+
+static void convert_s4x4_uint_d24_unorm(const BYTE *src, BYTE *dst, UINT pitch, UINT width, UINT height)
+{
+    unsigned int x, y;
+
+    for (y = 0; y < height; ++y)
+    {
+        const DWORD *source = (const DWORD *)(src + y * pitch);
+        DWORD *dest = (DWORD *)(dst + y * pitch);
+
+        for (x = 0; x < width; ++x)
+        {
+            /* Just need to clear out the X4 part. */
+            dest[x] = source[x] & ~0xf0;
+        }
+    }
+}
+
+static void convert_s8_uint_d24_float(const BYTE *src, BYTE *dst, UINT pitch, UINT width, UINT height)
+{
+    unsigned int x, y;
+    UINT outpitch = pitch * 2;
+
+    for (y = 0; y < height; ++y)
+    {
+        const DWORD *source = (const DWORD *)(src + y * pitch);
+        float *dest_f = (float *)(dst + y * outpitch);
+        DWORD *dest_s = (DWORD *)(dst + y * outpitch);
+
+        for (x = 0; x < width; ++x)
+        {
+            dest_f[x * 2] = float_24_to_32((source[x] & 0xffffff00) >> 8);
+            dest_s[x * 2 + 1] = source[x] & 0xff;
+        }
+    }
+}
+
+static const struct wined3d_format_texture_info format_texture_info[] =
+{
     /* WINED3DFORMAT                    internal                          srgbInternal                       rtInternal
             format                      type
@@ -254,287 +571,287 @@
      */
     {WINED3DFMT_UYVY,                   GL_LUMINANCE_ALPHA,               GL_LUMINANCE_ALPHA,                     0,
-            GL_LUMINANCE_ALPHA,         GL_UNSIGNED_BYTE,
+            GL_LUMINANCE_ALPHA,         GL_UNSIGNED_BYTE,                 0,
             WINED3DFMT_FLAG_FILTERING,
-            WINED3D_GL_EXT_NONE},
+            WINED3D_GL_EXT_NONE,        NULL},
     {WINED3DFMT_UYVY,                   GL_RGB,                           GL_RGB,                                 0,
-            GL_YCBCR_422_APPLE,         UNSIGNED_SHORT_8_8_APPLE,
+            GL_YCBCR_422_APPLE,         UNSIGNED_SHORT_8_8_APPLE,         0,
             WINED3DFMT_FLAG_FILTERING,
-            APPLE_YCBCR_422},
+            APPLE_YCBCR_422,            NULL},
     {WINED3DFMT_YUY2,                   GL_LUMINANCE_ALPHA,               GL_LUMINANCE_ALPHA,                     0,
-            GL_LUMINANCE_ALPHA,         GL_UNSIGNED_BYTE,
+            GL_LUMINANCE_ALPHA,         GL_UNSIGNED_BYTE,                 0,
             WINED3DFMT_FLAG_FILTERING,
-            WINED3D_GL_EXT_NONE},
+            WINED3D_GL_EXT_NONE,        NULL},
     {WINED3DFMT_YUY2,                   GL_RGB,                           GL_RGB,                                 0,
-            GL_YCBCR_422_APPLE,         UNSIGNED_SHORT_8_8_REV_APPLE,
+            GL_YCBCR_422_APPLE,         UNSIGNED_SHORT_8_8_REV_APPLE,     0,
             WINED3DFMT_FLAG_FILTERING,
-            APPLE_YCBCR_422},
+            APPLE_YCBCR_422,            NULL},
     {WINED3DFMT_YV12,                   GL_ALPHA,                         GL_ALPHA,                               0,
-            GL_ALPHA,                   GL_UNSIGNED_BYTE,
+            GL_ALPHA,                   GL_UNSIGNED_BYTE,                 0,
             WINED3DFMT_FLAG_FILTERING,
-            WINED3D_GL_EXT_NONE},
+            WINED3D_GL_EXT_NONE,        NULL},
     {WINED3DFMT_DXT1,                   GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, 0,
-            GL_RGBA,                    GL_UNSIGNED_BYTE,
+            GL_RGBA,                    GL_UNSIGNED_BYTE,                 0,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
-            EXT_TEXTURE_COMPRESSION_S3TC},
+            EXT_TEXTURE_COMPRESSION_S3TC, NULL},
     {WINED3DFMT_DXT2,                   GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, 0,
-            GL_RGBA,                    GL_UNSIGNED_BYTE,
+            GL_RGBA,                    GL_UNSIGNED_BYTE,                 0,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
-            EXT_TEXTURE_COMPRESSION_S3TC},
+            EXT_TEXTURE_COMPRESSION_S3TC, NULL},
     {WINED3DFMT_DXT3,                   GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, 0,
-            GL_RGBA,                    GL_UNSIGNED_BYTE,
+            GL_RGBA,                    GL_UNSIGNED_BYTE,                 0,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
-            EXT_TEXTURE_COMPRESSION_S3TC},
+            EXT_TEXTURE_COMPRESSION_S3TC, NULL},
     {WINED3DFMT_DXT4,                   GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, 0,
-            GL_RGBA,                    GL_UNSIGNED_BYTE,
+            GL_RGBA,                    GL_UNSIGNED_BYTE,                 0,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
-            EXT_TEXTURE_COMPRESSION_S3TC},
+            EXT_TEXTURE_COMPRESSION_S3TC, NULL},
     {WINED3DFMT_DXT5,                   GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, 0,
-            GL_RGBA,                    GL_UNSIGNED_BYTE,
+            GL_RGBA,                    GL_UNSIGNED_BYTE,                 0,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
-            EXT_TEXTURE_COMPRESSION_S3TC},
+            EXT_TEXTURE_COMPRESSION_S3TC, NULL},
     /* IEEE formats */
     {WINED3DFMT_R32_FLOAT,              GL_RGB32F_ARB,                    GL_RGB32F_ARB,                          0,
-            GL_RED,                     GL_FLOAT,
+            GL_RED,                     GL_FLOAT,                         0,
             WINED3DFMT_FLAG_RENDERTARGET,
-            ARB_TEXTURE_FLOAT},
+            ARB_TEXTURE_FLOAT,          NULL},
     {WINED3DFMT_R32_FLOAT,              GL_R32F,                          GL_R32F,                                0,
-            GL_RED,                     GL_FLOAT,
+            GL_RED,                     GL_FLOAT,                         0,
             WINED3DFMT_FLAG_RENDERTARGET,
-            ARB_TEXTURE_RG},
+            ARB_TEXTURE_RG,             NULL},
     {WINED3DFMT_R32G32_FLOAT,           GL_RGB32F_ARB,                    GL_RGB32F_ARB,                          0,
-            GL_RGB,                     GL_FLOAT,
+            GL_RGB,                     GL_FLOAT,                         12,
             WINED3DFMT_FLAG_RENDERTARGET,
-            ARB_TEXTURE_FLOAT},
+            ARB_TEXTURE_FLOAT,          &convert_r32g32_float},
     {WINED3DFMT_R32G32_FLOAT,           GL_RG32F,                         GL_RG32F,                               0,
-            GL_RG,                      GL_FLOAT,
+            GL_RG,                      GL_FLOAT,                         0,
             WINED3DFMT_FLAG_RENDERTARGET,
-            ARB_TEXTURE_RG},
+            ARB_TEXTURE_RG,             NULL},
     {WINED3DFMT_R32G32B32A32_FLOAT,     GL_RGBA32F_ARB,                   GL_RGBA32F_ARB,                         0,
-            GL_RGBA,                    GL_FLOAT,
+            GL_RGBA,                    GL_FLOAT,                         0,
             WINED3DFMT_FLAG_RENDERTARGET,
-            ARB_TEXTURE_FLOAT},
+            ARB_TEXTURE_FLOAT,          NULL},
     /* Float */
     {WINED3DFMT_R16_FLOAT,              GL_RGB16F_ARB,                    GL_RGB16F_ARB,                          0,
-            GL_RED,                     GL_HALF_FLOAT_ARB,
+            GL_RED,                     GL_HALF_FLOAT_ARB,                0,
             WINED3DFMT_FLAG_RENDERTARGET,
-            ARB_TEXTURE_FLOAT},
+            ARB_TEXTURE_FLOAT,          NULL},
     {WINED3DFMT_R16_FLOAT,              GL_R16F,                          GL_R16F,                                0,
-            GL_RED,                     GL_HALF_FLOAT_ARB,
+            GL_RED,                     GL_HALF_FLOAT_ARB,                0,
             WINED3DFMT_FLAG_RENDERTARGET,
-            ARB_TEXTURE_RG},
+            ARB_TEXTURE_RG,             NULL},
     {WINED3DFMT_R16G16_FLOAT,           GL_RGB16F_ARB,                    GL_RGB16F_ARB,                          0,
-            GL_RGB,                     GL_HALF_FLOAT_ARB,
+            GL_RGB,                     GL_HALF_FLOAT_ARB,                6,
             WINED3DFMT_FLAG_RENDERTARGET,
-            ARB_TEXTURE_FLOAT},
+            ARB_TEXTURE_FLOAT,          &convert_r16g16},
     {WINED3DFMT_R16G16_FLOAT,           GL_RG16F,                         GL_RG16F,                               0,
-            GL_RG,                      GL_HALF_FLOAT_ARB,
+            GL_RG,                      GL_HALF_FLOAT_ARB,                0,
             WINED3DFMT_FLAG_RENDERTARGET,
-            ARB_TEXTURE_RG},
+            ARB_TEXTURE_RG,             NULL},
     {WINED3DFMT_R16G16B16A16_FLOAT,     GL_RGBA16F_ARB,                   GL_RGBA16F_ARB,                         0,
-            GL_RGBA,                    GL_HALF_FLOAT_ARB,
+            GL_RGBA,                    GL_HALF_FLOAT_ARB,                0,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_RENDERTARGET,
-            ARB_TEXTURE_FLOAT},
+            ARB_TEXTURE_FLOAT,          NULL},
     /* Palettized formats */
     {WINED3DFMT_P8_UINT,                GL_RGBA,                          GL_RGBA,                                0,
-            GL_RGBA,                    GL_UNSIGNED_BYTE,
+            GL_ALPHA,                   GL_UNSIGNED_BYTE,                 0,
             0,
-            ARB_FRAGMENT_PROGRAM},
+            ARB_FRAGMENT_PROGRAM,       NULL},
     {WINED3DFMT_P8_UINT,                GL_COLOR_INDEX8_EXT,              GL_COLOR_INDEX8_EXT,                    0,
-            GL_COLOR_INDEX,             GL_UNSIGNED_BYTE,
+            GL_COLOR_INDEX,             GL_UNSIGNED_BYTE,                 0,
             0,
-            EXT_PALETTED_TEXTURE},
+            EXT_PALETTED_TEXTURE,       NULL},
     /* Standard ARGB formats */
     {WINED3DFMT_B8G8R8_UNORM,           GL_RGB8,                          GL_RGB8,                                0,
-            GL_BGR,                     GL_UNSIGNED_BYTE,
+            GL_BGR,                     GL_UNSIGNED_BYTE,                 0,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_RENDERTARGET,
-            WINED3D_GL_EXT_NONE},
+            WINED3D_GL_EXT_NONE,        NULL},
     {WINED3DFMT_B8G8R8A8_UNORM,         GL_RGBA8,                         GL_SRGB8_ALPHA8_EXT,                    0,
-            GL_BGRA,                    GL_UNSIGNED_INT_8_8_8_8_REV,
+            GL_BGRA,                    GL_UNSIGNED_INT_8_8_8_8_REV,      0,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_RENDERTARGET,
-            WINED3D_GL_EXT_NONE},
+            WINED3D_GL_EXT_NONE,        NULL},
     {WINED3DFMT_B8G8R8X8_UNORM,         GL_RGB8,                          GL_SRGB8_EXT,                           0,
-            GL_BGRA,                    GL_UNSIGNED_INT_8_8_8_8_REV,
+            GL_BGRA,                    GL_UNSIGNED_INT_8_8_8_8_REV,      0,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_RENDERTARGET,
-            WINED3D_GL_EXT_NONE},
+            WINED3D_GL_EXT_NONE,        NULL},
     {WINED3DFMT_B5G6R5_UNORM,           GL_RGB5,                          GL_RGB5,                          GL_RGB8,
-            GL_RGB,                     GL_UNSIGNED_SHORT_5_6_5,
+            GL_RGB,                     GL_UNSIGNED_SHORT_5_6_5,          0,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_RENDERTARGET,
-            WINED3D_GL_EXT_NONE},
+            WINED3D_GL_EXT_NONE,        NULL},
     {WINED3DFMT_B5G5R5X1_UNORM,         GL_RGB5,                          GL_RGB5_A1,                             0,
-            GL_BGRA,                    GL_UNSIGNED_SHORT_1_5_5_5_REV,
+            GL_BGRA,                    GL_UNSIGNED_SHORT_1_5_5_5_REV,    0,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
-            WINED3D_GL_EXT_NONE},
+            WINED3D_GL_EXT_NONE,        NULL},
     {WINED3DFMT_B5G5R5A1_UNORM,         GL_RGB5_A1,                       GL_RGB5_A1,                             0,
-            GL_BGRA,                    GL_UNSIGNED_SHORT_1_5_5_5_REV,
+            GL_BGRA,                    GL_UNSIGNED_SHORT_1_5_5_5_REV,    0,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
-            WINED3D_GL_EXT_NONE},
+            WINED3D_GL_EXT_NONE,        NULL},
     {WINED3DFMT_B4G4R4A4_UNORM,         GL_RGBA4,                         GL_SRGB8_ALPHA8_EXT,                    0,
-            GL_BGRA,                    GL_UNSIGNED_SHORT_4_4_4_4_REV,
+            GL_BGRA,                    GL_UNSIGNED_SHORT_4_4_4_4_REV,    0,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
-            WINED3D_GL_EXT_NONE},
+            WINED3D_GL_EXT_NONE,        NULL},
     {WINED3DFMT_B2G3R3_UNORM,           GL_R3_G3_B2,                      GL_R3_G3_B2,                            0,
-            GL_RGB,                     GL_UNSIGNED_BYTE_3_3_2,
+            GL_RGB,                     GL_UNSIGNED_BYTE_3_3_2,           0,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING,
-            WINED3D_GL_EXT_NONE},
+            WINED3D_GL_EXT_NONE,        NULL},
     {WINED3DFMT_A8_UNORM,               GL_ALPHA8,                        GL_ALPHA8,                              0,
-            GL_ALPHA,                   GL_UNSIGNED_BYTE,
+            GL_ALPHA,                   GL_UNSIGNED_BYTE,                 0,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING,
-            WINED3D_GL_EXT_NONE},
+            WINED3D_GL_EXT_NONE,        NULL},
     {WINED3DFMT_B4G4R4X4_UNORM,         GL_RGB4,                          GL_RGB4,                                0,
-            GL_BGRA,                    GL_UNSIGNED_SHORT_4_4_4_4_REV,
+            GL_BGRA,                    GL_UNSIGNED_SHORT_4_4_4_4_REV,    0,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
-            WINED3D_GL_EXT_NONE},
+            WINED3D_GL_EXT_NONE,        NULL},
     {WINED3DFMT_R10G10B10A2_UNORM,      GL_RGB10_A2,                      GL_RGB10_A2,                            0,
-            GL_RGBA,                    GL_UNSIGNED_INT_2_10_10_10_REV,
+            GL_RGBA,                    GL_UNSIGNED_INT_2_10_10_10_REV,   0,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
-            WINED3D_GL_EXT_NONE},
+            WINED3D_GL_EXT_NONE,        NULL},
     {WINED3DFMT_R8G8B8A8_UNORM,         GL_RGBA8,                         GL_RGBA8,                               0,
-            GL_RGBA,                    GL_UNSIGNED_INT_8_8_8_8_REV,
+            GL_RGBA,                    GL_UNSIGNED_INT_8_8_8_8_REV,      0,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
-            WINED3D_GL_EXT_NONE},
+            WINED3D_GL_EXT_NONE,        NULL},
     {WINED3DFMT_R8G8B8X8_UNORM,         GL_RGB8,                          GL_RGB8,                                0,
-            GL_RGBA,                    GL_UNSIGNED_INT_8_8_8_8_REV,
+            GL_RGBA,                    GL_UNSIGNED_INT_8_8_8_8_REV,      0,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
-            WINED3D_GL_EXT_NONE},
-    {WINED3DFMT_R16G16_UNORM,           GL_RGB16_EXT,                     GL_RGB16_EXT,               GL_RGBA16_EXT,
-            GL_RGB,                     GL_UNSIGNED_SHORT,
+            WINED3D_GL_EXT_NONE,        NULL},
+    {WINED3DFMT_R16G16_UNORM,           GL_RGB16,                         GL_RGB16,                       GL_RGBA16,
+            GL_RGB,                     GL_UNSIGNED_SHORT,                6,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
-            WINED3D_GL_EXT_NONE},
+            WINED3D_GL_EXT_NONE,        &convert_r16g16},
     {WINED3DFMT_B10G10R10A2_UNORM,      GL_RGB10_A2,                      GL_RGB10_A2,                            0,
-            GL_BGRA,                    GL_UNSIGNED_INT_2_10_10_10_REV,
+            GL_BGRA,                    GL_UNSIGNED_INT_2_10_10_10_REV,   0,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
-            WINED3D_GL_EXT_NONE},
-    {WINED3DFMT_R16G16B16A16_UNORM,     GL_RGBA16_EXT,                    GL_RGBA16_EXT,                          0,
-            GL_RGBA,                    GL_UNSIGNED_SHORT,
+            WINED3D_GL_EXT_NONE,        NULL},
+    {WINED3DFMT_R16G16B16A16_UNORM,     GL_RGBA16,                        GL_RGBA16,                              0,
+            GL_RGBA,                    GL_UNSIGNED_SHORT,                0,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_RENDERTARGET,
-            WINED3D_GL_EXT_NONE},
+            WINED3D_GL_EXT_NONE,        NULL},
     /* Luminance */
     {WINED3DFMT_L8_UNORM,               GL_LUMINANCE8,                    GL_SLUMINANCE8_EXT,                     0,
-            GL_LUMINANCE,               GL_UNSIGNED_BYTE,
+            GL_LUMINANCE,               GL_UNSIGNED_BYTE,                 0,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
-            WINED3D_GL_EXT_NONE},
+            WINED3D_GL_EXT_NONE,        NULL},
     {WINED3DFMT_L8A8_UNORM,             GL_LUMINANCE8_ALPHA8,             GL_SLUMINANCE8_ALPHA8_EXT,              0,
-            GL_LUMINANCE_ALPHA,         GL_UNSIGNED_BYTE,
+            GL_LUMINANCE_ALPHA,         GL_UNSIGNED_BYTE,                 0,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
-            WINED3D_GL_EXT_NONE},
+            WINED3D_GL_EXT_NONE,        NULL},
     {WINED3DFMT_L4A4_UNORM,             GL_LUMINANCE4_ALPHA4,             GL_LUMINANCE4_ALPHA4,                   0,
-            GL_LUMINANCE_ALPHA,         GL_UNSIGNED_BYTE,
+            GL_LUMINANCE_ALPHA,         GL_UNSIGNED_BYTE,                 2,
             0,
-            WINED3D_GL_EXT_NONE},
+            WINED3D_GL_EXT_NONE,        &convert_l4a4_unorm},
     /* Bump mapping stuff */
     {WINED3DFMT_R8G8_SNORM,             GL_RGB8,                          GL_RGB8,                                0,
-            GL_BGR,                     GL_UNSIGNED_BYTE,
+            GL_BGR,                     GL_UNSIGNED_BYTE,                 3,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
-            WINED3D_GL_EXT_NONE},
+            WINED3D_GL_EXT_NONE,        &convert_r8g8_snorm},
     {WINED3DFMT_R8G8_SNORM,             GL_DSDT8_NV,                      GL_DSDT8_NV,                            0,
-            GL_DSDT_NV,                 GL_BYTE,
+            GL_DSDT_NV,                 GL_BYTE,                          0,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
-            NV_TEXTURE_SHADER},
+            NV_TEXTURE_SHADER,          NULL},
     {WINED3DFMT_R5G5_SNORM_L6_UNORM,    GL_RGB5,                          GL_RGB5,                                0,
-            GL_RGB,                     GL_UNSIGNED_SHORT_5_6_5,
+            GL_RGB,                     GL_UNSIGNED_SHORT_5_6_5,          2,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
-            WINED3D_GL_EXT_NONE},
+            WINED3D_GL_EXT_NONE,        &convert_r5g5_snorm_l6_unorm},
     {WINED3DFMT_R5G5_SNORM_L6_UNORM,    GL_DSDT8_MAG8_NV,                 GL_DSDT8_MAG8_NV,                       0,
-            GL_DSDT_MAG_NV,             GL_BYTE,
+            GL_DSDT_MAG_NV,             GL_BYTE,                          3,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
-            NV_TEXTURE_SHADER},
+            NV_TEXTURE_SHADER,          &convert_r5g5_snorm_l6_unorm_nv},
     {WINED3DFMT_R8G8_SNORM_L8X8_UNORM,  GL_RGB8,                          GL_RGB8,                                0,
-            GL_BGRA,                    GL_UNSIGNED_INT_8_8_8_8_REV,
+            GL_BGRA,                    GL_UNSIGNED_INT_8_8_8_8_REV,      4,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
-            WINED3D_GL_EXT_NONE},
+            WINED3D_GL_EXT_NONE,        &convert_r8g8_snorm_l8x8_unorm},
     {WINED3DFMT_R8G8_SNORM_L8X8_UNORM,  GL_DSDT8_MAG8_INTENSITY8_NV,      GL_DSDT8_MAG8_INTENSITY8_NV,            0,
-            GL_DSDT_MAG_VIB_NV,         GL_UNSIGNED_INT_8_8_S8_S8_REV_NV,
+            GL_DSDT_MAG_VIB_NV,         GL_UNSIGNED_INT_8_8_S8_S8_REV_NV, 4,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
-            NV_TEXTURE_SHADER},
+            NV_TEXTURE_SHADER,          &convert_r8g8_snorm_l8x8_unorm_nv},
     {WINED3DFMT_R8G8B8A8_SNORM,         GL_RGBA8,                         GL_RGBA8,                               0,
-            GL_BGRA,                    GL_UNSIGNED_BYTE,
+            GL_BGRA,                    GL_UNSIGNED_BYTE,                 4,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
-            WINED3D_GL_EXT_NONE},
+            WINED3D_GL_EXT_NONE,        &convert_r8g8b8a8_snorm},
     {WINED3DFMT_R8G8B8A8_SNORM,         GL_SIGNED_RGBA8_NV,               GL_SIGNED_RGBA8_NV,                     0,
-            GL_RGBA,                    GL_BYTE,
+            GL_RGBA,                    GL_BYTE,                          0,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
-            NV_TEXTURE_SHADER},
-    {WINED3DFMT_R16G16_SNORM,           GL_RGB16_EXT,                     GL_RGB16_EXT,                           0,
-            GL_BGR,                     GL_UNSIGNED_SHORT,
+            NV_TEXTURE_SHADER,          NULL},
+    {WINED3DFMT_R16G16_SNORM,           GL_RGB16,                         GL_RGB16,                               0,
+            GL_BGR,                     GL_UNSIGNED_SHORT,                6,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
-            WINED3D_GL_EXT_NONE},
+            WINED3D_GL_EXT_NONE,        &convert_r16g16_snorm},
     {WINED3DFMT_R16G16_SNORM,           GL_SIGNED_HILO16_NV,              GL_SIGNED_HILO16_NV,                    0,
-            GL_HILO_NV,                 GL_SHORT,
+            GL_HILO_NV,                 GL_SHORT,                         0,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
-            NV_TEXTURE_SHADER},
+            NV_TEXTURE_SHADER,          NULL},
     /* Depth stencil formats */
     {WINED3DFMT_D16_LOCKABLE,           GL_DEPTH_COMPONENT24_ARB,         GL_DEPTH_COMPONENT24_ARB,               0,
-            GL_DEPTH_COMPONENT,         GL_UNSIGNED_SHORT,
+            GL_DEPTH_COMPONENT,         GL_UNSIGNED_SHORT,                0,
             WINED3DFMT_FLAG_DEPTH,
-            ARB_DEPTH_TEXTURE},
+            ARB_DEPTH_TEXTURE,          NULL},
     {WINED3DFMT_D32_UNORM,              GL_DEPTH_COMPONENT32_ARB,         GL_DEPTH_COMPONENT32_ARB,               0,
-            GL_DEPTH_COMPONENT,         GL_UNSIGNED_INT,
+            GL_DEPTH_COMPONENT,         GL_UNSIGNED_INT,                  0,
             WINED3DFMT_FLAG_DEPTH,
-            ARB_DEPTH_TEXTURE},
+            ARB_DEPTH_TEXTURE,          NULL},
     {WINED3DFMT_S1_UINT_D15_UNORM,      GL_DEPTH_COMPONENT24_ARB,         GL_DEPTH_COMPONENT24_ARB,               0,
-            GL_DEPTH_COMPONENT,         GL_UNSIGNED_SHORT,
+            GL_DEPTH_COMPONENT,         GL_UNSIGNED_SHORT,                0,
             WINED3DFMT_FLAG_DEPTH,
-            ARB_DEPTH_TEXTURE},
+            ARB_DEPTH_TEXTURE,          NULL},
     {WINED3DFMT_S1_UINT_D15_UNORM,      GL_DEPTH24_STENCIL8_EXT,          GL_DEPTH24_STENCIL8_EXT,                0,
-            GL_DEPTH_STENCIL_EXT,       GL_UNSIGNED_INT_24_8_EXT,
+            GL_DEPTH_STENCIL_EXT,       GL_UNSIGNED_INT_24_8_EXT,         4,
             WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL,
-            EXT_PACKED_DEPTH_STENCIL},
+            EXT_PACKED_DEPTH_STENCIL,   &convert_s1_uint_d15_unorm},
     {WINED3DFMT_S1_UINT_D15_UNORM,      GL_DEPTH24_STENCIL8,              GL_DEPTH24_STENCIL8,                    0,
-            GL_DEPTH_STENCIL,           GL_UNSIGNED_INT_24_8,
+            GL_DEPTH_STENCIL,           GL_UNSIGNED_INT_24_8,             4,
             WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL,
-            ARB_FRAMEBUFFER_OBJECT},
+            ARB_FRAMEBUFFER_OBJECT,     &convert_s1_uint_d15_unorm},
     {WINED3DFMT_D24_UNORM_S8_UINT,      GL_DEPTH_COMPONENT24_ARB,         GL_DEPTH_COMPONENT24_ARB,               0,
-            GL_DEPTH_COMPONENT,         GL_UNSIGNED_INT,
+            GL_DEPTH_COMPONENT,         GL_UNSIGNED_INT,                  0,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_DEPTH,
-            ARB_DEPTH_TEXTURE},
+            ARB_DEPTH_TEXTURE,          NULL},
     {WINED3DFMT_D24_UNORM_S8_UINT,      GL_DEPTH24_STENCIL8_EXT,          GL_DEPTH24_STENCIL8_EXT,                0,
-            GL_DEPTH_STENCIL_EXT,       GL_UNSIGNED_INT_24_8_EXT,
+            GL_DEPTH_STENCIL_EXT,       GL_UNSIGNED_INT_24_8_EXT,         0,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL,
-            EXT_PACKED_DEPTH_STENCIL},
+            EXT_PACKED_DEPTH_STENCIL,   NULL},
     {WINED3DFMT_D24_UNORM_S8_UINT,      GL_DEPTH24_STENCIL8,              GL_DEPTH24_STENCIL8,                    0,
-            GL_DEPTH_STENCIL,           GL_UNSIGNED_INT_24_8,
+            GL_DEPTH_STENCIL,           GL_UNSIGNED_INT_24_8,             0,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL,
-            ARB_FRAMEBUFFER_OBJECT},
+            ARB_FRAMEBUFFER_OBJECT,     NULL},
     {WINED3DFMT_X8D24_UNORM,            GL_DEPTH_COMPONENT24_ARB,         GL_DEPTH_COMPONENT24_ARB,               0,
-            GL_DEPTH_COMPONENT,         GL_UNSIGNED_INT,
+            GL_DEPTH_COMPONENT,         GL_UNSIGNED_INT,                  0,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_DEPTH,
-            ARB_DEPTH_TEXTURE},
+            ARB_DEPTH_TEXTURE,          NULL},
     {WINED3DFMT_S4X4_UINT_D24_UNORM,    GL_DEPTH_COMPONENT24_ARB,         GL_DEPTH_COMPONENT24_ARB,               0,
-            GL_DEPTH_COMPONENT,         GL_UNSIGNED_INT,
+            GL_DEPTH_COMPONENT,         GL_UNSIGNED_INT,                  0,
             WINED3DFMT_FLAG_DEPTH,
-            ARB_DEPTH_TEXTURE},
+            ARB_DEPTH_TEXTURE,          NULL},
     {WINED3DFMT_S4X4_UINT_D24_UNORM,    GL_DEPTH24_STENCIL8_EXT,          GL_DEPTH24_STENCIL8_EXT,                0,
-            GL_DEPTH_STENCIL_EXT,       GL_UNSIGNED_INT_24_8_EXT,
+            GL_DEPTH_STENCIL_EXT,       GL_UNSIGNED_INT_24_8_EXT,         4,
             WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL,
-            EXT_PACKED_DEPTH_STENCIL},
+            EXT_PACKED_DEPTH_STENCIL,   &convert_s4x4_uint_d24_unorm},
     {WINED3DFMT_S4X4_UINT_D24_UNORM,    GL_DEPTH24_STENCIL8,              GL_DEPTH24_STENCIL8,                    0,
-            GL_DEPTH_STENCIL,           GL_UNSIGNED_INT_24_8,
+            GL_DEPTH_STENCIL,           GL_UNSIGNED_INT_24_8,             4,
             WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL,
-            ARB_FRAMEBUFFER_OBJECT},
+            ARB_FRAMEBUFFER_OBJECT,     &convert_s4x4_uint_d24_unorm},
     {WINED3DFMT_D16_UNORM,              GL_DEPTH_COMPONENT24_ARB,         GL_DEPTH_COMPONENT24_ARB,               0,
-            GL_DEPTH_COMPONENT,         GL_UNSIGNED_SHORT,
+            GL_DEPTH_COMPONENT,         GL_UNSIGNED_SHORT,                0,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_DEPTH,
-            ARB_DEPTH_TEXTURE},
-    {WINED3DFMT_L16_UNORM,              GL_LUMINANCE16_EXT,               GL_LUMINANCE16_EXT,                     0,
-            GL_LUMINANCE,               GL_UNSIGNED_SHORT,
+            ARB_DEPTH_TEXTURE,          NULL},
+    {WINED3DFMT_L16_UNORM,              GL_LUMINANCE16,                   GL_LUMINANCE16,                         0,
+            GL_LUMINANCE,               GL_UNSIGNED_SHORT,                0,
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
-            WINED3D_GL_EXT_NONE},
+            WINED3D_GL_EXT_NONE,        NULL},
     {WINED3DFMT_D32_FLOAT,              GL_DEPTH_COMPONENT32F,            GL_DEPTH_COMPONENT32F,                  0,
-            GL_DEPTH_COMPONENT,         GL_FLOAT,
+            GL_DEPTH_COMPONENT,         GL_FLOAT,                         0,
             WINED3DFMT_FLAG_DEPTH,
-            ARB_DEPTH_BUFFER_FLOAT},
+            ARB_DEPTH_BUFFER_FLOAT,     NULL},
     {WINED3DFMT_S8_UINT_D24_FLOAT,      GL_DEPTH32F_STENCIL8,             GL_DEPTH32F_STENCIL8,                   0,
-            GL_DEPTH_STENCIL,           GL_FLOAT_32_UNSIGNED_INT_24_8_REV,
+            GL_DEPTH_STENCIL,           GL_FLOAT_32_UNSIGNED_INT_24_8_REV, 8,
             WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL,
-            ARB_DEPTH_BUFFER_FLOAT},
+            ARB_DEPTH_BUFFER_FLOAT,     &convert_s8_uint_d24_float},
     /* Vendor-specific formats */
     {WINED3DFMT_ATI2N,                  GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI, GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI, 0,
-            GL_LUMINANCE_ALPHA,         GL_UNSIGNED_BYTE,
+            GL_LUMINANCE_ALPHA,         GL_UNSIGNED_BYTE,                 0,
             0,
-            ATI_TEXTURE_COMPRESSION_3DC},
+            ATI_TEXTURE_COMPRESSION_3DC, NULL},
     {WINED3DFMT_ATI2N,                  GL_COMPRESSED_RED_GREEN_RGTC2_EXT, GL_COMPRESSED_RED_GREEN_RGTC2_EXT,     0,
-            GL_LUMINANCE_ALPHA,         GL_UNSIGNED_BYTE,
+            GL_LUMINANCE_ALPHA,         GL_UNSIGNED_BYTE,                 0,
             0,
-            EXT_TEXTURE_COMPRESSION_RGTC},
+            EXT_TEXTURE_COMPRESSION_RGTC, NULL},
 };
 
@@ -570,5 +887,5 @@
     for (i = 0; i < format_count; ++i)
     {
-        struct GlPixelFormatDesc *desc = &gl_info->gl_formats[i];
+        struct wined3d_format_desc *desc = &gl_info->gl_formats[i];
         desc->format = formats[i].format;
         desc->red_mask = formats[i].redMask;
@@ -605,5 +922,5 @@
     for (i = 0; i < (sizeof(format_compression_info) / sizeof(*format_compression_info)); ++i)
     {
-        struct GlPixelFormatDesc *format_desc;
+        struct wined3d_format_desc *format_desc;
         int fmt_idx = getFmtIdx(format_compression_info[i].format);
 
@@ -626,5 +943,5 @@
 
 /* Context activation is done by the caller. */
-static void check_fbo_compat(const struct wined3d_gl_info *gl_info, struct GlPixelFormatDesc *format_desc)
+static void check_fbo_compat(const struct wined3d_gl_info *gl_info, struct wined3d_format_desc *format_desc)
 {
     /* Check if the default internal format is supported as a frame buffer
@@ -765,5 +1082,5 @@
     for (i = 0; i < sizeof(formats) / sizeof(*formats); ++i)
     {
-        struct GlPixelFormatDesc *desc = &gl_info->gl_formats[i];
+        struct wined3d_format_desc *desc = &gl_info->gl_formats[i];
 
         if (!desc->glInternal) continue;
@@ -808,27 +1125,31 @@
     unsigned int i;
 
-    for (i = 0; i < sizeof(gl_formats_template) / sizeof(gl_formats_template[0]); ++i)
-    {
-        int fmt_idx = getFmtIdx(gl_formats_template[i].fmt);
-        struct GlPixelFormatDesc *desc;
+    for (i = 0; i < sizeof(format_texture_info) / sizeof(*format_texture_info); ++i)
+    {
+        int fmt_idx = getFmtIdx(format_texture_info[i].format);
+        struct wined3d_format_desc *desc;
 
         if (fmt_idx == -1)
         {
             ERR("Format %s (%#x) not found.\n",
-                    debug_d3dformat(gl_formats_template[i].fmt), gl_formats_template[i].fmt);
+                    debug_d3dformat(format_texture_info[i].format), format_texture_info[i].format);
             return FALSE;
         }
 
-        if (!gl_info->supported[gl_formats_template[i].extension]) continue;
+        if (!gl_info->supported[format_texture_info[i].extension]) continue;
 
         desc = &gl_info->gl_formats[fmt_idx];
-        desc->glInternal = gl_formats_template[i].glInternal;
-        desc->glGammaInternal = gl_formats_template[i].glGammaInternal;
-        desc->rtInternal = gl_formats_template[i].rtInternal;
-        desc->glFormat = gl_formats_template[i].glFormat;
-        desc->glType = gl_formats_template[i].glType;
+        desc->glInternal = format_texture_info[i].gl_internal;
+        desc->glGammaInternal = format_texture_info[i].gl_srgb_internal;
+        desc->rtInternal = format_texture_info[i].gl_rt_internal;
+        desc->glFormat = format_texture_info[i].gl_format;
+        desc->glType = format_texture_info[i].gl_type;
         desc->color_fixup = COLOR_FIXUP_IDENTITY;
-        desc->Flags |= gl_formats_template[i].Flags;
+        desc->Flags |= format_texture_info[i].flags;
         desc->heightscale = 1.0f;
+
+        /* Texture conversion stuff */
+        desc->convert = format_texture_info[i].convert;
+        desc->conv_byte_count = format_texture_info[i].conv_byte_count;
     }
 
@@ -948,4 +1269,5 @@
 static void init_format_filter_info(struct wined3d_gl_info *gl_info, enum wined3d_pci_vendor vendor)
 {
+    struct wined3d_format_desc *desc;
     unsigned int fmt_idx, i;
     WINED3DFORMAT fmts16[] = {
@@ -955,10 +1277,9 @@
     };
     BOOL filtered;
-    struct GlPixelFormatDesc *desc;
 
     if(wined3d_settings.offscreen_rendering_mode != ORM_FBO)
     {
         WARN("No FBO support, or no FBO ORM, guessing filter info from GL caps\n");
-        if (vendor == VENDOR_NVIDIA && gl_info->supported[ARB_TEXTURE_FLOAT])
+        if (vendor == HW_VENDOR_NVIDIA && gl_info->supported[ARB_TEXTURE_FLOAT])
         {
             TRACE("Nvidia card with texture_float support: Assuming float16 blending\n");
@@ -1053,4 +1374,5 @@
         gl_info->gl_formats[idx].color_fixup = create_color_fixup_desc(
                 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
+
         idx = getFmtIdx(WINED3DFMT_R16G16_SNORM);
         gl_info->gl_formats[idx].color_fixup = create_color_fixup_desc(
@@ -1098,15 +1420,21 @@
     {
         idx = getFmtIdx(WINED3DFMT_YUY2);
-        gl_info->gl_formats[idx].color_fixup = create_yuv_fixup_desc(YUV_FIXUP_YUY2);
+        gl_info->gl_formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_YUY2);
 
         idx = getFmtIdx(WINED3DFMT_UYVY);
-        gl_info->gl_formats[idx].color_fixup = create_yuv_fixup_desc(YUV_FIXUP_UYVY);
+        gl_info->gl_formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_UYVY);
     }
 
     idx = getFmtIdx(WINED3DFMT_YV12);
     gl_info->gl_formats[idx].heightscale = 1.5f;
-    gl_info->gl_formats[idx].color_fixup = create_yuv_fixup_desc(YUV_FIXUP_YV12);
-
-    if (gl_info->supported[EXT_VERTEX_ARRAY_BGRA])
+    gl_info->gl_formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_YV12);
+
+    if (gl_info->supported[EXT_PALETTED_TEXTURE] || gl_info->supported[ARB_FRAGMENT_PROGRAM])
+    {
+        idx = getFmtIdx(WINED3DFMT_P8_UINT);
+        gl_info->gl_formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_P8);
+    }
+
+    if (gl_info->supported[ARB_VERTEX_ARRAY_BGRA])
     {
         idx = getFmtIdx(WINED3DFMT_B8G8R8A8_UNORM);
@@ -1132,5 +1460,5 @@
     for (i = 0; i < (sizeof(format_vertex_info) / sizeof(*format_vertex_info)); ++i)
     {
-        struct GlPixelFormatDesc *format_desc;
+        struct wined3d_format_desc *format_desc;
         int fmt_idx = getFmtIdx(format_vertex_info[i].format);
 
@@ -1189,5 +1517,5 @@
 }
 
-const struct GlPixelFormatDesc *getFormatDescEntry(WINED3DFORMAT fmt, const struct wined3d_gl_info *gl_info)
+const struct wined3d_format_desc *getFormatDescEntry(WINED3DFORMAT fmt, const struct wined3d_gl_info *gl_info)
 {
     int idx = getFmtIdx(fmt);
@@ -1492,7 +1820,5 @@
   switch (state) {
 #define D3DSTATE_TO_STR(u) case u: return #u
-    D3DSTATE_TO_STR(WINED3DRS_TEXTUREHANDLE             );
     D3DSTATE_TO_STR(WINED3DRS_ANTIALIAS                 );
-    D3DSTATE_TO_STR(WINED3DRS_TEXTUREADDRESS            );
     D3DSTATE_TO_STR(WINED3DRS_TEXTUREPERSPECTIVE        );
     D3DSTATE_TO_STR(WINED3DRS_WRAPU                     );
@@ -1508,9 +1834,6 @@
     D3DSTATE_TO_STR(WINED3DRS_ALPHATESTENABLE           );
     D3DSTATE_TO_STR(WINED3DRS_LASTPIXEL                 );
-    D3DSTATE_TO_STR(WINED3DRS_TEXTUREMAG                );
-    D3DSTATE_TO_STR(WINED3DRS_TEXTUREMIN                );
     D3DSTATE_TO_STR(WINED3DRS_SRCBLEND                  );
     D3DSTATE_TO_STR(WINED3DRS_DESTBLEND                 );
-    D3DSTATE_TO_STR(WINED3DRS_TEXTUREMAPBLEND           );
     D3DSTATE_TO_STR(WINED3DRS_CULLMODE                  );
     D3DSTATE_TO_STR(WINED3DRS_ZFUNC                     );
@@ -1533,7 +1856,4 @@
     D3DSTATE_TO_STR(WINED3DRS_EDGEANTIALIAS             );
     D3DSTATE_TO_STR(WINED3DRS_COLORKEYENABLE            );
-    D3DSTATE_TO_STR(WINED3DRS_BORDERCOLOR               );
-    D3DSTATE_TO_STR(WINED3DRS_TEXTUREADDRESSU           );
-    D3DSTATE_TO_STR(WINED3DRS_TEXTUREADDRESSV           );
     D3DSTATE_TO_STR(WINED3DRS_MIPMAPLODBIAS             );
     D3DSTATE_TO_STR(WINED3DRS_ZBIAS                     );
@@ -1551,36 +1871,4 @@
     D3DSTATE_TO_STR(WINED3DRS_STENCILWRITEMASK          );
     D3DSTATE_TO_STR(WINED3DRS_TEXTUREFACTOR             );
-    D3DSTATE_TO_STR(WINED3DRS_STIPPLEPATTERN00          );
-    D3DSTATE_TO_STR(WINED3DRS_STIPPLEPATTERN01          );
-    D3DSTATE_TO_STR(WINED3DRS_STIPPLEPATTERN02          );
-    D3DSTATE_TO_STR(WINED3DRS_STIPPLEPATTERN03          );
-    D3DSTATE_TO_STR(WINED3DRS_STIPPLEPATTERN04          );
-    D3DSTATE_TO_STR(WINED3DRS_STIPPLEPATTERN05          );
-    D3DSTATE_TO_STR(WINED3DRS_STIPPLEPATTERN06          );
-    D3DSTATE_TO_STR(WINED3DRS_STIPPLEPATTERN07          );
-    D3DSTATE_TO_STR(WINED3DRS_STIPPLEPATTERN08          );
-    D3DSTATE_TO_STR(WINED3DRS_STIPPLEPATTERN09          );
-    D3DSTATE_TO_STR(WINED3DRS_STIPPLEPATTERN10          );
-    D3DSTATE_TO_STR(WINED3DRS_STIPPLEPATTERN11          );
-    D3DSTATE_TO_STR(WINED3DRS_STIPPLEPATTERN12          );
-    D3DSTATE_TO_STR(WINED3DRS_STIPPLEPATTERN13          );
-    D3DSTATE_TO_STR(WINED3DRS_STIPPLEPATTERN14          );
-    D3DSTATE_TO_STR(WINED3DRS_STIPPLEPATTERN15          );
-    D3DSTATE_TO_STR(WINED3DRS_STIPPLEPATTERN16          );
-    D3DSTATE_TO_STR(WINED3DRS_STIPPLEPATTERN17          );
-    D3DSTATE_TO_STR(WINED3DRS_STIPPLEPATTERN18          );
-    D3DSTATE_TO_STR(WINED3DRS_STIPPLEPATTERN19          );
-    D3DSTATE_TO_STR(WINED3DRS_STIPPLEPATTERN20          );
-    D3DSTATE_TO_STR(WINED3DRS_STIPPLEPATTERN21          );
-    D3DSTATE_TO_STR(WINED3DRS_STIPPLEPATTERN22          );
-    D3DSTATE_TO_STR(WINED3DRS_STIPPLEPATTERN23          );
-    D3DSTATE_TO_STR(WINED3DRS_STIPPLEPATTERN24          );
-    D3DSTATE_TO_STR(WINED3DRS_STIPPLEPATTERN25          );
-    D3DSTATE_TO_STR(WINED3DRS_STIPPLEPATTERN26          );
-    D3DSTATE_TO_STR(WINED3DRS_STIPPLEPATTERN27          );
-    D3DSTATE_TO_STR(WINED3DRS_STIPPLEPATTERN28          );
-    D3DSTATE_TO_STR(WINED3DRS_STIPPLEPATTERN29          );
-    D3DSTATE_TO_STR(WINED3DRS_STIPPLEPATTERN30          );
-    D3DSTATE_TO_STR(WINED3DRS_STIPPLEPATTERN31          );
     D3DSTATE_TO_STR(WINED3DRS_WRAP0                     );
     D3DSTATE_TO_STR(WINED3DRS_WRAP1                     );
@@ -1796,4 +2084,49 @@
 }
 
+const char *debug_d3dstate(DWORD state)
+{
+    if (STATE_IS_RENDER(state))
+        return wine_dbg_sprintf("STATE_RENDER(%s)", debug_d3drenderstate(state - STATE_RENDER(0)));
+    if (STATE_IS_TEXTURESTAGE(state))
+    {
+        DWORD texture_stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
+        DWORD texture_state = state - STATE_TEXTURESTAGE(texture_stage, 0);
+        return wine_dbg_sprintf("STATE_TEXTURESTAGE(%#x, %s)",
+                texture_stage, debug_d3dtexturestate(texture_state));
+    }
+    if (STATE_IS_SAMPLER(state))
+        return wine_dbg_sprintf("STATE_SAMPLER(%#x)", state - STATE_SAMPLER(0));
+    if (STATE_IS_PIXELSHADER(state))
+        return "STATE_PIXELSHADER";
+    if (STATE_IS_TRANSFORM(state))
+        return wine_dbg_sprintf("STATE_TRANSFORM(%s)", debug_d3dtstype(state - STATE_TRANSFORM(0)));
+    if (STATE_IS_STREAMSRC(state))
+        return "STATE_STREAMSRC";
+    if (STATE_IS_INDEXBUFFER(state))
+        return "STATE_INDEXBUFFER";
+    if (STATE_IS_VDECL(state))
+        return "STATE_VDECL";
+    if (STATE_IS_VSHADER(state))
+        return "STATE_VSHADER";
+    if (STATE_IS_VIEWPORT(state))
+        return "STATE_VIEWPORT";
+    if (STATE_IS_VERTEXSHADERCONSTANT(state))
+        return "STATE_VERTEXSHADERCONSTANT";
+    if (STATE_IS_PIXELSHADERCONSTANT(state))
+        return "STATE_PIXELSHADERCONSTANT";
+    if (STATE_IS_ACTIVELIGHT(state))
+        return wine_dbg_sprintf("STATE_ACTIVELIGHT(%#x)", state - STATE_ACTIVELIGHT(0));
+    if (STATE_IS_SCISSORRECT(state))
+        return "STATE_SCISSORRECT";
+    if (STATE_IS_CLIPPLANE(state))
+        return wine_dbg_sprintf("STATE_CLIPPLANE(%#x)", state - STATE_CLIPPLANE(0));
+    if (STATE_IS_MATERIAL(state))
+        return "STATE_MATERIAL";
+    if (STATE_IS_FRONTFACE(state))
+        return "STATE_FRONTFACE";
+
+    return wine_dbg_sprintf("UNKNOWN_STATE(%#x)", state);
+}
+
 const char* debug_d3dpool(WINED3DPOOL Pool) {
   switch (Pool) {
@@ -1878,6 +2211,6 @@
         WINED3D_TO_STR(CHANNEL_SOURCE_Z);
         WINED3D_TO_STR(CHANNEL_SOURCE_W);
-        WINED3D_TO_STR(CHANNEL_SOURCE_YUV0);
-        WINED3D_TO_STR(CHANNEL_SOURCE_YUV1);
+        WINED3D_TO_STR(CHANNEL_SOURCE_COMPLEX0);
+        WINED3D_TO_STR(CHANNEL_SOURCE_COMPLEX1);
 #undef WINED3D_TO_STR
         default:
@@ -1887,15 +2220,16 @@
 }
 
-static const char *debug_yuv_fixup(enum yuv_fixup yuv_fixup)
-{
-    switch(yuv_fixup)
+static const char *debug_complex_fixup(enum complex_fixup fixup)
+{
+    switch(fixup)
     {
 #define WINED3D_TO_STR(x) case x: return #x
-        WINED3D_TO_STR(YUV_FIXUP_YUY2);
-        WINED3D_TO_STR(YUV_FIXUP_UYVY);
-        WINED3D_TO_STR(YUV_FIXUP_YV12);
+        WINED3D_TO_STR(COMPLEX_FIXUP_YUY2);
+        WINED3D_TO_STR(COMPLEX_FIXUP_UYVY);
+        WINED3D_TO_STR(COMPLEX_FIXUP_YV12);
+        WINED3D_TO_STR(COMPLEX_FIXUP_P8);
 #undef WINED3D_TO_STR
         default:
-            FIXME("Unrecognized YUV fixup %#x\n", yuv_fixup);
+            FIXME("Unrecognized complex fixup %#x\n", fixup);
             return "unrecognized";
     }
@@ -1904,7 +2238,7 @@
 void dump_color_fixup_desc(struct color_fixup_desc fixup)
 {
-    if (is_yuv_fixup(fixup))
-    {
-        TRACE("\tYUV: %s\n", debug_yuv_fixup(get_yuv_fixup(fixup)));
+    if (is_complex_fixup(fixup))
+    {
+        TRACE("\tComplex: %s\n", debug_complex_fixup(get_complex_fixup(fixup)));
         return;
     }
@@ -2086,5 +2420,5 @@
 /* Helper function for retrieving color info for ChoosePixelFormat and wglChoosePixelFormatARB.
  * The later function requires individual color components. */
-BOOL getColorBits(const struct GlPixelFormatDesc *format_desc,
+BOOL getColorBits(const struct wined3d_format_desc *format_desc,
         short *redSize, short *greenSize, short *blueSize, short *alphaSize, short *totalSize)
 {
@@ -2123,5 +2457,5 @@
 
 /* Helper function for retrieving depth/stencil info for ChoosePixelFormat and wglChoosePixelFormatARB */
-BOOL getDepthStencilBits(const struct GlPixelFormatDesc *format_desc, short *depthSize, short *stencilSize)
+BOOL getDepthStencilBits(const struct wined3d_format_desc *format_desc, short *depthSize, short *stencilSize)
 {
     TRACE("fmt: %s\n", debug_d3dformat(format_desc->format));
@@ -2149,4 +2483,113 @@
             *depthSize, *stencilSize, debug_d3dformat(format_desc->format));
     return TRUE;
+}
+
+DWORD color_convert_argb_to_fmt(DWORD color, WINED3DFORMAT destfmt)
+{
+    unsigned int r, g, b, a;
+    DWORD ret;
+
+    if (destfmt == WINED3DFMT_B8G8R8A8_UNORM
+            || destfmt == WINED3DFMT_B8G8R8X8_UNORM
+            || destfmt == WINED3DFMT_B8G8R8_UNORM)
+        return color;
+
+    TRACE("Converting color %08x to format %s\n", color, debug_d3dformat(destfmt));
+
+    a = (color & 0xff000000) >> 24;
+    r = (color & 0x00ff0000) >> 16;
+    g = (color & 0x0000ff00) >>  8;
+    b = (color & 0x000000ff) >>  0;
+
+    switch(destfmt)
+    {
+        case WINED3DFMT_B5G6R5_UNORM:
+            if(r == 0xff && g == 0xff && b == 0xff) return 0xffff;
+            r = (r * 32) / 256;
+            g = (g * 64) / 256;
+            b = (b * 32) / 256;
+            ret  = r << 11;
+            ret |= g << 5;
+            ret |= b;
+            TRACE("Returning %08x\n", ret);
+            return ret;
+
+        case WINED3DFMT_B5G5R5X1_UNORM:
+        case WINED3DFMT_B5G5R5A1_UNORM:
+            a = (a *  2) / 256;
+            r = (r * 32) / 256;
+            g = (g * 32) / 256;
+            b = (b * 32) / 256;
+            ret  = a << 15;
+            ret |= r << 10;
+            ret |= g <<  5;
+            ret |= b <<  0;
+            TRACE("Returning %08x\n", ret);
+            return ret;
+
+        case WINED3DFMT_A8_UNORM:
+            TRACE("Returning %08x\n", a);
+            return a;
+
+        case WINED3DFMT_B4G4R4X4_UNORM:
+        case WINED3DFMT_B4G4R4A4_UNORM:
+            a = (a * 16) / 256;
+            r = (r * 16) / 256;
+            g = (g * 16) / 256;
+            b = (b * 16) / 256;
+            ret  = a << 12;
+            ret |= r <<  8;
+            ret |= g <<  4;
+            ret |= b <<  0;
+            TRACE("Returning %08x\n", ret);
+            return ret;
+
+        case WINED3DFMT_B2G3R3_UNORM:
+            r = (r * 8) / 256;
+            g = (g * 8) / 256;
+            b = (b * 4) / 256;
+            ret  = r <<  5;
+            ret |= g <<  2;
+            ret |= b <<  0;
+            TRACE("Returning %08x\n", ret);
+            return ret;
+
+        case WINED3DFMT_R8G8B8X8_UNORM:
+        case WINED3DFMT_R8G8B8A8_UNORM:
+            ret  = a << 24;
+            ret |= b << 16;
+            ret |= g <<  8;
+            ret |= r <<  0;
+            TRACE("Returning %08x\n", ret);
+            return ret;
+
+        case WINED3DFMT_B10G10R10A2_UNORM:
+            a = (a *    4) / 256;
+            r = (r * 1024) / 256;
+            g = (g * 1024) / 256;
+            b = (b * 1024) / 256;
+            ret  = a << 30;
+            ret |= r << 20;
+            ret |= g << 10;
+            ret |= b <<  0;
+            TRACE("Returning %08x\n", ret);
+            return ret;
+
+        case WINED3DFMT_R10G10B10A2_UNORM:
+            a = (a *    4) / 256;
+            r = (r * 1024) / 256;
+            g = (g * 1024) / 256;
+            b = (b * 1024) / 256;
+            ret  = a << 30;
+            ret |= b << 20;
+            ret |= g << 10;
+            ret |= r <<  0;
+            TRACE("Returning %08x\n", ret);
+            return ret;
+
+        default:
+            FIXME("Add a COLORFILL conversion for format %s\n", debug_d3dformat(destfmt));
+            return 0;
+    }
 }
 
@@ -2217,145 +2660,4 @@
 
     return size;
-}
-
-/***********************************************************************
- * CalculateTexRect
- *
- * Calculates the dimensions of the opengl texture used for blits.
- * Handled oversized opengl textures and updates the source rectangle
- * accordingly
- *
- * Params:
- *  This: Surface to operate on
- *  Rect: Requested rectangle
- *
- * Returns:
- *  TRUE if the texture part can be loaded,
- *  FALSE otherwise
- *
- *********************************************************************/
-BOOL CalculateTexRect(IWineD3DSurfaceImpl *This, RECT *Rect, float glTexCoord[4])
-{
-    const struct wined3d_gl_info *gl_info = &This->resource.device->adapter->gl_info;
-    int x1 = Rect->left, x2 = Rect->right;
-    int y1 = Rect->top, y2 = Rect->bottom;
-    GLint maxSize = gl_info->limits.texture_size;
-
-    TRACE("(%p)->(%d,%d)-(%d,%d)\n", This,
-          Rect->left, Rect->top, Rect->right, Rect->bottom);
-
-    /* The sizes might be reversed */
-    if(Rect->left > Rect->right) {
-        x1 = Rect->right;
-        x2 = Rect->left;
-    }
-    if(Rect->top > Rect->bottom) {
-        y1 = Rect->bottom;
-        y2 = Rect->top;
-    }
-
-    /* No oversized texture? This is easy */
-    if(!(This->Flags & SFLAG_OVERSIZE)) {
-        /* Which rect from the texture do I need? */
-        if (This->texture_target == GL_TEXTURE_RECTANGLE_ARB)
-        {
-            glTexCoord[0] = (float) Rect->left;
-            glTexCoord[2] = (float) Rect->top;
-            glTexCoord[1] = (float) Rect->right;
-            glTexCoord[3] = (float) Rect->bottom;
-        } else {
-            glTexCoord[0] = (float) Rect->left / (float) This->pow2Width;
-            glTexCoord[2] = (float) Rect->top / (float) This->pow2Height;
-            glTexCoord[1] = (float) Rect->right / (float) This->pow2Width;
-            glTexCoord[3] = (float) Rect->bottom / (float) This->pow2Height;
-        }
-
-        return TRUE;
-    } else {
-        /* Check if we can succeed at all */
-        if( (x2 - x1) > maxSize ||
-            (y2 - y1) > maxSize ) {
-            TRACE("Requested rectangle is too large for gl\n");
-            return FALSE;
-        }
-
-        /* A part of the texture has to be picked. First, check if
-         * some texture part is loaded already, if yes try to re-use it.
-         * If the texture is dirty, or the part can't be used,
-         * re-position the part to load
-         */
-        if(This->Flags & SFLAG_INTEXTURE) {
-            if(This->glRect.left <= x1 && This->glRect.right >= x2 &&
-               This->glRect.top <= y1 && This->glRect.bottom >= x2 ) {
-                /* Ok, the rectangle is ok, re-use it */
-                TRACE("Using existing gl Texture\n");
-            } else {
-                /* Rectangle is not ok, dirtify the texture to reload it */
-                TRACE("Dirtifying texture to force reload\n");
-                This->Flags &= ~SFLAG_INTEXTURE;
-            }
-        }
-
-        /* Now if we are dirty(no else if!) */
-        if(!(This->Flags & SFLAG_INTEXTURE)) {
-            /* Set the new rectangle. Use the following strategy:
-             * 1) Use as big textures as possible.
-             * 2) Place the texture part in the way that the requested
-             *    part is in the middle of the texture(well, almost)
-             * 3) If the texture is moved over the edges of the
-             *    surface, replace it nicely
-             * 4) If the coord is not limiting the texture size,
-             *    use the whole size
-             */
-            if((This->pow2Width) > maxSize) {
-                This->glRect.left = x1 - maxSize / 2;
-                if(This->glRect.left < 0) {
-                    This->glRect.left = 0;
-                }
-                This->glRect.right = This->glRect.left + maxSize;
-                if(This->glRect.right > This->currentDesc.Width) {
-                    This->glRect.right = This->currentDesc.Width;
-                    This->glRect.left = This->glRect.right - maxSize;
-                }
-            } else {
-                This->glRect.left = 0;
-                This->glRect.right = This->pow2Width;
-            }
-
-            if (This->pow2Height > maxSize)
-            {
-                This->glRect.top = x1 - gl_info->limits.texture_size / 2;
-                if(This->glRect.top < 0) This->glRect.top = 0;
-                This->glRect.bottom = This->glRect.left + maxSize;
-                if(This->glRect.bottom > This->currentDesc.Height) {
-                    This->glRect.bottom = This->currentDesc.Height;
-                    This->glRect.top = This->glRect.bottom - maxSize;
-                }
-            } else {
-                This->glRect.top = 0;
-                This->glRect.bottom = This->pow2Height;
-            }
-            TRACE("(%p): Using rect (%d,%d)-(%d,%d)\n", This,
-                   This->glRect.left, This->glRect.top, This->glRect.right, This->glRect.bottom);
-        }
-
-        /* Re-calculate the rect to draw */
-        Rect->left -= This->glRect.left;
-        Rect->right -= This->glRect.left;
-        Rect->top -= This->glRect.top;
-        Rect->bottom -= This->glRect.top;
-
-        /* Get the gl coordinates. The gl rectangle is a power of 2, eigher the max size,
-         * or the pow2Width / pow2Height of the surface.
-         *
-         * Can never be GL_TEXTURE_RECTANGLE_ARB because oversized surfaces are always set up
-         * as regular GL_TEXTURE_2D.
-         */
-        glTexCoord[0] = (float) Rect->left / (float) (This->glRect.right - This->glRect.left);
-        glTexCoord[2] = (float) Rect->top / (float) (This->glRect.bottom - This->glRect.top);
-        glTexCoord[1] = (float) Rect->right / (float) (This->glRect.right - This->glRect.left);
-        glTexCoord[3] = (float) Rect->bottom / (float) (This->glRect.bottom - This->glRect.top);
-    }
-    return TRUE;
 }
 
@@ -2789,6 +3091,8 @@
 void select_shader_mode(const struct wined3d_gl_info *gl_info, int *ps_selected, int *vs_selected)
 {
+    BOOL glsl = wined3d_settings.glslRequested && gl_info->glsl_version >= MAKEDWORD_VERSION(1, 20);
+
     if (wined3d_settings.vs_mode == VS_NONE) *vs_selected = SHADER_NONE;
-    else if (gl_info->supported[ARB_VERTEX_SHADER] && wined3d_settings.glslRequested)
+    else if (gl_info->supported[ARB_VERTEX_SHADER] && glsl)
     {
         /* Geforce4 cards support GLSL but for vertex shaders only. Further its reported GLSL caps are
@@ -2802,44 +3106,7 @@
 
     if (wined3d_settings.ps_mode == PS_NONE) *ps_selected = SHADER_NONE;
-    else if (gl_info->supported[ARB_FRAGMENT_SHADER] && wined3d_settings.glslRequested) *ps_selected = SHADER_GLSL;
+    else if (gl_info->supported[ARB_FRAGMENT_SHADER] && glsl) *ps_selected = SHADER_GLSL;
     else if (gl_info->supported[ARB_FRAGMENT_PROGRAM]) *ps_selected = SHADER_ARB;
     else if (gl_info->supported[ATI_FRAGMENT_SHADER]) *ps_selected = SHADER_ATI;
     else *ps_selected = SHADER_NONE;
 }
-
-const shader_backend_t *select_shader_backend(struct wined3d_adapter *adapter, WINED3DDEVTYPE device_type)
-{
-    int vs_selected_mode, ps_selected_mode;
-
-    select_shader_mode(&adapter->gl_info, &ps_selected_mode, &vs_selected_mode);
-    if (vs_selected_mode == SHADER_GLSL || ps_selected_mode == SHADER_GLSL) return &glsl_shader_backend;
-    if (vs_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_ARB) return &arb_program_shader_backend;
-    return &none_shader_backend;
-}
-
-const struct fragment_pipeline *select_fragment_implementation(struct wined3d_adapter *adapter,
-        WINED3DDEVTYPE device_type)
-{
-    const struct wined3d_gl_info *gl_info = &adapter->gl_info;
-    int vs_selected_mode, ps_selected_mode;
-
-    select_shader_mode(gl_info, &ps_selected_mode, &vs_selected_mode);
-    if ((ps_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_GLSL)
-            && gl_info->supported[ARB_FRAGMENT_PROGRAM]) return &arbfp_fragment_pipeline;
-    else if (ps_selected_mode == SHADER_ATI) return &atifs_fragment_pipeline;
-    else if (gl_info->supported[NV_REGISTER_COMBINERS]
-            && gl_info->supported[NV_TEXTURE_SHADER2]) return &nvts_fragment_pipeline;
-    else if (gl_info->supported[NV_REGISTER_COMBINERS]) return &nvrc_fragment_pipeline;
-    else return &ffp_fragment_pipeline;
-}
-
-const struct blit_shader *select_blit_implementation(struct wined3d_adapter *adapter, WINED3DDEVTYPE device_type)
-{
-    const struct wined3d_gl_info *gl_info = &adapter->gl_info;
-    int vs_selected_mode, ps_selected_mode;
-
-    select_shader_mode(gl_info, &ps_selected_mode, &vs_selected_mode);
-    if ((ps_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_GLSL)
-            && gl_info->supported[ARB_FRAGMENT_PROGRAM]) return &arbfp_blit;
-    else return &ffp_blit;
-}
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/view.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/view.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/view.c	(revision 28475)
@@ -107,5 +107,5 @@
 }
 
-const struct IWineD3DRendertargetViewVtbl wined3d_rendertarget_view_vtbl =
+static const struct IWineD3DRendertargetViewVtbl wined3d_rendertarget_view_vtbl =
 {
     /* IUnknown methods */
@@ -118,2 +118,12 @@
     rendertarget_view_GetResource,
 };
+
+void wined3d_rendertarget_view_init(struct wined3d_rendertarget_view *view,
+        IWineD3DResource *resource, IUnknown *parent)
+{
+    view->vtbl = &wined3d_rendertarget_view_vtbl;
+    view->refcount = 1;
+    IWineD3DResource_AddRef(resource);
+    view->resource = resource;
+    view->parent = parent;
+}
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/volume.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/volume.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/volume.c	(revision 28475)
@@ -325,5 +325,5 @@
 static HRESULT WINAPI IWineD3DVolumeImpl_LoadTexture(IWineD3DVolume *iface, int gl_level, BOOL srgb_mode) {
     IWineD3DVolumeImpl *This     = (IWineD3DVolumeImpl *)iface;
-    const struct GlPixelFormatDesc *glDesc = This->resource.format_desc;
+    const struct wined3d_format_desc *glDesc = This->resource.format_desc;
 
     TRACE("(%p) : level %u, format %s (0x%08x)\n", This, gl_level, debug_d3dformat(glDesc->format), glDesc->format);
@@ -396,5 +396,5 @@
 {
     const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
-    const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(format, gl_info);
+    const struct wined3d_format_desc *format_desc = getFormatDescEntry(format, gl_info);
     HRESULT hr;
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/volumetexture.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/volumetexture.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/volumetexture.c	(revision 28475)
@@ -365,5 +365,5 @@
 {
     const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
-    const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(format, gl_info);
+    const struct wined3d_format_desc *format_desc = getFormatDescEntry(format, gl_info);
     UINT tmp_w, tmp_h, tmp_d;
     unsigned int i;
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/wined3d_gl.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/wined3d_gl.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/wined3d_gl.h	(revision 28475)
@@ -85,4 +85,7 @@
 typedef ptrdiff_t       GLintptr;
 typedef ptrdiff_t       GLsizeiptr;
+typedef INT64           GLint64;
+typedef UINT64          GLuint64;
+typedef struct __GLsync *GLsync;
 
 /* Booleans */
@@ -813,4 +816,195 @@
 #define GL_SAMPLE_COVERAGE_INVERT         0x80AB
 #define GL_MULTISAMPLE_BIT                0x20000000
+
+/* GL_VERSION_2_0 */
+#ifndef GL_VERSION_2_0
+#define GL_VERSION_2_0 1
+#define GL_BLEND_EQUATION_RGB                               GL_BLEND_EQUATION
+#define GL_VERTEX_ATTRIB_ARRAY_ENABLED                      0x8622
+#define GL_VERTEX_ATTRIB_ARRAY_SIZE                         0x8623
+#define GL_VERTEX_ATTRIB_ARRAY_STRIDE                       0x8624
+#define GL_VERTEX_ATTRIB_ARRAY_TYPE                         0x8625
+#define GL_CURRENT_VERTEX_ATTRIB                            0x8626
+#define GL_VERTEX_PROGRAM_POINT_SIZE                        0x8642
+#define GL_VERTEX_PROGRAM_TWO_SIDE                          0x8643
+#define GL_VERTEX_ATTRIB_ARRAY_POINTER                      0x8645
+#define GL_STENCIL_BACK_FUNC                                0x8800
+#define GL_STENCIL_BACK_FAIL                                0x8801
+#define GL_STENCIL_BACK_PASS_DEPTH_FAIL                     0x8802
+#define GL_STENCIL_BACK_PASS_DEPTH_PASS                     0x8803
+#define GL_MAX_DRAW_BUFFERS                                 0x8824
+#define GL_DRAW_BUFFER0                                     0x8825
+#define GL_DRAW_BUFFER1                                     0x8826
+#define GL_DRAW_BUFFER2                                     0x8827
+#define GL_DRAW_BUFFER3                                     0x8828
+#define GL_DRAW_BUFFER4                                     0x8829
+#define GL_DRAW_BUFFER5                                     0x882a
+#define GL_DRAW_BUFFER6                                     0x882b
+#define GL_DRAW_BUFFER7                                     0x882c
+#define GL_DRAW_BUFFER8                                     0x882d
+#define GL_DRAW_BUFFER9                                     0x882e
+#define GL_DRAW_BUFFER10                                    0x882f
+#define GL_DRAW_BUFFER11                                    0x8830
+#define GL_DRAW_BUFFER12                                    0x8831
+#define GL_DRAW_BUFFER13                                    0x8832
+#define GL_DRAW_BUFFER14                                    0x8833
+#define GL_DRAW_BUFFER15                                    0x8834
+#define GL_BLEND_EQUATION_ALPHA                             0x883d
+#define GL_POINT_SPRITE                                     0x8861
+#define GL_COORD_REPLACE                                    0x8862
+#define GL_MAX_VERTEX_ATTRIBS                               0x8869
+#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED                   0x886a
+#define GL_MAX_TEXTURE_COORDS                               0x8871
+#define GL_MAX_TEXTURE_IMAGE_UNITS                          0x8872
+#define GL_FRAGMENT_SHADER                                  0x8b30
+#define GL_VERTEX_SHADER                                    0x8b31
+#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS                  0x8b49
+#define GL_MAX_VERTEX_UNIFORM_COMPONENTS                    0x8b4a
+#define GL_MAX_VARYING_FLOATS                               0x8b4b
+#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS                   0x8b4c
+#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS                 0x8b4d
+#define GL_SHADER_TYPE                                      0x8b4f
+#define GL_FLOAT_VEC2                                       0x8b50
+#define GL_FLOAT_VEC3                                       0x8b51
+#define GL_FLOAT_VEC4                                       0x8b52
+#define GL_INT_VEC2                                         0x8b53
+#define GL_INT_VEC3                                         0x8b54
+#define GL_INT_VEC4                                         0x8b55
+#define GL_BOOL                                             0x8b56
+#define GL_BOOL_VEC2                                        0x8b57
+#define GL_BOOL_VEC3                                        0x8b58
+#define GL_BOOL_VEC4                                        0x8b59
+#define GL_FLOAT_MAT2                                       0x8b5a
+#define GL_FLOAT_MAT3                                       0x8b5b
+#define GL_FLOAT_MAT4                                       0x8b5c
+#define GL_SAMPLER_1D                                       0x8b5d
+#define GL_SAMPLER_2D                                       0x8b5e
+#define GL_SAMPLER_3D                                       0x8b5f
+#define GL_SAMPLER_CUBE                                     0x8b60
+#define GL_SAMPLER_1D_SHADOW                                0x8b61
+#define GL_SAMPLER_2D_SHADOW                                0x8b62
+#define GL_DELETE_STATUS                                    0x8b80
+#define GL_COMPILE_STATUS                                   0x8b81
+#define GL_LINK_STATUS                                      0x8b82
+#define GL_VALIDATE_STATUS                                  0x8b83
+#define GL_INFO_LOG_LENGTH                                  0x8b84
+#define GL_ATTACHED_SHADERS                                 0x8b85
+#define GL_ACTIVE_UNIFORMS                                  0x8b86
+#define GL_ACTIVE_UNIFORM_MAX_LENGTH                        0x8b87
+#define GL_SHADER_SOURCE_LENGTH                             0x8b88
+#define GL_ACTIVE_ATTRIBUTES                                0x8b89
+#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH                      0x8b8a
+#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT                  0x8b8b
+#define GL_SHADING_LANGUAGE_VERSION                         0x8b8c
+#define GL_CURRENT_PROGRAM                                  0x8b8d
+#define GL_POINT_SPRITE_COORD_ORIGIN                        0x8ca0
+#define GL_LOWER_LEFT                                       0x8ca1
+#define GL_UPPER_LEFT                                       0x8ca2
+#define GL_STENCIL_BACK_REF                                 0x8ca3
+#define GL_STENCIL_BACK_VALUE_MASK                          0x8ca4
+#define GL_STENCIL_BACK_WRITEMASK                           0x8ca5
+typedef char GLchar;
+#endif
+typedef void (WINE_GLAPI *PGLFNBLENDEQUATIONSEPARATEPROC)(GLenum modeRGB, GLenum modeAlpha);
+typedef void (WINE_GLAPI *PGLFNDRAWBUFFERSPROC)(GLsizei n, const GLenum *bufs);
+typedef void (WINE_GLAPI *PGLFNSTENCILOPSEPARATEPROC)(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
+typedef void (WINE_GLAPI *PGLFNSTENCILFUNCSEPARATEPROC)(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);
+typedef void (WINE_GLAPI *PGLFNSTENCILMASKSEPARATEPROC)(GLenum face, GLuint mask);
+typedef void (WINE_GLAPI *PGLFNATTACHSHADERPROC)(GLuint program, GLuint shader);
+typedef void (WINE_GLAPI *PGLFNBINDATTRIBLOCATIONPROC)(GLuint program, GLuint index, const GLchar *name);
+typedef void (WINE_GLAPI *PGLFNCOMPILESHADERPROC)(GLuint shader);
+typedef GLuint (WINE_GLAPI *PGLFNCREATEPROGRAMPROC)(void);
+typedef GLuint (WINE_GLAPI *PGLFNCREATESHADERPROC)(GLenum type);
+typedef void (WINE_GLAPI *PGLFNDELETEPROGRAMPROC)(GLuint program);
+typedef void (WINE_GLAPI *PGLFNDELETESHADERPROC)(GLuint shader);
+typedef void (WINE_GLAPI *PGLFNDETACHSHADERPROC)(GLuint program, GLuint shader);
+typedef void (WINE_GLAPI *PGLFNDISABLEVERTEXATTRIBARRAYPROC)(GLuint index);
+typedef void (WINE_GLAPI *PGLFNENABLEVERTEXATTRIBARRAYPROC)(GLuint index);
+typedef void (WINE_GLAPI *PGLFNGETACTIVEATTRIBPROC)(GLuint program,
+        GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
+typedef void (WINE_GLAPI *PGLFNGETACTIVEUNIFORMPROC)(GLuint program,
+        GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
+typedef void (WINE_GLAPI *PGLFNGETATTACHEDSHADERSPROC)(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj);
+typedef GLint (WINE_GLAPI *PGLFNGETATTRIBLOCATIONPROC)(GLuint program, const GLchar *name);
+typedef void (WINE_GLAPI *PGLFNGETPROGRAMIVPROC)(GLuint program, GLenum pname, GLint *params);
+typedef void (WINE_GLAPI *PGLFNGETPROGRAMINFOLOGPROC)(GLuint program,
+        GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+typedef void (WINE_GLAPI *PGLFNGETSHADERIVPROC)(GLuint shader, GLenum pname, GLint *params);
+typedef void (WINE_GLAPI *PGLFNGETSHADERINFOLOGPROC)(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+typedef void (WINE_GLAPI *PGLFNGETSHADERSOURCEPROC)(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source);
+typedef GLint (WINE_GLAPI *PGLFNGETUNIFORMLOCATIONPROC)(GLuint program, const GLchar *name);
+typedef void (WINE_GLAPI *PGLFNGETUNIFORMFVPROC)(GLuint program, GLint location, GLfloat *params);
+typedef void (WINE_GLAPI *PGLFNGETUNIFORMIVPROC)(GLuint program, GLint location, GLint *params);
+typedef void (WINE_GLAPI *PGLFNGETVERTEXATTRIBDVPROC)(GLuint index, GLenum pname, GLdouble *params);
+typedef void (WINE_GLAPI *PGLFNGETVERTEXATTRIBFVPROC)(GLuint index, GLenum pname, GLfloat *params);
+typedef void (WINE_GLAPI *PGLFNGETVERTEXATTRIBIVPROC)(GLuint index, GLenum pname, GLint *params);
+typedef void (WINE_GLAPI *PGLFNGETVERTEXATTRIBPOINTERVPROC)(GLuint index, GLenum pname, GLvoid* *pointer);
+typedef GLboolean (WINE_GLAPI *PGLFNISPROGRAMPROC)(GLuint program);
+typedef GLboolean (WINE_GLAPI *PGLFNISSHADERPROC)(GLuint shader);
+typedef void (WINE_GLAPI *PGLFNLINKPROGRAMPROC)(GLuint program);
+typedef void (WINE_GLAPI *PGLFNSHADERSOURCEPROC)(GLuint shader,
+        GLsizei count, const GLchar* *string, const GLint *length);
+typedef void (WINE_GLAPI *PGLFNUSEPROGRAMPROC)(GLuint program);
+typedef void (WINE_GLAPI *PGLFNUNIFORM1FPROC)(GLint location, GLfloat v0);
+typedef void (WINE_GLAPI *PGLFNUNIFORM2FPROC)(GLint location, GLfloat v0, GLfloat v1);
+typedef void (WINE_GLAPI *PGLFNUNIFORM3FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+typedef void (WINE_GLAPI *PGLFNUNIFORM4FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+typedef void (WINE_GLAPI *PGLFNUNIFORM1IPROC)(GLint location, GLint v0);
+typedef void (WINE_GLAPI *PGLFNUNIFORM2IPROC)(GLint location, GLint v0, GLint v1);
+typedef void (WINE_GLAPI *PGLFNUNIFORM3IPROC)(GLint location, GLint v0, GLint v1, GLint v2);
+typedef void (WINE_GLAPI *PGLFNUNIFORM4IPROC)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+typedef void (WINE_GLAPI *PGLFNUNIFORM1FVPROC)(GLint location, GLsizei count, const GLfloat *value);
+typedef void (WINE_GLAPI *PGLFNUNIFORM2FVPROC)(GLint location, GLsizei count, const GLfloat *value);
+typedef void (WINE_GLAPI *PGLFNUNIFORM3FVPROC)(GLint location, GLsizei count, const GLfloat *value);
+typedef void (WINE_GLAPI *PGLFNUNIFORM4FVPROC)(GLint location, GLsizei count, const GLfloat *value);
+typedef void (WINE_GLAPI *PGLFNUNIFORM1IVPROC)(GLint location, GLsizei count, const GLint *value);
+typedef void (WINE_GLAPI *PGLFNUNIFORM2IVPROC)(GLint location, GLsizei count, const GLint *value);
+typedef void (WINE_GLAPI *PGLFNUNIFORM3IVPROC)(GLint location, GLsizei count, const GLint *value);
+typedef void (WINE_GLAPI *PGLFNUNIFORM4IVPROC)(GLint location, GLsizei count, const GLint *value);
+typedef void (WINE_GLAPI *PGLFNUNIFORMMATRIX2FVPROC)(GLint location,
+        GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (WINE_GLAPI *PGLFNUNIFORMMATRIX3FVPROC)(GLint location,
+        GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (WINE_GLAPI *PGLFNUNIFORMMATRIX4FVPROC)(GLint location,
+        GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (WINE_GLAPI *PGLFNVALIDATEPROGRAMPROC)(GLuint program);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1DPROC)(GLuint index, GLdouble x);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1DVPROC)(GLuint index, const GLdouble *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1FPROC)(GLuint index, GLfloat x);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1FVPROC)(GLuint index, const GLfloat *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1SPROC)(GLuint index, GLshort x);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1SVPROC)(GLuint index, const GLshort *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2DPROC)(GLuint index, GLdouble x, GLdouble y);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2DVPROC)(GLuint index, const GLdouble *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2FPROC)(GLuint index, GLfloat x, GLfloat y);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2FVPROC)(GLuint index, const GLfloat *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2SPROC)(GLuint index, GLshort x, GLshort y);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2SVPROC)(GLuint index, const GLshort *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3DVPROC)(GLuint index, const GLdouble *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3FVPROC)(GLuint index, const GLfloat *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3SPROC)(GLuint index, GLshort x, GLshort y, GLshort z);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3SVPROC)(GLuint index, const GLshort *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NBVPROC)(GLuint index, const GLbyte *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NIVPROC)(GLuint index, const GLint *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NSVPROC)(GLuint index, const GLshort *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NUBPROC)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NUBVPROC)(GLuint index, const GLubyte *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NUIVPROC)(GLuint index, const GLuint *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NUSVPROC)(GLuint index, const GLushort *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4BVPROC)(GLuint index, const GLbyte *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4DVPROC)(GLuint index, const GLdouble *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4FVPROC)(GLuint index, const GLfloat *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4IVPROC)(GLuint index, const GLint *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4SPROC)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4SVPROC)(GLuint index, const GLshort *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4UBVPROC)(GLuint index, const GLubyte *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4UIVPROC)(GLuint index, const GLuint *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4USVPROC)(GLuint index, const GLushort *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIBPOINTERPROC)(GLuint index,
+        GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
 
 void (WINE_GLAPI *glAccum)(GLenum op, GLfloat value) DECLSPEC_HIDDEN;
@@ -1534,26 +1728,202 @@
     USE_WGL_FUNC(wglShareLists)
 
-
-/****************************************************
- * OpenGL Extensions (EXT and ARB)
- *     #defines and functions pointer
- ****************************************************/
+/* OpenGL extensions. */
+typedef enum wined3d_gl_extension
+{
+    WINED3D_GL_EXT_NONE,
+
+    /* APPLE */
+    APPLE_CLIENT_STORAGE,
+    APPLE_FENCE,
+    APPLE_FLOAT_PIXELS,
+    APPLE_FLUSH_BUFFER_RANGE,
+    APPLE_FLUSH_RENDER,
+    APPLE_YCBCR_422,
+    /* ARB */
+    ARB_COLOR_BUFFER_FLOAT,
+    ARB_DEPTH_BUFFER_FLOAT,
+    ARB_DEPTH_CLAMP,
+    ARB_DEPTH_TEXTURE,
+    ARB_DRAW_BUFFERS,
+    ARB_FRAGMENT_PROGRAM,
+    ARB_FRAGMENT_SHADER,
+    ARB_FRAMEBUFFER_OBJECT,
+    ARB_GEOMETRY_SHADER4,
+    ARB_HALF_FLOAT_PIXEL,
+    ARB_HALF_FLOAT_VERTEX,
+    ARB_IMAGING,
+    ARB_MAP_BUFFER_RANGE,
+    ARB_MULTISAMPLE,
+    ARB_MULTITEXTURE,
+    ARB_OCCLUSION_QUERY,
+    ARB_PIXEL_BUFFER_OBJECT,
+    ARB_POINT_PARAMETERS,
+    ARB_POINT_SPRITE,
+    ARB_PROVOKING_VERTEX,
+    ARB_SHADER_OBJECTS,
+    ARB_SHADER_TEXTURE_LOD,
+    ARB_SHADING_LANGUAGE_100,
+    ARB_SYNC,
+    ARB_TEXTURE_BORDER_CLAMP,
+    ARB_TEXTURE_COMPRESSION,
+    ARB_TEXTURE_CUBE_MAP,
+    ARB_TEXTURE_ENV_ADD,
+    ARB_TEXTURE_ENV_COMBINE,
+    ARB_TEXTURE_ENV_DOT3,
+    ARB_TEXTURE_FLOAT,
+    ARB_TEXTURE_MIRRORED_REPEAT,
+    ARB_TEXTURE_NON_POWER_OF_TWO,
+    ARB_TEXTURE_RECTANGLE,
+    ARB_TEXTURE_RG,
+    ARB_VERTEX_ARRAY_BGRA,
+    ARB_VERTEX_BLEND,
+    ARB_VERTEX_BUFFER_OBJECT,
+    ARB_VERTEX_PROGRAM,
+    ARB_VERTEX_SHADER,
+    /* ATI */
+    ATI_FRAGMENT_SHADER,
+    ATI_SEPARATE_STENCIL,
+    ATI_TEXTURE_COMPRESSION_3DC,
+    ATI_TEXTURE_ENV_COMBINE3,
+    ATI_TEXTURE_MIRROR_ONCE,
+    /* EXT */
+    EXT_BLEND_COLOR,
+    EXT_BLEND_EQUATION_SEPARATE,
+    EXT_BLEND_FUNC_SEPARATE,
+    EXT_BLEND_MINMAX,
+    EXT_DRAW_BUFFERS2,
+    EXT_FOG_COORD,
+    EXT_FRAMEBUFFER_BLIT,
+    EXT_FRAMEBUFFER_MULTISAMPLE,
+    EXT_FRAMEBUFFER_OBJECT,
+    EXT_GPU_PROGRAM_PARAMETERS,
+    EXT_GPU_SHADER4,
+    EXT_PACKED_DEPTH_STENCIL,
+    EXT_PALETTED_TEXTURE,
+    EXT_POINT_PARAMETERS,
+    EXT_PROVOKING_VERTEX,
+    EXT_SECONDARY_COLOR,
+    EXT_STENCIL_TWO_SIDE,
+    EXT_STENCIL_WRAP,
+    EXT_TEXTURE3D,
+    EXT_TEXTURE_COMPRESSION_RGTC,
+    EXT_TEXTURE_COMPRESSION_S3TC,
+    EXT_TEXTURE_ENV_ADD,
+    EXT_TEXTURE_ENV_COMBINE,
+    EXT_TEXTURE_ENV_DOT3,
+    EXT_TEXTURE_FILTER_ANISOTROPIC,
+    EXT_TEXTURE_LOD_BIAS,
+    EXT_TEXTURE_SRGB,
+    EXT_VERTEX_ARRAY_BGRA,
+    /* NVIDIA */
+    NV_DEPTH_CLAMP,
+    NV_FENCE,
+    NV_FOG_DISTANCE,
+    NV_FRAGMENT_PROGRAM,
+    NV_FRAGMENT_PROGRAM2,
+    NV_FRAGMENT_PROGRAM_OPTION,
+    NV_HALF_FLOAT,
+    NV_LIGHT_MAX_EXPONENT,
+    NV_REGISTER_COMBINERS,
+    NV_REGISTER_COMBINERS2,
+    NV_TEXGEN_REFLECTION,
+    NV_TEXTURE_ENV_COMBINE4,
+    NV_TEXTURE_SHADER,
+    NV_TEXTURE_SHADER2,
+    NV_VERTEX_PROGRAM,
+    NV_VERTEX_PROGRAM1_1,
+    NV_VERTEX_PROGRAM2,
+    NV_VERTEX_PROGRAM2_OPTION,
+    NV_VERTEX_PROGRAM3,
+    /* SGI */
+    SGIS_GENERATE_MIPMAP,
+    SGI_VIDEO_SYNC,
+    /* WGL extensions */
+    WGL_ARB_PIXEL_FORMAT,
+    WGL_WINE_PIXEL_FORMAT_PASSTHROUGH,
+    /* Internally used */
+    WINE_NORMALIZED_TEXRECT,
+
+    WINED3D_GL_EXT_COUNT,
+} GL_SupportedExt;
+
+/* GL_APPLE_client_storage */
+#ifndef GL_APPLE_client_storage
+#define GL_APPLE_client_storage 1
+#define GL_UNPACK_CLIENT_STORAGE_APPLE                      0x85b2
+#endif
+
+/* GL_APPLE_fence */
+#ifndef GL_APPLE_fence
+#define GL_APPLE_fence 1
+#define GL_DRAW_PIXELS_APPLE                                0x8a0a
+#define GL_FENCE_APPLE                                      0x8a0b
+#endif
+typedef void (WINE_GLAPI *PGLFNGENFENCESAPPLEPROC)(GLsizei, GLuint *);
+typedef void (WINE_GLAPI *PGLFNDELETEFENCESAPPLEPROC)(GLuint, const GLuint *);
+typedef void (WINE_GLAPI *PGLFNSETFENCEAPPLEPROC)(GLuint);
+typedef GLboolean (WINE_GLAPI *PGLFNTESTFENCEAPPLEPROC)(GLuint);
+typedef void (WINE_GLAPI *PGLFNFINISHFENCEAPPLEPROC)(GLuint);
+typedef GLboolean (WINE_GLAPI *PGLFNISFENCEAPPLEPROC)(GLuint);
+typedef GLboolean (WINE_GLAPI *PGLFNTESTOBJECTAPPLEPROC)(GLenum, GLuint);
+typedef void (WINE_GLAPI *PGLFNFINISHOBJECTAPPLEPROC)(GLenum, GLuint);
+
+/* GL_APPLE_float_pixels */
+#ifndef GL_APPLE_float_pixels
+#define GL_APPLE_float_pixels 1
+#define GL_HALF_APPLE                                       0x140b
+#define GL_COLOR_FLOAT_APPLE                                0x8a0f
+#define GL_RGBA_FLOAT32_APPLE                               0x8814
+#define GL_RGB_FLOAT32_APPLE                                0x8815
+#define GL_ALPHA_FLOAT32_APPLE                              0x8816
+#define GL_INTENSITY_FLOAT32_APPLE                          0x8817
+#define GL_LUMINANCE_FLOAT32_APPLE                          0x8818
+#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE                    0x8819
+#define GL_RGBA_FLOAT16_APPLE                               0x881a
+#define GL_RGB_FLOAT16_APPLE                                0x881b
+#define GL_ALPHA_FLOAT16_APPLE                              0x881c
+#define GL_INTENSITY_FLOAT16_APPLE                          0x881d
+#define GL_LUMINANCE_FLOAT16_APPLE                          0x881e
+#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE                    0x881f
+#endif
+
+/* GL_APPLE_flush_buffer_range */
+#ifndef GL_APPLE_flush_buffer_range
+#define GL_APPLE_flush_buffer_range 1
+#define GL_BUFFER_SERIALIZED_MODIFY_APPLE                   0x8a12
+#define GL_BUFFER_FLUSHING_UNMAP_APPLE                      0x8a13
+typedef void (WINE_GLAPI *PGLFNBUFFERPARAMETERIAPPLE)(GLenum target, GLenum pname, GLint param);
+typedef void (WINE_GLAPI *PGLFNFLUSHMAPPEDBUFFERRANGEAPPLE)(GLenum target, GLintptr offset, GLsizeiptr size);
+#endif
+
+/* GL_APPLE_flush_render */
+typedef void (WINE_GLAPI *PGLFNFLUSHRENDERAPPLEPROC)(void);
+typedef void (WINE_GLAPI *PGLFNFINISHRENDERAPPLEPROC)(void);
+
+/* GL_APPLE_ycbcr_422 */
+#ifndef GL_APPLE_ycbcr_422
+#define GL_APPLE_ycbcr_422 1
+#define GL_YCBCR_422_APPLE                                  0x85b9
+#define UNSIGNED_SHORT_8_8_APPLE                            0x85ba
+#define UNSIGNED_SHORT_8_8_REV_APPLE                        0x85bb
+#endif
 
 /* GL_ARB_color_buffer_float */
 #ifndef GL_ARB_color_buffer_float
-#define GL_RGBA_FLOAT_MODE_ARB            0x8820
-#define GL_CLAMP_VERTEX_COLOR_ARB         0x891A
-#define GL_CLAMP_FRAGMENT_COLOR_ARB       0x891B
-#define GL_CLAMP_READ_COLOR_ARB           0x891C
-#define GL_FIXED_ONLY_ARB                 0x891D
-#endif
-typedef void (WINE_GLAPI *PGLFNCLAMPCOLORARBPROC) (GLenum target, GLenum clamp);
+#define GL_ARB_color_buffer_float 1
+#define GL_RGBA_FLOAT_MODE_ARB                              0x8820
+#define GL_CLAMP_VERTEX_COLOR_ARB                           0x891a
+#define GL_CLAMP_FRAGMENT_COLOR_ARB                         0x891b
+#define GL_CLAMP_READ_COLOR_ARB                             0x891c
+#define GL_FIXED_ONLY_ARB                                   0x891d
+#endif
+typedef void (WINE_GLAPI *PGLFNCLAMPCOLORARBPROC)(GLenum target, GLenum clamp);
 
 /* GL_ARB_depth_buffer_float */
 #ifndef GL_ARB_depth_buffer_float
 #define GL_ARB_depth_buffer_float 1
-#define GL_DEPTH_COMPONENT32F             0x8cac
-#define GL_DEPTH32F_STENCIL8              0x8cad
-#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8dad
+#define GL_DEPTH_COMPONENT32F                               0x8cac
+#define GL_DEPTH32F_STENCIL8                                0x8cad
+#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV                   0x8dad
 #endif
 
@@ -1561,5 +1931,5 @@
 #ifndef GL_ARB_depth_clamp
 #define GL_ARB_depth_clamp 1
-#define GL_DEPTH_CLAMP                    0x864f
+#define GL_DEPTH_CLAMP                                      0x864f
 #endif
 
@@ -1567,9 +1937,9 @@
 #ifndef GL_ARB_depth_texture
 #define GL_ARB_depth_texture 1
-#define GL_DEPTH_COMPONENT16_ARB          0x81A5
-#define GL_DEPTH_COMPONENT24_ARB          0x81A6
-#define GL_DEPTH_COMPONENT32_ARB          0x81A7
-#define GL_TEXTURE_DEPTH_SIZE_ARB         0x884A
-#define GL_DEPTH_TEXTURE_MODE_ARB         0x884B
+#define GL_DEPTH_COMPONENT16_ARB                            0x81a5
+#define GL_DEPTH_COMPONENT24_ARB                            0x81a6
+#define GL_DEPTH_COMPONENT32_ARB                            0x81a7
+#define GL_TEXTURE_DEPTH_SIZE_ARB                           0x884a
+#define GL_DEPTH_TEXTURE_MODE_ARB                           0x884b
 #endif
 
@@ -1577,23 +1947,52 @@
 #ifndef GL_ARB_draw_buffers
 #define GL_ARB_draw_buffers 1
-#define GL_MAX_DRAW_BUFFERS_ARB           0x8824
-#define GL_DRAW_BUFFER0_ARB               0x8825
-#define GL_DRAW_BUFFER1_ARB               0x8826
-#define GL_DRAW_BUFFER2_ARB               0x8827
-#define GL_DRAW_BUFFER3_ARB               0x8828
-#define GL_DRAW_BUFFER4_ARB               0x8829
-#define GL_DRAW_BUFFER5_ARB               0x882A
-#define GL_DRAW_BUFFER6_ARB               0x882B
-#define GL_DRAW_BUFFER7_ARB               0x882C
-#define GL_DRAW_BUFFER8_ARB               0x882D
-#define GL_DRAW_BUFFER9_ARB               0x882E
-#define GL_DRAW_BUFFER10_ARB              0x882F
-#define GL_DRAW_BUFFER11_ARB              0x8830
-#define GL_DRAW_BUFFER12_ARB              0x8831
-#define GL_DRAW_BUFFER13_ARB              0x8832
-#define GL_DRAW_BUFFER14_ARB              0x8833
-#define GL_DRAW_BUFFER15_ARB              0x8834
-#endif
-typedef void (WINE_GLAPI *PGLFNDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs);
+#define GL_MAX_DRAW_BUFFERS_ARB                             0x8824
+#define GL_DRAW_BUFFER0_ARB                                 0x8825
+#define GL_DRAW_BUFFER1_ARB                                 0x8826
+#define GL_DRAW_BUFFER2_ARB                                 0x8827
+#define GL_DRAW_BUFFER3_ARB                                 0x8828
+#define GL_DRAW_BUFFER4_ARB                                 0x8829
+#define GL_DRAW_BUFFER5_ARB                                 0x882a
+#define GL_DRAW_BUFFER6_ARB                                 0x882b
+#define GL_DRAW_BUFFER7_ARB                                 0x882c
+#define GL_DRAW_BUFFER8_ARB                                 0x882d
+#define GL_DRAW_BUFFER9_ARB                                 0x882e
+#define GL_DRAW_BUFFER10_ARB                                0x882f
+#define GL_DRAW_BUFFER11_ARB                                0x8830
+#define GL_DRAW_BUFFER12_ARB                                0x8831
+#define GL_DRAW_BUFFER13_ARB                                0x8832
+#define GL_DRAW_BUFFER14_ARB                                0x8833
+#define GL_DRAW_BUFFER15_ARB                                0x8834
+#endif
+typedef void (WINE_GLAPI *PGLFNDRAWBUFFERSARBPROC)(GLsizei n, const GLenum *bufs);
+
+/* GL_ARB_fragment_program */
+#ifndef GL_ARB_fragment_program
+#define GL_ARB_fragment_program 1
+#define GL_FRAGMENT_PROGRAM_ARB                             0x8804
+#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB                     0x8805
+#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB                     0x8806
+#define GL_PROGRAM_TEX_INDIRECTIONS_ARB                     0x8807
+#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB              0x8808
+#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB              0x8809
+#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB              0x880a
+#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB                 0x880b
+#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB                 0x880c
+#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB                 0x880d
+#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB          0x880e
+#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB          0x880f
+#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB          0x8810
+#define GL_MAX_TEXTURE_COORDS_ARB                           0x8871
+#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB                      0x8872
+/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */
+#endif
+
+/* GL_ARB_fragment_shader */
+#ifndef GL_ARB_fragment_shader
+#define GL_ARB_fragment_shader 1
+#define GL_FRAGMENT_SHADER_ARB                              0x8b30
+#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB              0x8b49
+#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB              0x8b8b
+#endif
 
 /* GL_ARB_framebuffer_object */
@@ -1675,56 +2074,57 @@
 #define GL_TEXTURE_STENCIL_SIZE                             0x88f1
 #endif
-typedef GLboolean (WINE_GLAPI * PGLFNGLISRENDERBUFFERPROC)(GLuint renderbuffer);
-typedef void (WINE_GLAPI * PGLFNGLBINDRENDERBUFFERPROC)(GLenum target, GLuint renderbuffer);
-typedef void (WINE_GLAPI * PGLFNGLDELETERENDERBUFFERSPROC)(GLsizei n, const GLuint *renderbuffers);
-typedef void (WINE_GLAPI * PGLFNGLGENRENDERBUFFERSPROC)(GLsizei n, GLuint *renderbuffers);
-typedef void (WINE_GLAPI * PGLFNGLRENDERBUFFERSTORAGEPROC)(GLenum target, GLenum internalformat,
+typedef GLboolean (WINE_GLAPI *PGLFNGLISRENDERBUFFERPROC)(GLuint renderbuffer);
+typedef void (WINE_GLAPI *PGLFNGLBINDRENDERBUFFERPROC)(GLenum target, GLuint renderbuffer);
+typedef void (WINE_GLAPI *PGLFNGLDELETERENDERBUFFERSPROC)(GLsizei n, const GLuint *renderbuffers);
+typedef void (WINE_GLAPI *PGLFNGLGENRENDERBUFFERSPROC)(GLsizei n, GLuint *renderbuffers);
+typedef void (WINE_GLAPI *PGLFNGLRENDERBUFFERSTORAGEPROC)(GLenum target, GLenum internalformat,
         GLsizei width, GLsizei height);
-typedef void (WINE_GLAPI * PGLFNRENDERBUFFERSTORAGEMULTISAMPLEPROC)(GLenum target, GLsizei samples,
+typedef void (WINE_GLAPI *PGLFNRENDERBUFFERSTORAGEMULTISAMPLEPROC)(GLenum target, GLsizei samples,
         GLenum internalformat, GLsizei width, GLsizei height);
-typedef void (WINE_GLAPI * PGLFNGLGETRENDERBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint *params);
-typedef GLboolean (WINE_GLAPI * PGLFNGLISFRAMEBUFFERPROC)(GLuint framebuffer);
-typedef void (WINE_GLAPI * PGLFNGLBINDFRAMEBUFFERPROC)(GLenum target, GLuint framebuffer);
-typedef void (WINE_GLAPI * PGLFNGLDELETEFRAMEBUFFERSPROC)(GLsizei n, const GLuint *framebuffers);
-typedef void (WINE_GLAPI * PGLFNGLGENFRAMEBUFFERSPROC)(GLsizei n, GLuint *framebuffers);
-typedef GLenum (WINE_GLAPI * PGLFNGLCHECKFRAMEBUFFERSTATUSPROC)(GLenum target);
-typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERTEXTURE1DPROC)(GLenum target, GLenum attachment,
+typedef void (WINE_GLAPI *PGLFNGLGETRENDERBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint *params);
+typedef GLboolean (WINE_GLAPI *PGLFNGLISFRAMEBUFFERPROC)(GLuint framebuffer);
+typedef void (WINE_GLAPI *PGLFNGLBINDFRAMEBUFFERPROC)(GLenum target, GLuint framebuffer);
+typedef void (WINE_GLAPI *PGLFNGLDELETEFRAMEBUFFERSPROC)(GLsizei n, const GLuint *framebuffers);
+typedef void (WINE_GLAPI *PGLFNGLGENFRAMEBUFFERSPROC)(GLsizei n, GLuint *framebuffers);
+typedef GLenum (WINE_GLAPI *PGLFNGLCHECKFRAMEBUFFERSTATUSPROC)(GLenum target);
+typedef void (WINE_GLAPI *PGLFNGLFRAMEBUFFERTEXTURE1DPROC)(GLenum target, GLenum attachment,
         GLenum textarget, GLuint texture, GLint level);
-typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERTEXTURE2DPROC)(GLenum target, GLenum attachment,
+typedef void (WINE_GLAPI *PGLFNGLFRAMEBUFFERTEXTURE2DPROC)(GLenum target, GLenum attachment,
         GLenum textarget, GLuint texture, GLint level);
-typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERTEXTURE3DPROC)(GLenum target, GLenum attachment,
+typedef void (WINE_GLAPI *PGLFNGLFRAMEBUFFERTEXTURE3DPROC)(GLenum target, GLenum attachment,
         GLenum textarget, GLuint texture, GLint level, GLint layer);
-typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERTEXTURELAYERPROC)(GLenum target, GLenum attachment,
+typedef void (WINE_GLAPI *PGLFNGLFRAMEBUFFERTEXTURELAYERPROC)(GLenum target, GLenum attachment,
         GLuint texture, GLint level, GLint layer);
-typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERRENDERBUFFERPROC)(GLenum target, GLenum attachment,
+typedef void (WINE_GLAPI *PGLFNGLFRAMEBUFFERRENDERBUFFERPROC)(GLenum target, GLenum attachment,
         GLenum renderbuffertarget, GLuint renderbuffer);
-typedef void (WINE_GLAPI * PGLFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)(GLenum target, GLenum attachment,
+typedef void (WINE_GLAPI *PGLFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)(GLenum target, GLenum attachment,
         GLenum pname, GLint *params);
-typedef void (WINE_GLAPI * PGLFNGLBLITFRAMEBUFFERPROC)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
+typedef void (WINE_GLAPI *PGLFNGLBLITFRAMEBUFFERPROC)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
         GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
-typedef void (WINE_GLAPI * PGLFNGLGENERATEMIPMAPPROC)(GLenum target);
+typedef void (WINE_GLAPI *PGLFNGLGENERATEMIPMAPPROC)(GLenum target);
 
 /* GL_ARB_geometry_shader4 */
 #ifndef GL_ARB_geometry_shader4
-#define GL_GEOMETRY_SHADER_ARB                      0x8dd9
-#define GL_GEOMETRY_VERTICES_OUT_ARB                0x8dda
-#define GL_GEOMETRY_INPUT_TYPE_ARB                  0x8ddb
-#define GL_GEOMETRY_OUTPUT_TYPE_ARB                 0x8ddc
-#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB     0x8c29
-#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB      0x8ddd
-#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB        0x8dde
-#define GL_MAX_VARYING_COMPONENTS_ARB               0x8b4b
-#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB      0x8ddf
-#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB         0x8de0
-#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8de1
-#define GL_LINES_ADJACENCY_ARB                      0x000a
-#define GL_LINE_STRIP_ADJACENCY_ARB                 0x000b
-#define GL_TRIANGLES_ADJACENCY_ARB                  0x000c
-#define GL_TRIANGLE_STRIP_ADJACENCY_ARB             0x000d
-#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8da8
-#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB   0x8da9
-#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB       0x8da7
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER     0x8cd4
-#define GL_PROGRAM_POINT_SIZE_ARB                   0x8642
+#define GL_ARB_geometry_shader4 1
+#define GL_GEOMETRY_SHADER_ARB                              0x8dd9
+#define GL_GEOMETRY_VERTICES_OUT_ARB                        0x8dda
+#define GL_GEOMETRY_INPUT_TYPE_ARB                          0x8ddb
+#define GL_GEOMETRY_OUTPUT_TYPE_ARB                         0x8ddc
+#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB             0x8c29
+#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB              0x8ddd
+#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB                0x8dde
+#define GL_MAX_VARYING_COMPONENTS_ARB                       0x8b4b
+#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB              0x8ddf
+#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB                 0x8de0
+#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB         0x8de1
+#define GL_LINES_ADJACENCY_ARB                              0x000a
+#define GL_LINE_STRIP_ADJACENCY_ARB                         0x000b
+#define GL_TRIANGLES_ADJACENCY_ARB                          0x000c
+#define GL_TRIANGLE_STRIP_ADJACENCY_ARB                     0x000d
+#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB         0x8da8
+#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB           0x8da9
+#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB               0x8da7
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER             0x8cd4
+#define GL_PROGRAM_POINT_SIZE_ARB                           0x8642
 #endif
 typedef void (WINE_GLAPI *PGLFNPROGRAMPARAMETERIARBPROC)(GLuint program, GLenum pname, GLint value);
@@ -1736,378 +2136,1074 @@
         GLuint texture, GLint level, GLenum face);
 
+/* GL_ARB_half_float_pixel */
+#ifndef GL_ARB_half_float_pixel
+#define GL_ARB_half_float_pixel 1
+#define GL_HALF_FLOAT_ARB                                   0x140b
+#endif
+
+/* GL_ARB_half_float_vertex */
+#ifndef GL_ARB_half_float_vertex
+#define GL_ARB_half_float_vertex 1
+/* No _ARB, see extension spec */
+#define GL_HALF_FLOAT                                       0x140b
+#endif
+
 /* GL_ARB_imaging */
 #ifndef GL_ARB_imaging
 #define GL_ARB_imaging 1
-#define GL_CONSTANT_COLOR                 0x8001
-#define GL_ONE_MINUS_CONSTANT_COLOR       0x8002
-#define GL_CONSTANT_ALPHA                 0x8003
-#define GL_ONE_MINUS_CONSTANT_ALPHA       0x8004
-#define GL_BLEND_COLOR                    0x8005
-#define GL_FUNC_ADD                       0x8006
-#define GL_MIN                            0x8007
-#define GL_MAX                            0x8008
-#define GL_BLEND_EQUATION                 0x8009
-#define GL_FUNC_SUBTRACT                  0x800A
-#define GL_FUNC_REVERSE_SUBTRACT          0x800B
-#define GL_CONVOLUTION_1D                 0x8010
-#define GL_CONVOLUTION_2D                 0x8011
-#define GL_SEPARABLE_2D                   0x8012
-#define GL_CONVOLUTION_BORDER_MODE        0x8013
-#define GL_CONVOLUTION_FILTER_SCALE       0x8014
-#define GL_CONVOLUTION_FILTER_BIAS        0x8015
-#define GL_REDUCE                         0x8016
-#define GL_CONVOLUTION_FORMAT             0x8017
-#define GL_CONVOLUTION_WIDTH              0x8018
-#define GL_CONVOLUTION_HEIGHT             0x8019
-#define GL_MAX_CONVOLUTION_WIDTH          0x801A
-#define GL_MAX_CONVOLUTION_HEIGHT         0x801B
-#define GL_POST_CONVOLUTION_RED_SCALE     0x801C
-#define GL_POST_CONVOLUTION_GREEN_SCALE   0x801D
-#define GL_POST_CONVOLUTION_BLUE_SCALE    0x801E
-#define GL_POST_CONVOLUTION_ALPHA_SCALE   0x801F
-#define GL_POST_CONVOLUTION_RED_BIAS      0x8020
-#define GL_POST_CONVOLUTION_GREEN_BIAS    0x8021
-#define GL_POST_CONVOLUTION_BLUE_BIAS     0x8022
-#define GL_POST_CONVOLUTION_ALPHA_BIAS    0x8023
-#define GL_HISTOGRAM                      0x8024
-#define GL_PROXY_HISTOGRAM                0x8025
-#define GL_HISTOGRAM_WIDTH                0x8026
-#define GL_HISTOGRAM_FORMAT               0x8027
-#define GL_HISTOGRAM_RED_SIZE             0x8028
-#define GL_HISTOGRAM_GREEN_SIZE           0x8029
-#define GL_HISTOGRAM_BLUE_SIZE            0x802A
-#define GL_HISTOGRAM_ALPHA_SIZE           0x802B
-#define GL_HISTOGRAM_LUMINANCE_SIZE       0x802C
-#define GL_HISTOGRAM_SINK                 0x802D
-#define GL_MINMAX                         0x802E
-#define GL_MINMAX_FORMAT                  0x802F
-#define GL_MINMAX_SINK                    0x8030
-#define GL_TABLE_TOO_LARGE                0x8031
-#define GL_COLOR_MATRIX                   0x80B1
-#define GL_COLOR_MATRIX_STACK_DEPTH       0x80B2
-#define GL_MAX_COLOR_MATRIX_STACK_DEPTH   0x80B3
-#define GL_POST_COLOR_MATRIX_RED_SCALE    0x80B4
-#define GL_POST_COLOR_MATRIX_GREEN_SCALE  0x80B5
-#define GL_POST_COLOR_MATRIX_BLUE_SCALE   0x80B6
-#define GL_POST_COLOR_MATRIX_ALPHA_SCALE  0x80B7
-#define GL_POST_COLOR_MATRIX_RED_BIAS     0x80B8
-#define GL_POST_COLOR_MATRIX_GREEN_BIAS   0x80B9
-#define GL_POST_COLOR_MATRIX_BLUE_BIAS    0x80BA
-#define GL_POST_COLOR_MATRIX_ALPHA_BIAS   0x80BB
-#define GL_COLOR_TABLE                    0x80D0
-#define GL_POST_CONVOLUTION_COLOR_TABLE   0x80D1
-#define GL_POST_COLOR_MATRIX_COLOR_TABLE  0x80D2
-#define GL_PROXY_COLOR_TABLE              0x80D3
-#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4
-#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5
-#define GL_COLOR_TABLE_SCALE              0x80D6
-#define GL_COLOR_TABLE_BIAS               0x80D7
-#define GL_COLOR_TABLE_FORMAT             0x80D8
-#define GL_COLOR_TABLE_WIDTH              0x80D9
-#define GL_COLOR_TABLE_RED_SIZE           0x80DA
-#define GL_COLOR_TABLE_GREEN_SIZE         0x80DB
-#define GL_COLOR_TABLE_BLUE_SIZE          0x80DC
-#define GL_COLOR_TABLE_ALPHA_SIZE         0x80DD
-#define GL_COLOR_TABLE_LUMINANCE_SIZE     0x80DE
-#define GL_COLOR_TABLE_INTENSITY_SIZE     0x80DF
-#define GL_CONSTANT_BORDER                0x8151
-#define GL_REPLICATE_BORDER               0x8153
-#define GL_CONVOLUTION_BORDER_COLOR       0x8154
-#endif
-typedef void (WINE_GLAPI *PGLFNBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
-typedef void (WINE_GLAPI *PGLFNBLENDEQUATIONPROC) (GLenum mode);
+#define GL_CONSTANT_COLOR                                   0x8001
+#define GL_ONE_MINUS_CONSTANT_COLOR                         0x8002
+#define GL_CONSTANT_ALPHA                                   0x8003
+#define GL_ONE_MINUS_CONSTANT_ALPHA                         0x8004
+#define GL_BLEND_COLOR                                      0x8005
+#define GL_FUNC_ADD                                         0x8006
+#define GL_MIN                                              0x8007
+#define GL_MAX                                              0x8008
+#define GL_BLEND_EQUATION                                   0x8009
+#define GL_FUNC_SUBTRACT                                    0x800a
+#define GL_FUNC_REVERSE_SUBTRACT                            0x800b
+#define GL_CONVOLUTION_1D                                   0x8010
+#define GL_CONVOLUTION_2D                                   0x8011
+#define GL_SEPARABLE_2D                                     0x8012
+#define GL_CONVOLUTION_BORDER_MODE                          0x8013
+#define GL_CONVOLUTION_FILTER_SCALE                         0x8014
+#define GL_CONVOLUTION_FILTER_BIAS                          0x8015
+#define GL_REDUCE                                           0x8016
+#define GL_CONVOLUTION_FORMAT                               0x8017
+#define GL_CONVOLUTION_WIDTH                                0x8018
+#define GL_CONVOLUTION_HEIGHT                               0x8019
+#define GL_MAX_CONVOLUTION_WIDTH                            0x801a
+#define GL_MAX_CONVOLUTION_HEIGHT                           0x801b
+#define GL_POST_CONVOLUTION_RED_SCALE                       0x801d
+#define GL_POST_CONVOLUTION_GREEN_SCALE                     0x801f
+#define GL_POST_CONVOLUTION_BLUE_SCALE                      0x801e
+#define GL_POST_CONVOLUTION_ALPHA_SCALE                     0x801f
+#define GL_POST_CONVOLUTION_RED_BIAS                        0x8020
+#define GL_POST_CONVOLUTION_GREEN_BIAS                      0x8021
+#define GL_POST_CONVOLUTION_BLUE_BIAS                       0x8022
+#define GL_POST_CONVOLUTION_ALPHA_BIAS                      0x8023
+#define GL_HISTOGRAM                                        0x8024
+#define GL_PROXY_HISTOGRAM                                  0x8025
+#define GL_HISTOGRAM_WIDTH                                  0x8026
+#define GL_HISTOGRAM_FORMAT                                 0x8027
+#define GL_HISTOGRAM_RED_SIZE                               0x8028
+#define GL_HISTOGRAM_GREEN_SIZE                             0x8029
+#define GL_HISTOGRAM_BLUE_SIZE                              0x802a
+#define GL_HISTOGRAM_ALPHA_SIZE                             0x802b
+#define GL_HISTOGRAM_LUMINANCE_SIZE                         0x802c
+#define GL_HISTOGRAM_SINK                                   0x802d
+#define GL_MINMAX                                           0x802e
+#define GL_MINMAX_FORMAT                                    0x802f
+#define GL_MINMAX_SINK                                      0x8030
+#define GL_TABLE_TOO_LARGE                                  0x8031
+#define GL_COLOR_MATRIX                                     0x80b1
+#define GL_COLOR_MATRIX_STACK_DEPTH                         0x80b2
+#define GL_MAX_COLOR_MATRIX_STACK_DEPTH                     0x80b3
+#define GL_POST_COLOR_MATRIX_RED_SCALE                      0x80b4
+#define GL_POST_COLOR_MATRIX_GREEN_SCALE                    0x80b5
+#define GL_POST_COLOR_MATRIX_BLUE_SCALE                     0x80b6
+#define GL_POST_COLOR_MATRIX_ALPHA_SCALE                    0x80b7
+#define GL_POST_COLOR_MATRIX_RED_BIAS                       0x80b8
+#define GL_POST_COLOR_MATRIX_GREEN_BIAS                     0x80b9
+#define GL_POST_COLOR_MATRIX_BLUE_BIAS                      0x80ba
+#define GL_POST_COLOR_MATRIX_ALPHA_BIAS                     0x80bb
+#define GL_COLOR_TABLE                                      0x80d0
+#define GL_POST_CONVOLUTION_COLOR_TABLE                     0x80d1
+#define GL_POST_COLOR_MATRIX_COLOR_TABLE                    0x80d2
+#define GL_PROXY_COLOR_TABLE                                0x80d3
+#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE               0x80d4
+#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE              0x80d5
+#define GL_COLOR_TABLE_SCALE                                0x80d6
+#define GL_COLOR_TABLE_BIAS                                 0x80d7
+#define GL_COLOR_TABLE_FORMAT                               0x80d8
+#define GL_COLOR_TABLE_WIDTH                                0x80d9
+#define GL_COLOR_TABLE_RED_SIZE                             0x80da
+#define GL_COLOR_TABLE_GREEN_SIZE                           0x80db
+#define GL_COLOR_TABLE_BLUE_SIZE                            0x80dc
+#define GL_COLOR_TABLE_ALPHA_SIZE                           0x80dd
+#define GL_COLOR_TABLE_LUMINANCE_SIZE                       0x80de
+#define GL_COLOR_TABLE_INTENSITY_SIZE                       0x80df
+#define GL_CONSTANT_BORDER                                  0x8151
+#define GL_REPLICATE_BORDER                                 0x8153
+#define GL_CONVOLUTION_BORDER_COLOR                         0x8154
+#endif
+typedef void (WINE_GLAPI *PGLFNBLENDCOLORPROC)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+typedef void (WINE_GLAPI *PGLFNBLENDEQUATIONPROC)(GLenum mode);
+
+/* GL_ARB_map_buffer_range */
+#ifndef GL_ARB_map_buffer_range
+#define GL_ARB_map_buffer_range 1
+#define GL_MAP_READ_BIT                                     0x0001
+#define GL_MAP_WRITE_BIT                                    0x0002
+#define GL_MAP_INVALIDATE_RANGE_BIT                         0x0004
+#define GL_MAP_INVALIDATE_BUFFER_BIT                        0x0008
+#define GL_MAP_FLUSH_EXPLICIT_BIT                           0x0010
+#define GL_MAP_UNSYNCHRONIZED_BIT                           0x0020
+#endif
+typedef GLvoid *(WINE_GLAPI *PGLFNMAPBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
+typedef void (WINE_GLAPI *PGLFNFLUSHMAPPEDBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length);
+
+/* GL_ARB_multisample */
+#ifndef GL_ARB_multisample
+#define GL_ARB_multisample 1
+#define GL_MULTISAMPLE_ARB                                  0x809d
+#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB                     0x809e
+#define GL_SAMPLE_ALPHA_TO_ONE_ARB                          0x809f
+#define GL_SAMPLE_COVERAGE_ARB                              0x80a0
+#define GL_SAMPLE_BUFFERS_ARB                               0x80a8
+#define GL_SAMPLES_ARB                                      0x80a9
+#define GL_SAMPLE_COVERAGE_VALUE_ARB                        0x80aa
+#define GL_SAMPLE_COVERAGE_INVERT_ARB                       0x80ab
+#define GL_MULTISAMPLE_BIT_ARB                              0x20000000
+#endif
+typedef void (WINE_GLAPI *WINED3D_PFNGLSAMPLECOVERAGEARBPROC)(GLclampf value, GLboolean invert);
+
 /* GL_ARB_multitexture */
 #ifndef GL_ARB_multitexture
 #define GL_ARB_multitexture 1
-#define GL_TEXTURE0_ARB                   0x84C0
-#define GL_TEXTURE1_ARB                   0x84C1
-#define GL_TEXTURE2_ARB                   0x84C2
-#define GL_TEXTURE3_ARB                   0x84C3
-#define GL_TEXTURE4_ARB                   0x84C4
-#define GL_TEXTURE5_ARB                   0x84C5
-#define GL_TEXTURE6_ARB                   0x84C6
-#define GL_TEXTURE7_ARB                   0x84C7
-#define GL_TEXTURE8_ARB                   0x84C8
-#define GL_TEXTURE9_ARB                   0x84C9
-#define GL_TEXTURE10_ARB                  0x84CA
-#define GL_TEXTURE11_ARB                  0x84CB
-#define GL_TEXTURE12_ARB                  0x84CC
-#define GL_TEXTURE13_ARB                  0x84CD
-#define GL_TEXTURE14_ARB                  0x84CE
-#define GL_TEXTURE15_ARB                  0x84CF
-#define GL_TEXTURE16_ARB                  0x84D0
-#define GL_TEXTURE17_ARB                  0x84D1
-#define GL_TEXTURE18_ARB                  0x84D2
-#define GL_TEXTURE19_ARB                  0x84D3
-#define GL_TEXTURE20_ARB                  0x84D4
-#define GL_TEXTURE21_ARB                  0x84D5
-#define GL_TEXTURE22_ARB                  0x84D6
-#define GL_TEXTURE23_ARB                  0x84D7
-#define GL_TEXTURE24_ARB                  0x84D8
-#define GL_TEXTURE25_ARB                  0x84D9
-#define GL_TEXTURE26_ARB                  0x84DA
-#define GL_TEXTURE27_ARB                  0x84DB
-#define GL_TEXTURE28_ARB                  0x84DC
-#define GL_TEXTURE29_ARB                  0x84DD
-#define GL_TEXTURE30_ARB                  0x84DE
-#define GL_TEXTURE31_ARB                  0x84DF
-#define GL_ACTIVE_TEXTURE_ARB             0x84E0
-#define GL_CLIENT_ACTIVE_TEXTURE_ARB      0x84E1
-#define GL_MAX_TEXTURE_UNITS_ARB          0x84E2
-#endif
-typedef void (WINE_GLAPI *WINED3D_PFNGLACTIVETEXTUREARBPROC) (GLenum texture);
-typedef void (WINE_GLAPI *WINED3D_PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture);
-typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s);
-typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v);
-typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t);
-typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v);
-typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r);
-typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v);
-typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
-typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v);
-typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v);
-typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v);
+#define GL_TEXTURE0_ARB                                     0x84c0
+#define GL_TEXTURE1_ARB                                     0x84c1
+#define GL_TEXTURE2_ARB                                     0x84c2
+#define GL_TEXTURE3_ARB                                     0x84c3
+#define GL_TEXTURE4_ARB                                     0x84c4
+#define GL_TEXTURE5_ARB                                     0x84c5
+#define GL_TEXTURE6_ARB                                     0x84c6
+#define GL_TEXTURE7_ARB                                     0x84c7
+#define GL_TEXTURE8_ARB                                     0x84c8
+#define GL_TEXTURE9_ARB                                     0x84c9
+#define GL_TEXTURE10_ARB                                    0x84ca
+#define GL_TEXTURE11_ARB                                    0x84cb
+#define GL_TEXTURE12_ARB                                    0x84cc
+#define GL_TEXTURE13_ARB                                    0x84cd
+#define GL_TEXTURE14_ARB                                    0x84ce
+#define GL_TEXTURE15_ARB                                    0x84cf
+#define GL_TEXTURE16_ARB                                    0x84d0
+#define GL_TEXTURE17_ARB                                    0x84d1
+#define GL_TEXTURE18_ARB                                    0x84d2
+#define GL_TEXTURE19_ARB                                    0x84d3
+#define GL_TEXTURE20_ARB                                    0x84d4
+#define GL_TEXTURE21_ARB                                    0x84d5
+#define GL_TEXTURE22_ARB                                    0x84d6
+#define GL_TEXTURE23_ARB                                    0x84d7
+#define GL_TEXTURE24_ARB                                    0x84d8
+#define GL_TEXTURE25_ARB                                    0x84d9
+#define GL_TEXTURE26_ARB                                    0x84da
+#define GL_TEXTURE27_ARB                                    0x84db
+#define GL_TEXTURE28_ARB                                    0x84dc
+#define GL_TEXTURE29_ARB                                    0x84dd
+#define GL_TEXTURE30_ARB                                    0x84de
+#define GL_TEXTURE31_ARB                                    0x84df
+#define GL_ACTIVE_TEXTURE_ARB                               0x84e0
+#define GL_CLIENT_ACTIVE_TEXTURE_ARB                        0x84e1
+#define GL_MAX_TEXTURE_UNITS_ARB                            0x84e2
+#endif
+typedef void (WINE_GLAPI *WINED3D_PFNGLACTIVETEXTUREARBPROC)(GLenum texture);
+typedef void (WINE_GLAPI *WINED3D_PFNGLCLIENTACTIVETEXTUREARBPROC)(GLenum texture);
+typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD1FARBPROC)(GLenum target, GLfloat s);
+typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD1FVARBPROC)(GLenum target, const GLfloat *v);
+typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD2FARBPROC)(GLenum target, GLfloat s, GLfloat t);
+typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD2FVARBPROC)(GLenum target, const GLfloat *v);
+typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD3FARBPROC)(GLenum target, GLfloat s, GLfloat t, GLfloat r);
+typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD3FVARBPROC)(GLenum target, const GLfloat *v);
+typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD4FARBPROC)(GLenum target,
+        GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD4FVARBPROC)(GLenum target, const GLfloat *v);
+typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD2SVARBPROC)(GLenum target, const GLshort *v);
+typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD4SVARBPROC)(GLenum target, const GLshort *v);
+
+/* GL_ARB_occlusion_query */
+#ifndef GL_ARB_occlusion_query
+#define GL_ARB_occlusion_query 1
+#define GL_SAMPLES_PASSED_ARB                               0x8914
+#define GL_QUERY_COUNTER_BITS_ARB                           0x8864
+#define GL_CURRENT_QUERY_ARB                                0x8865
+#define GL_QUERY_RESULT_ARB                                 0x8866
+#define GL_QUERY_RESULT_AVAILABLE_ARB                       0x8867
+#endif
+typedef void (WINE_GLAPI *PGLFNGENQUERIESARBPROC)(GLsizei n, GLuint *queries);
+typedef void (WINE_GLAPI *PGLFNDELETEQUERIESARBPROC)(GLsizei n, const GLuint *queries);
+typedef GLboolean (WINE_GLAPI *PGLFNISQUERYARBPROC)(GLuint query);
+typedef void (WINE_GLAPI *PGLFNBEGINQUERYARBPROC)(GLenum target, GLuint query);
+typedef void (WINE_GLAPI *PGLFNENDQUERYARBPROC)(GLenum target);
+typedef void (WINE_GLAPI *PGLFNGETQUERYIVARBPROC)(GLenum target, GLenum pname, GLint *params);
+typedef void (WINE_GLAPI *PGLFNGETQUERYOBJECTIVARBPROC)(GLuint query, GLenum pname, GLint *params);
+typedef void (WINE_GLAPI *PGLFNGETQUERYOBJECTUIVARBPROC)(GLuint query, GLenum pname, GLuint *params);
+
+/* GL_ARB_pixel_buffer_object */
+#ifndef GL_ARB_pixel_buffer_object
+#define GL_ARB_pixel_buffer_object 1
+#define GL_PIXEL_PACK_BUFFER_ARB                            0x88eb
+#define GL_PIXEL_UNPACK_BUFFER_ARB                          0x88ec
+#define GL_PIXEL_PACK_BUFFER_BINDING_ARB                    0x88ed
+#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB                  0x88ef
+#endif
+
+/* GL_ARB_point_parameters */
+#ifndef GL_ARB_point_parameters
+#define GL_ARB_point_parameters 1
+#define GL_POINT_SIZE_MIN_ARB                               0x8126
+#define GL_POINT_SIZE_MAX_ARB                               0x8127
+#define GL_POINT_FADE_THRESHOLD_SIZE_ARB                    0x8128
+#define GL_POINT_DISTANCE_ATTENUATION_ARB                   0x8129
+#endif
+typedef void (WINE_GLAPI *PGLFNGLPOINTPARAMETERFARBPROC)(GLenum pname, GLfloat param);
+typedef void (WINE_GLAPI *PGLFNGLPOINTPARAMETERFVARBPROC)(GLenum pname, const GLfloat *params);
+
+/* GL_ARB_point_sprite */
+#ifndef GL_ARB_point_sprite
+#define GL_ARB_point_sprite 1
+#define GL_POINT_SPRITE_ARB                                 0x8861
+#define GL_COORD_REPLACE_ARB                                0x8862
+#endif
+
+/* GL_ARB_provoking_vertex */
+#ifndef GL_ARB_provoking_vertex
+#define GL_ARB_provoking_vertex 1
+#define GL_FIRST_VERTEX_CONVENTION                          0x8e4d
+#define GL_LAST_VERTEX_CONVENTION                           0x8e4e
+#define GL_PROVOKING_VERTEX                                 0x8e4f
+#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION         0x8e4c
+#endif
+typedef void (WINE_GLAPI *PGLFNGLPROVOKINGVERTEXPROC)(GLenum mode);
+
+/* GL_ARB_shader_objects */
+#ifndef GL_ARB_shader_objects
+#define GL_ARB_shader_objects 1
+typedef char GLcharARB;
+typedef unsigned int GLhandleARB;
+#define GL_PROGRAM_OBJECT_ARB                               0x8b40
+#define GL_OBJECT_TYPE_ARB                                  0x8b4e
+#define GL_OBJECT_SUBTYPE_ARB                               0x8b4f
+#define GL_OBJECT_DELETE_STATUS_ARB                         0x8b80
+#define GL_OBJECT_COMPILE_STATUS_ARB                        0x8b81
+#define GL_OBJECT_LINK_STATUS_ARB                           0x8b82
+#define GL_OBJECT_VALIDATE_STATUS_ARB                       0x8b83
+#define GL_OBJECT_INFO_LOG_LENGTH_ARB                       0x8b84
+#define GL_OBJECT_ATTACHED_OBJECTS_ARB                      0x8b85
+#define GL_OBJECT_ACTIVE_UNIFORMS_ARB                       0x8b86
+#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB             0x8b87
+#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB                  0x8b88
+#define GL_SHADER_OBJECT_ARB                                0x8b48
+#define GL_FLOAT_VEC2_ARB                                   0x8b50
+#define GL_FLOAT_VEC3_ARB                                   0x8b51
+#define GL_FLOAT_VEC4_ARB                                   0x8b52
+#define GL_INT_VEC2_ARB                                     0x8b53
+#define GL_INT_VEC3_ARB                                     0x8b54
+#define GL_INT_VEC4_ARB                                     0x8b55
+#define GL_BOOL_ARB                                         0x8b56
+#define GL_BOOL_VEC2_ARB                                    0x8b57
+#define GL_BOOL_VEC3_ARB                                    0x8b58
+#define GL_BOOL_VEC4_ARB                                    0x8b59
+#define GL_FLOAT_MAT2_ARB                                   0x8b5a
+#define GL_FLOAT_MAT3_ARB                                   0x8b5b
+#define GL_FLOAT_MAT4_ARB                                   0x8b5c
+#define GL_SAMPLER_1D_ARB                                   0x8b5d
+#define GL_SAMPLER_2D_ARB                                   0x8b5e
+#define GL_SAMPLER_3D_ARB                                   0x8b5f
+#define GL_SAMPLER_CUBE_ARB                                 0x8b60
+#define GL_SAMPLER_1D_SHADOW_ARB                            0x8b61
+#define GL_SAMPLER_2D_SHADOW_ARB                            0x8b62
+#define GL_SAMPLER_2D_RECT_ARB                              0x8b63
+#define GL_SAMPELR_2D_RECT_SHADOW_ARB                       0x8b64
+#endif
+
+/* GL_ARB_shading_language_100 */
+#ifndef GL_ARB_shading_language_100
+#define GL_ARB_shading_language_100 1
+#define GL_SHADING_LANGUAGE_VERSION_ARB                     0x8b8c
+#endif
+
+/* GL_ARB_sync */
+#ifndef GL_ARB_sync
+#define GL_ARB_sync 1
+#define GL_MAX_SERVER_WAIT_TIMEOUT              0x9111
+#define GL_OBJECT_TYPE                          0x9112
+#define GL_SYNC_CONDITION                       0x9113
+#define GL_SYNC_STATUS                          0x9114
+#define GL_SYNC_FLAGS                           0x9115
+#define GL_SYNC_FENCE                           0x9116
+#define GL_SYNC_GPU_COMMANDS_COMPLETE           0x9117
+#define GL_UNSIGNALED                           0x9118
+#define GL_SIGNALED                             0x9119
+#define GL_SYNC_FLUSH_COMMANDS_BIT              0x00000001
+#define GL_TIMEOUT_IGNORED                      0xffffffffffffffffULL
+#define GL_ALREADY_SIGNALED                     0x911a
+#define GL_TIMEOUT_EXPIRED                      0x911b
+#define GL_CONDITION_SATISFIED                  0x911c
+#define GL_WAIT_FAILED                          0x911d
+#endif
+typedef GLsync (WINE_GLAPI *PGLFNFENCESYNCPROC)(GLenum condition, GLbitfield flags);
+typedef GLboolean (WINE_GLAPI *PGLFNISSYNCPROC)(GLsync sync);
+typedef GLvoid (WINE_GLAPI *PGLFNDELETESYNCPROC)(GLsync sync);
+typedef GLenum (WINE_GLAPI *PGLFNCLIENTWAITSYNCPROC)(GLsync sync, GLbitfield flags, GLuint64 timeout);
+typedef GLvoid (WINE_GLAPI *PGLFNWAITSYNCPROC)(GLsync sync, GLbitfield flags, GLuint64 timeout);
+typedef GLvoid (WINE_GLAPI *PGLFNGETINTEGER64VPROC)(GLenum pname, GLint64 *params);
+typedef GLvoid (WINE_GLAPI *PGLFNGETSYNCIVPROC)(GLsync sync, GLenum pname, GLsizei bufsize,
+        GLsizei *length, GLint *values);
+
+/* GL_ARB_texture_border_clamp */
+#ifndef GL_ARB_texture_border_clamp
+#define GL_ARB_texture_border_clamp 1
+#define GL_CLAMP_TO_BORDER_ARB                              0x812d
+#endif
 
 /* GL_ARB_texture_cube_map */
 #ifndef GL_ARB_texture_cube_map
 #define GL_ARB_texture_cube_map 1
-#define GL_NORMAL_MAP_ARB                   0x8511
-#define GL_REFLECTION_MAP_ARB               0x8512
-#define GL_TEXTURE_CUBE_MAP_ARB             0x8513
-#define GL_TEXTURE_BINDING_CUBE_MAP_ARB     0x8514
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB  0x8515
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB  0x8516
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB  0x8517
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB  0x8518
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB  0x8519
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB  0x851A
-#define GL_PROXY_TEXTURE_CUBE_MAP_ARB       0x851B
-#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB    0x851C
-#endif
-
-/* GL_ARB_point_parameters */
-#ifndef GL_ARB_point_parameters
-#define GL_ARB_point_parameters 1
-#define GL_POINT_SIZE_MIN_ARB             0x8126
-#define GL_POINT_SIZE_MAX_ARB             0x8127
-#define GL_POINT_FADE_THRESHOLD_SIZE_ARB  0x8128
-#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129
-#endif
-typedef void (WINE_GLAPI * PGLFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param);
-typedef void (WINE_GLAPI * PGLFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params);
-
-/* GL_ARB_provoking_vertex */
-#ifndef GL_ARB_provoking_vertex
-#define GL_ARB_provoking_vertex 1
-#define GL_FIRST_VERTEX_CONVENTION                      0x8e4d
-#define GL_LAST_VERTEX_CONVENTION                       0x8e4e
-#define GL_PROVOKING_VERTEX                             0x8e4f
-#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION     0x8e4c
-#endif
-typedef void (WINE_GLAPI * PGLFNGLPROVOKINGVERTEXPROC)(GLenum mode);
+#define GL_NORMAL_MAP_ARB                                   0x8511
+#define GL_REFLECTION_MAP_ARB                               0x8512
+#define GL_TEXTURE_CUBE_MAP_ARB                             0x8513
+#define GL_TEXTURE_BINDING_CUBE_MAP_ARB                     0x8514
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB                  0x8515
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB                  0x8516
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB                  0x8517
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB                  0x8518
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB                  0x8519
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB                  0x851a
+#define GL_PROXY_TEXTURE_CUBE_MAP_ARB                       0x851b
+#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB                    0x851c
+#endif
+
+/* GL_ARB_texture_env_dot3 */
+#ifndef GL_ARB_texture_env_dot3
+#define GL_ARB_texture_env_dot3 1
+#define GL_DOT3_RGB_ARB                                     0x86ae
+#define GL_DOT3_RGBA_ARB                                    0x86af
+#endif
+
+/* GL_ARB_texture_float */
+#ifndef GL_ARB_texture_float
+#define GL_ARB_texture_float 1
+#define GL_RGBA32F_ARB                                      0x8814
+#define GL_RGB32F_ARB                                       0x8815
+#define GL_RGBA16F_ARB                                      0x881a
+#define GL_RGB16F_ARB                                       0x881b
+#endif
+
+/* GL_ARB_texture_mirrored_repeat */
+#ifndef GL_ARB_texture_mirrored_repeat
+#define GL_ARB_texture_mirrored_repeat 1
+#define GL_MIRRORED_REPEAT_ARB                              0x8370
+#endif
+
+/* GL_ARB_texture_rectangle */
+#ifndef GL_ARB_texture_rectangle
+#define GL_ARB_texture_rectangle 1
+#define GL_TEXTURE_RECTANGLE_ARB                            0x84f5
+#define GL_TEXTURE_BINDING_RECTANGLE_ARB                    0x84f6
+#define GL_PROXY_TEXTURE_RECTANGLE_ARB                      0x84f7
+#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB                   0x84f8
+#define GL_SAMPLER_2D_RECT_ARB                              0x8b63
+#define GL_SAMPLER_2D_RECT_SHADOW_ARB                       0x8b64
+#endif
+
+/* GL_ARB_texture_rg */
+#ifndef GL_ARB_texture_rg
+#define GL_ARB_texture_rg 1
+#define GL_RG                                               0x8227
+#define GL_RG_INTEGER                                       0x8228
+#define GL_R8                                               0x8229
+#define GL_R16                                              0x822a
+#define GL_RG8                                              0x822b
+#define GL_RG16                                             0x822c
+#define GL_R16F                                             0x822d
+#define GL_R32F                                             0x822e
+#define GL_RG16F                                            0x822f
+#define GL_RG32F                                            0x8230
+#define GL_R8I                                              0x8231
+#define GL_R8UI                                             0x8232
+#define GL_R16I                                             0x8233
+#define GL_R16UI                                            0x8234
+#define GL_R32I                                             0x8235
+#define GL_R32UI                                            0x8236
+#define GL_RG8I                                             0x8237
+#define GL_RG8UI                                            0x8238
+#define GL_RG16I                                            0x8239
+#define GL_RG16UI                                           0x823a
+#define GL_RG32I                                            0x823b
+#define GL_RG32UI                                           0x823c
+#endif
 
 /* GL_ARB_vertex_blend */
 #ifndef GL_ARB_vertex_blend
 #define GL_ARB_vertex_blend 1
-#define GL_MAX_VERTEX_UNITS_ARB           0x86A4
-#define GL_ACTIVE_VERTEX_UNITS_ARB        0x86A5
-#define GL_WEIGHT_SUM_UNITY_ARB           0x86A6
-#define GL_VERTEX_BLEND_ARB               0x86A7
-#define GL_CURRENT_WEIGHT_ARB             0x86A8
-#define GL_WEIGHT_ARRAY_TYPE_ARB          0x86A9
-#define GL_WEIGHT_ARRAY_STRIDE_ARB        0x86AA
-#define GL_WEIGHT_ARRAY_SIZE_ARB          0x86AB
-#define GL_WEIGHT_ARRAY_POINTER_ARB       0x86AC
-#define GL_WEIGHT_ARRAY_ARB               0x86AD
-#define GL_MODELVIEW0_ARB                 0x1700
-#define GL_MODELVIEW1_ARB                 0x850A
-#define GL_MODELVIEW2_ARB                 0x8722
-#define GL_MODELVIEW3_ARB                 0x8723
-#define GL_MODELVIEW4_ARB                 0x8724
-#define GL_MODELVIEW5_ARB                 0x8725
-#define GL_MODELVIEW6_ARB                 0x8726
-#define GL_MODELVIEW7_ARB                 0x8727
-#define GL_MODELVIEW8_ARB                 0x8728
-#define GL_MODELVIEW9_ARB                 0x8729
-#define GL_MODELVIEW10_ARB                0x872A
-#define GL_MODELVIEW11_ARB                0x872B
-#define GL_MODELVIEW12_ARB                0x872C
-#define GL_MODELVIEW13_ARB                0x872D
-#define GL_MODELVIEW14_ARB                0x872E
-#define GL_MODELVIEW15_ARB                0x872F
-#define GL_MODELVIEW16_ARB                0x8730
-#define GL_MODELVIEW17_ARB                0x8731
-#define GL_MODELVIEW18_ARB                0x8732
-#define GL_MODELVIEW19_ARB                0x8733
-#define GL_MODELVIEW20_ARB                0x8734
-#define GL_MODELVIEW21_ARB                0x8735
-#define GL_MODELVIEW22_ARB                0x8736
-#define GL_MODELVIEW23_ARB                0x8737
-#define GL_MODELVIEW24_ARB                0x8738
-#define GL_MODELVIEW25_ARB                0x8739
-#define GL_MODELVIEW26_ARB                0x873A
-#define GL_MODELVIEW27_ARB                0x873B
-#define GL_MODELVIEW28_ARB                0x873C
-#define GL_MODELVIEW29_ARB                0x873D
-#define GL_MODELVIEW30_ARB                0x873E
-#define GL_MODELVIEW31_ARB                0x873F
-#endif
-typedef void (WINE_GLAPI * PGLFNGLWEIGHTPOINTERARB) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
-typedef void (WINE_GLAPI * PGLFNGLWEIGHTBV) (GLint size, const GLbyte *weights);
-typedef void (WINE_GLAPI * PGLFNGLWEIGHTSV) (GLint size, const GLshort *weights);
-typedef void (WINE_GLAPI * PGLFNGLWEIGHTIV) (GLint size, const GLint *weights);
-typedef void (WINE_GLAPI * PGLFNGLWEIGHTFV) (GLint size, const GLfloat *weights);
-typedef void (WINE_GLAPI * PGLFNGLWEIGHTDV) (GLint size, const GLdouble *weights);
-typedef void (WINE_GLAPI * PGLFNGLWEIGHTUBV) (GLint size, const GLubyte *weights);
-typedef void (WINE_GLAPI * PGLFNGLWEIGHTUSV) (GLint size, const GLushort *weights);
-typedef void (WINE_GLAPI * PGLFNGLWEIGHTUIV) (GLint size, const GLuint *weights);
-typedef void (WINE_GLAPI * PGLFNGLVERTEXBLENDARB) (GLint count);
-/* GL_ARB_pixel_buffer_object */
-#ifndef GL_ARB_pixel_buffer_object
-#define GL_ARB_pixel_buffer_object 1
-#endif
-#define GL_PIXEL_PACK_BUFFER_ARB               0x88EB
-#define GL_PIXEL_UNPACK_BUFFER_ARB             0x88EC
-#define GL_PIXEL_PACK_BUFFER_BINDING_ARB       0x88ED
-#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB     0x88EF
+#define GL_MAX_VERTEX_UNITS_ARB                             0x86a4
+#define GL_ACTIVE_VERTEX_UNITS_ARB                          0x86a5
+#define GL_WEIGHT_SUM_UNITY_ARB                             0x86a6
+#define GL_VERTEX_BLEND_ARB                                 0x86a7
+#define GL_CURRENT_WEIGHT_ARB                               0x86a8
+#define GL_WEIGHT_ARRAY_TYPE_ARB                            0x86a9
+#define GL_WEIGHT_ARRAY_STRIDE_ARB                          0x86aa
+#define GL_WEIGHT_ARRAY_SIZE_ARB                            0x86ab
+#define GL_WEIGHT_ARRAY_POINTER_ARB                         0x86ac
+#define GL_WEIGHT_ARRAY_ARB                                 0x86ad
+#define GL_MODELVIEW0_ARB                                   0x1700
+#define GL_MODELVIEW1_ARB                                   0x850a
+#define GL_MODELVIEW2_ARB                                   0x8722
+#define GL_MODELVIEW3_ARB                                   0x8723
+#define GL_MODELVIEW4_ARB                                   0x8724
+#define GL_MODELVIEW5_ARB                                   0x8725
+#define GL_MODELVIEW6_ARB                                   0x8726
+#define GL_MODELVIEW7_ARB                                   0x8727
+#define GL_MODELVIEW8_ARB                                   0x8728
+#define GL_MODELVIEW9_ARB                                   0x8729
+#define GL_MODELVIEW10_ARB                                  0x872a
+#define GL_MODELVIEW11_ARB                                  0x872b
+#define GL_MODELVIEW12_ARB                                  0x872c
+#define GL_MODELVIEW13_ARB                                  0x872d
+#define GL_MODELVIEW14_ARB                                  0x872e
+#define GL_MODELVIEW15_ARB                                  0x872f
+#define GL_MODELVIEW16_ARB                                  0x8730
+#define GL_MODELVIEW17_ARB                                  0x8731
+#define GL_MODELVIEW18_ARB                                  0x8732
+#define GL_MODELVIEW19_ARB                                  0x8733
+#define GL_MODELVIEW20_ARB                                  0x8734
+#define GL_MODELVIEW21_ARB                                  0x8735
+#define GL_MODELVIEW22_ARB                                  0x8736
+#define GL_MODELVIEW23_ARB                                  0x8737
+#define GL_MODELVIEW24_ARB                                  0x8738
+#define GL_MODELVIEW25_ARB                                  0x8739
+#define GL_MODELVIEW26_ARB                                  0x873a
+#define GL_MODELVIEW27_ARB                                  0x873b
+#define GL_MODELVIEW28_ARB                                  0x873c
+#define GL_MODELVIEW29_ARB                                  0x873d
+#define GL_MODELVIEW30_ARB                                  0x873e
+#define GL_MODELVIEW31_ARB                                  0x873f
+#endif
+typedef void (WINE_GLAPI *PGLFNGLWEIGHTPOINTERARB)(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (WINE_GLAPI *PGLFNGLWEIGHTBV)(GLint size, const GLbyte *weights);
+typedef void (WINE_GLAPI *PGLFNGLWEIGHTSV)(GLint size, const GLshort *weights);
+typedef void (WINE_GLAPI *PGLFNGLWEIGHTIV)(GLint size, const GLint *weights);
+typedef void (WINE_GLAPI *PGLFNGLWEIGHTFV)(GLint size, const GLfloat *weights);
+typedef void (WINE_GLAPI *PGLFNGLWEIGHTDV)(GLint size, const GLdouble *weights);
+typedef void (WINE_GLAPI *PGLFNGLWEIGHTUBV)(GLint size, const GLubyte *weights);
+typedef void (WINE_GLAPI *PGLFNGLWEIGHTUSV)(GLint size, const GLushort *weights);
+typedef void (WINE_GLAPI *PGLFNGLWEIGHTUIV)(GLint size, const GLuint *weights);
+typedef void (WINE_GLAPI *PGLFNGLVERTEXBLENDARB)(GLint count);
+
+/* GL_ARB_vertex_buffer_object */
+#ifndef GL_ARB_vertex_buffer_object
+#define GL_ARB_vertex_buffer_object 1
+#define GL_BUFFER_SIZE_ARB                                  0x8764
+#define GL_BUFFER_USAGE_ARB                                 0x8765
+#define GL_ARRAY_BUFFER_ARB                                 0x8892
+#define GL_ELEMENT_ARRAY_BUFFER_ARB                         0x8893
+#define GL_ARRAY_BUFFER_BINDING_ARB                         0x8894
+#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB                 0x8895
+#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB                  0x8896
+#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB                  0x8897
+#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB                   0x8898
+#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB                   0x8899
+#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB           0x889a
+#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB               0x889b
+#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB         0x889c
+#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB          0x889d
+#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB                  0x889e
+#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB           0x889f
+#define GL_READ_ONLY_ARB                                    0x88b8
+#define GL_WRITE_ONLY_ARB                                   0x88b9
+#define GL_READ_WRITE_ARB                                   0x88ba
+#define GL_BUFFER_ACCESS_ARB                                0x88bb
+#define GL_BUFFER_MAPPED_ARB                                0x88bc
+#define GL_BUFFER_MAP_POINTER_ARB                           0x88bd
+#define GL_STREAM_DRAW_ARB                                  0x88e0
+#define GL_STREAM_READ_ARB                                  0x88e1
+#define GL_STREAM_COPY_ARB                                  0x88e2
+#define GL_STATIC_DRAW_ARB                                  0x88e4
+#define GL_STATIC_READ_ARB                                  0x88e5
+#define GL_STATIC_COPY_ARB                                  0x88e6
+#define GL_DYNAMIC_DRAW_ARB                                 0x88e8
+#define GL_DYNAMIC_READ_ARB                                 0x88e9
+#define GL_DYNAMIC_COPY_ARB                                 0x88ea
+#endif
+typedef void (WINE_GLAPI *PGLFNBINDBUFFERARBPROC)(GLenum target, GLuint buffer);
+typedef void (WINE_GLAPI *PGLFNDELETEBUFFERSARBPROC)(GLsizei n, const GLuint *buffers);
+typedef void (WINE_GLAPI *PGLFNGENBUFFERSARBPROC)(GLsizei n, GLuint *buffers);
+typedef GLboolean (WINE_GLAPI *PGLFNISBUFFERARBPROC)(GLuint buffer);
+typedef void (WINE_GLAPI *PGLFNBUFFERDATAARBPROC)(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
+typedef void (WINE_GLAPI *PGLFNBUFFERSUBDATAARBPROC)(GLenum target,
+        GLintptr offset, GLsizeiptr size, const GLvoid *data);
+typedef void (WINE_GLAPI *PGLFNGETBUFFERSUBDATAARBPROC)(GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data);
+typedef GLvoid* (WINE_GLAPI *PGLFNMAPBUFFERARBPROC)(GLenum  target, GLenum access);
+typedef GLboolean (WINE_GLAPI *PGLFNUNMAPBUFFERARBPROC)(GLenum target);
+typedef void (WINE_GLAPI *PGLFNGETBUFFERPARAMETERIVARBPROC)(GLenum target, GLenum pname, GLint *params);
+typedef void (WINE_GLAPI *PGLFNGETBUFFERPOINTERVARBPROC)(GLenum target, GLenum pname, GLvoid* *params);
+
+/* GL_ARB_vertex_program */
+#ifndef GL_ARB_vertex_program
+#define GL_ARB_vertex_program 1
+#define GL_VERTEX_PROGRAM_ARB                               0x8620
+#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB                    0x8642
+#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB                      0x8643
+#define GL_COLOR_SUM_ARB                                    0x8458
+#define GL_PROGRAM_FORMAT_ASCII_ARB                         0x8875
+#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB                  0x8622
+#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB                     0x8623
+#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB                   0x8624
+#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB                     0x8625
+#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB               0x886a
+#define GL_CURRENT_VERTEX_ATTRIB_ARB                        0x8626
+#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB                  0x8645
+#define GL_PROGRAM_LENGTH_ARB                               0x8627
+#define GL_PROGRAM_FORMAT_ARB                               0x8876
+#define GL_PROGRAM_BINDING_ARB                              0x8677
+#define GL_PROGRAM_INSTRUCTIONS_ARB                         0x88a0
+#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB                     0x88a1
+#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB                  0x88a2
+#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB              0x88a3
+#define GL_PROGRAM_TEMPORARIES_ARB                          0x88a4
+#define GL_MAX_PROGRAM_TEMPORARIES_ARB                      0x88a5
+#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB                   0x88a6
+#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB               0x88a7
+#define GL_PROGRAM_PARAMETERS_ARB                           0x88a8
+#define GL_MAX_PROGRAM_PARAMETERS_ARB                       0x88a9
+#define GL_PROGRAM_NATIVE_PARAMETERS_ARB                    0x88aa
+#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB                0x88ab
+#define GL_PROGRAM_ATTRIBS_ARB                              0x88ac
+#define GL_MAX_PROGRAM_ATTRIBS_ARB                          0x88ad
+#define GL_PROGRAM_NATIVE_ATTRIBS_ARB                       0x88ae
+#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB                   0x88af
+#define GL_PROGRAM_ADDRESS_REGISTERS_ARB                    0x88b0
+#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB                0x88b1
+#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB             0x88b2
+#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB         0x88b3
+#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB                 0x88b4
+#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB                   0x88b5
+#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB                  0x88b6
+#define GL_PROGRAM_STRING_ARB                               0x8628
+#define GL_PROGRAM_ERROR_POSITION_ARB                       0x864b
+#define GL_CURRENT_MATRIX_ARB                               0x8641
+#define GL_TRANSPOSE_CURRENT_MATRIX_ARB                     0x88b7
+#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB                   0x8640
+#define GL_MAX_VERTEX_ATTRIBS_ARB                           0x8869
+#define GL_MAX_PROGRAM_MATRICES_ARB                         0x862f
+#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB               0x862e
+#define GL_PROGRAM_ERROR_STRING_ARB                         0x8874
+#define GL_MATRIX0_ARB                                      0x88c0
+#define GL_MATRIX1_ARB                                      0x88c1
+#define GL_MATRIX2_ARB                                      0x88c2
+#define GL_MATRIX3_ARB                                      0x88c3
+#define GL_MATRIX4_ARB                                      0x88c4
+#define GL_MATRIX5_ARB                                      0x88c5
+#define GL_MATRIX6_ARB                                      0x88c6
+#define GL_MATRIX7_ARB                                      0x88c7
+#define GL_MATRIX8_ARB                                      0x88c8
+#define GL_MATRIX9_ARB                                      0x88c9
+#define GL_MATRIX10_ARB                                     0x88ca
+#define GL_MATRIX11_ARB                                     0x88cb
+#define GL_MATRIX12_ARB                                     0x88cc
+#define GL_MATRIX13_ARB                                     0x88cd
+#define GL_MATRIX14_ARB                                     0x88ce
+#define GL_MATRIX15_ARB                                     0x88cf
+#define GL_MATRIX16_ARB                                     0x88d0
+#define GL_MATRIX17_ARB                                     0x88d1
+#define GL_MATRIX18_ARB                                     0x88d2
+#define GL_MATRIX19_ARB                                     0x88d3
+#define GL_MATRIX20_ARB                                     0x88d4
+#define GL_MATRIX21_ARB                                     0x88d5
+#define GL_MATRIX22_ARB                                     0x88d6
+#define GL_MATRIX23_ARB                                     0x88d7
+#define GL_MATRIX24_ARB                                     0x88d8
+#define GL_MATRIX25_ARB                                     0x88d9
+#define GL_MATRIX26_ARB                                     0x88da
+#define GL_MATRIX27_ARB                                     0x88db
+#define GL_MATRIX28_ARB                                     0x88dc
+#define GL_MATRIX29_ARB                                     0x88dd
+#define GL_MATRIX30_ARB                                     0x88de
+#define GL_MATRIX31_ARB                                     0x88df
+#endif
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1DARBPROC)(GLuint index, GLdouble x);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1DVARBPROC)(GLuint index, const GLdouble *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1FARBPROC)(GLuint index, GLfloat x);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1FVARBPROC)(GLuint index, const GLfloat *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1SARBPROC)(GLuint index, GLshort x);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1SVARBPROC)(GLuint index, const GLshort *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2DARBPROC)(GLuint index, GLdouble x, GLdouble y);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2DVARBPROC)(GLuint index, const GLdouble *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2FARBPROC)(GLuint index, GLfloat x, GLfloat y);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2FVARBPROC)(GLuint index, const GLfloat *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2SARBPROC)(GLuint index, GLshort x, GLshort y);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2SVARBPROC)(GLuint index, const GLshort *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3DARBPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3DVARBPROC)(GLuint index, const GLdouble *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3FARBPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3FVARBPROC)(GLuint index, const GLfloat *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3SARBPROC)(GLuint index, GLshort x, GLshort y, GLshort z);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3SVARBPROC)(GLuint index, const GLshort *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NBVARBPROC)(GLuint index, const GLbyte *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NIVARBPROC)(GLuint index, const GLint *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NSVARBPROC)(GLuint index, const GLshort *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NUBARBPROC)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NUBVARBPROC)(GLuint index, const GLubyte *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NUIVARBPROC)(GLuint index, const GLuint *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4NUSVARBPROC)(GLuint index, const GLushort *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4BVARBPROC)(GLuint index, const GLbyte *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4DARBPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4DVARBPROC)(GLuint index, const GLdouble *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4FARBPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4FVARBPROC)(GLuint index, const GLfloat *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4IVARBPROC)(GLuint index, const GLint *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4SARBPROC)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4SVARBPROC)(GLuint index, const GLshort *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4UBVARBPROC)(GLuint index, const GLubyte *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4UIVARBPROC)(GLuint index, const GLuint *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4USVARBPROC)(GLuint index, const GLushort *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIBPOINTERARBPROC)(GLuint index, GLint size,
+        GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
+typedef void (WINE_GLAPI *PGLFNENABLEVERTEXATTRIBARRAYARBPROC)(GLuint index);
+typedef void (WINE_GLAPI *PGLFNDISABLEVERTEXATTRIBARRAYARBPROC)(GLuint index);
+typedef void (WINE_GLAPI *PGLFNPROGRAMSTRINGARBPROC)(GLenum target, GLenum format, GLsizei len, const GLvoid *string);
+typedef void (WINE_GLAPI *PGLFNBINDPROGRAMARBPROC)(GLenum target, GLuint program);
+typedef void (WINE_GLAPI *PGLFNDELETEPROGRAMSARBPROC)(GLsizei n, const GLuint *programs);
+typedef void (WINE_GLAPI *PGLFNGENPROGRAMSARBPROC)(GLsizei n, GLuint *programs);
+typedef void (WINE_GLAPI *PGLFNPROGRAMENVPARAMETER4DARBPROC)(GLenum target,
+        GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (WINE_GLAPI *PGLFNPROGRAMENVPARAMETER4DVARBPROC)(GLenum target, GLuint index, const GLdouble *params);
+typedef void (WINE_GLAPI *PGLFNPROGRAMENVPARAMETER4FARBPROC)(GLenum target,
+        GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (WINE_GLAPI *PGLFNPROGRAMENVPARAMETER4FVARBPROC)(GLenum target, GLuint index, const GLfloat *params);
+typedef void (WINE_GLAPI *PGLFNPROGRAMLOCALPARAMETER4DARBPROC)(GLenum target,
+        GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (WINE_GLAPI *PGLFNPROGRAMLOCALPARAMETER4DVARBPROC)(GLenum target, GLuint index, const GLdouble *params);
+typedef void (WINE_GLAPI *PGLFNPROGRAMLOCALPARAMETER4FARBPROC)(GLenum target,
+        GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (WINE_GLAPI *PGLFNPROGRAMLOCALPARAMETER4FVARBPROC)(GLenum target, GLuint index, const GLfloat *params);
+typedef void (WINE_GLAPI *PGLFNGETPROGRAMENVPARAMETERDVARBPROC)(GLenum target, GLuint index, GLdouble *params);
+typedef void (WINE_GLAPI *PGLFNGETPROGRAMENVPARAMETERFVARBPROC)(GLenum target, GLuint index, GLfloat *params);
+typedef void (WINE_GLAPI *PGLFNGETPROGRAMLOCALPARAMETERDVARBPROC)(GLenum target, GLuint index, GLdouble *params);
+typedef void (WINE_GLAPI *PGLFNGETPROGRAMLOCALPARAMETERFVARBPROC)(GLenum target, GLuint index, GLfloat *params);
+typedef void (WINE_GLAPI *PGLFNGETPROGRAMIVARBPROC)(GLenum target, GLenum pname, GLint *params);
+typedef void (WINE_GLAPI *PGLFNGETPROGRAMSTRINGARBPROC)(GLenum target, GLenum pname, GLvoid *string);
+typedef void (WINE_GLAPI *PGLFNGETVERTEXATTRIBDVARBPROC)(GLuint index, GLenum pname, GLdouble *params);
+typedef void (WINE_GLAPI *PGLFNGETVERTEXATTRIBFVARBPROC)(GLuint index, GLenum pname, GLfloat *params);
+typedef void (WINE_GLAPI *PGLFNGETVERTEXATTRIBIVARBPROC)(GLuint index, GLenum pname, GLint *params);
+typedef void (WINE_GLAPI *PGLFNGETVERTEXATTRIBPOINTERVARBPROC)(GLuint index, GLenum pname, GLvoid* *pointer);
+typedef GLboolean (WINE_GLAPI *PGLFNISPROGRAMARBPROC)(GLuint program);
+
+/* GL_ARB_vertex_shader */
+#ifndef GL_ARB_vertex_shader
+#define GL_ARB_vertex_shader 1
+#define GL_VERTEX_SHADER_ARB                                0x8b31
+#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB                0x8b4a
+#define GL_MAX_VARYING_FLOATS_ARB                           0x8b4b
+#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB               0x8b4c
+#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB             0x8b4d
+#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB                     0x8b89
+#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB           0x8b8a
+#endif
+typedef void (WINE_GLAPI *WINED3D_PFNGLGETOBJECTPARAMETERIVARBPROC)(GLhandleARB obj, GLenum pname, GLint *params);
+typedef void (WINE_GLAPI *WINED3D_PFNGLGETOBJECTPARAMETERFVARBPROC)(GLhandleARB obj, GLenum pname, GLfloat *params);
+typedef GLint (WINE_GLAPI *WINED3D_PFNGLGETUNIFORMLOCATIONARBPROC)(GLhandleARB programObj, const GLcharARB *name);
+typedef void (WINE_GLAPI *WINED3D_PFNGLGETACTIVEUNIFORMARBPROC)(GLhandleARB programObj, GLuint index,
+        GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name);
+typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM1IARBPROC)(GLint location, GLint v0);
+typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM2IARBPROC)(GLint location, GLint v0, GLint v1);
+typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM3IARBPROC)(GLint location, GLint v0, GLint v1, GLint v2);
+typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM4IARBPROC)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM1FARBPROC)(GLint location, GLfloat v0);
+typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM2FARBPROC)(GLint location, GLfloat v0, GLfloat v1);
+typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM3FARBPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM4FARBPROC)(GLint location,
+        GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM1IVARBPROC)(GLint location, GLsizei count, const GLint *value);
+typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM2IVARBPROC)(GLint location, GLsizei count, const GLint *value);
+typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM3IVARBPROC)(GLint location, GLsizei count, const GLint *value);
+typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM4IVARBPROC)(GLint location, GLsizei count, const GLint *value);
+typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM1FVARBPROC)(GLint location, GLsizei count, const GLfloat *value);
+typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM2FVARBPROC)(GLint location, GLsizei count, const GLfloat *value);
+typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM3FVARBPROC)(GLint location, GLsizei count, const GLfloat *value);
+typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORM4FVARBPROC)(GLint location, GLsizei count, const GLfloat *value);
+typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORMMATRIX2FVARBPROC)(GLint location,
+        GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORMMATRIX3FVARBPROC)(GLint location,
+        GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (WINE_GLAPI *WINED3D_PFNGLUNIFORMMATRIX4FVARBPROC)(GLint location,
+        GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (WINE_GLAPI *WINED3D_PFNGLGETUNIFORMFVARBPROC)(GLhandleARB programObj, GLint location, GLfloat *params);
+typedef void (WINE_GLAPI *WINED3D_PFNGLGETUNIFORMIVARBPROC)(GLhandleARB programObj, GLint location, GLint *params);
+typedef void (WINE_GLAPI *WINED3D_PFNGLGETINFOLOGARBPROC)(GLhandleARB obj,
+        GLsizei maxLength, GLsizei *length, GLcharARB *infoLog);
+typedef void (WINE_GLAPI *WINED3D_PFNGLUSEPROGRAMOBJECTARBPROC)(GLhandleARB programObj);
+typedef GLhandleARB (WINE_GLAPI *WINED3D_PFNGLCREATESHADEROBJECTARBPROC)(GLenum shaderType);
+typedef void (WINE_GLAPI *WINED3D_PFNGLSHADERSOURCEARBPROC)(GLhandleARB shaderObj,
+        GLsizei count, const GLcharARB* *string, const GLint *length);
+typedef void (WINE_GLAPI *WINED3D_PFNGLCOMPILESHADERARBPROC)(GLhandleARB shaderObj);
+typedef GLhandleARB (WINE_GLAPI *WINED3D_PFNGLCREATEPROGRAMOBJECTARBPROC)(void);
+typedef void (WINE_GLAPI *WINED3D_PFNGLATTACHOBJECTARBPROC)(GLhandleARB containerObj, GLhandleARB obj);
+typedef void (WINE_GLAPI *WINED3D_PFNGLLINKPROGRAMARBPROC)(GLhandleARB programObj);
+typedef void (WINE_GLAPI *WINED3D_PFNGLDETACHOBJECTARBPROC)(GLhandleARB containerObj, GLhandleARB attachedObj);
+typedef void (WINE_GLAPI *WINED3D_PFNGLDELETEOBJECTARBPROC)(GLhandleARB obj);
+typedef void (WINE_GLAPI *WINED3D_PFNGLVALIDATEPROGRAMARBPROC)(GLhandleARB programObj);
+typedef void (WINE_GLAPI *WINED3D_PFNGLGETATTACHEDOBJECTSARBPROC)(GLhandleARB containerObj,
+        GLsizei maxCount, GLsizei *count, GLhandleARB *obj);
+typedef GLhandleARB (WINE_GLAPI *WINED3D_PFNGLGETHANDLEARBPROC)(GLenum pname);
+typedef void (WINE_GLAPI *WINED3D_PFNGLGETSHADERSOURCEARBPROC)(GLhandleARB obj,
+        GLsizei maxLength, GLsizei *length, GLcharARB *source);
+typedef void (WINE_GLAPI *WINED3D_PFNGLBINDATTRIBLOCATIONARBPROC)(GLhandleARB programObj,
+        GLuint index, const GLcharARB *name);
+typedef GLint (WINE_GLAPI *WINED3D_PFNGLGETATTRIBLOCATIONARBPROC)(GLhandleARB programObj, const GLcharARB *name);
+
+/* GL_ATI_fragment_shader */
+#ifndef GL_ATI_fragment_shader
+#define GL_ATI_fragment_shader 1
+#define GL_FRAGMENT_SHADER_ATI                              0x8920
+#define GL_REG_0_ATI                                        0x8921
+#define GL_REG_1_ATI                                        0x8922
+#define GL_REG_2_ATI                                        0x8923
+#define GL_REG_3_ATI                                        0x8924
+#define GL_REG_4_ATI                                        0x8925
+#define GL_REG_5_ATI                                        0x8926
+#define GL_CON_0_ATI                                        0x8941
+#define GL_CON_1_ATI                                        0x8942
+#define GL_CON_2_ATI                                        0x8943
+#define GL_CON_3_ATI                                        0x8944
+#define GL_CON_4_ATI                                        0x8945
+#define GL_CON_5_ATI                                        0x8946
+#define GL_CON_6_ATI                                        0x8947
+#define GL_CON_7_ATI                                        0x8948
+#define GL_MOV_ATI                                          0x8961
+#define GL_ADD_ATI                                          0x8963
+#define GL_MUL_ATI                                          0x8964
+#define GL_SUB_ATI                                          0x8965
+#define GL_DOT3_ATI                                         0x8966
+#define GL_DOT4_ATI                                         0x8967
+#define GL_MAD_ATI                                          0x8968
+#define GL_LERP_ATI                                         0x8969
+#define GL_CND_ATI                                          0x896a
+#define GL_CND0_ATI                                         0x896b
+#define GL_DOT2_ADD_ATI                                     0x896c
+#define GL_SECONDARY_INTERPOLATOR_ATI                       0x896d
+#define GL_SWIZZLE_STR_ATI                                  0x8976
+#define GL_SWIZZLE_STQ_ATI                                  0x8977
+#define GL_SWIZZLE_STR_DR_ATI                               0x8978
+#define GL_SWIZZLE_STQ_DQ_ATI                               0x8979
+#define GL_RED_BIT_ATI                                      0x00000001
+#define GL_GREEN_BIT_ATI                                    0x00000002
+#define GL_BLUE_BIT_ATI                                     0x00000004
+#define GL_2X_BIT_ATI                                       0x00000001
+#define GL_4X_BIT_ATI                                       0x00000002
+#define GL_8X_BIT_ATI                                       0x00000004
+#define GL_HALF_BIT_ATI                                     0x00000008
+#define GL_QUARTER_BIT_ATI                                  0x00000010
+#define GL_EIGHTH_BIT_ATI                                   0x00000020
+#define GL_SATURATE_BIT_ATI                                 0x00000040
+#define GL_COMP_BIT_ATI                                     0x00000002
+#define GL_NEGATE_BIT_ATI                                   0x00000004
+#define GL_BIAS_BIT_ATI                                     0x00000008
+#endif
+typedef GLuint (WINE_GLAPI *PGLFNGENFRAGMENTSHADERSATI)(GLuint range);
+typedef void (WINE_GLAPI *PGLFNBINDFRAGMENTSHADERATI)(GLuint id);
+typedef void (WINE_GLAPI *PGLFNDELETEFRAGMENTSHADERATI)(GLuint id);
+typedef void (WINE_GLAPI *PGLFNBEGINFRAGMENTSHADERATI)(void);
+typedef void (WINE_GLAPI *PGLFNENDFRAGMENTSHADERATI)(void);
+typedef void (WINE_GLAPI *PGLFNPASSTEXCOORDATI)(GLuint dst, GLuint coord, GLenum swizzle);
+typedef void (WINE_GLAPI *PGLFNSAMPLEMAPATI)(GLuint dst, GLuint interp, GLenum swizzle);
+typedef void (WINE_GLAPI *PGLFNCOLORFRAGMENTOP1ATI)(GLenum op, GLuint dst, GLuint dstMask,
+        GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod);
+typedef void (WINE_GLAPI *PGLFNCOLORFRAGMENTOP2ATI)(GLenum op, GLuint dst, GLuint dstMask,
+        GLuint dstMod, GLuint arg1, GLuint arg1Rep,
+        GLuint arg1Mod, GLuint arg2, GLuint arg2Rep,
+        GLuint arg2Mod);
+typedef void (WINE_GLAPI *PGLFNCOLORFRAGMENTOP3ATI)(GLenum op, GLuint dst, GLuint dstMask,
+        GLuint dstMod, GLuint arg1, GLuint arg1Rep,
+        GLuint arg1Mod, GLuint arg2, GLuint arg2Rep,
+        GLuint arg2Mod, GLuint arg3, GLuint arg3Rep,
+        GLuint arg3Mod);
+typedef void (WINE_GLAPI *PGLFNALPHAFRAGMENTOP1ATI)(GLenum op, GLuint dst, GLuint dstMod,
+        GLuint arg1, GLuint arg1Rep, GLuint arg1Mod);
+typedef void (WINE_GLAPI *PGLFNALPHAFRAGMENTOP2ATI)(GLenum op, GLuint dst, GLuint dstMod,
+        GLuint arg1, GLuint arg1Rep, GLuint arg1Mod,
+        GLuint arg2, GLuint arg2Rep, GLuint arg2Mod);
+typedef void (WINE_GLAPI *PGLFNALPHAFRAGMENTOP3ATI)(GLenum op, GLuint dst, GLuint dstMod,
+        GLuint arg1, GLuint arg1Rep, GLuint arg1Mod,
+        GLuint arg2, GLuint arg2Rep, GLuint arg2Mod,
+        GLuint arg3, GLuint arg3Rep, GLuint arg3Mod);
+typedef void (WINE_GLAPI *PGLFNSETFRAGMENTSHADERCONSTANTATI)(GLuint dst, const GLfloat *value);
+
+/* GL_ATI_separate_stencil */
+#ifndef GL_ATI_separate_stencil
+#define GL_ATI_separate_stencil 1
+#define GL_STENCIL_BACK_FUNC_ATI                            0x8800
+#define GL_STENCIL_BACK_FAIL_ATI                            0x8801
+#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI                 0x8802
+#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI                 0x8803
+#endif
+typedef void (WINE_GLAPI *PGLFNSTENCILOPSEPARATEATIPROC)(GLenum, GLenum, GLenum, GLenum);
+typedef void (WINE_GLAPI *PGLFNSTENCILFUNCSEPARATEATIPROC)(GLenum, GLenum, GLint, GLuint);
+
+/* GL_ATI_texture_compression_3dc */
+#ifndef GL_ATI_texture_compression_3dc
+#define GL_ATI_texture_compression_3dc 1
+#define GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI               0x8837
+#endif
+
+/* GL_ATI_texture_env_combine3 */
+#ifndef GL_ATI_texture_env_combine3
+#define GL_ATI_texture_env_combine3 1
+#define GL_MODULATE_ADD_ATI                                 0x8744
+#define GL_MODULATE_SIGNED_ADD_ATI                          0x8745
+#define GL_MODULATE_SUBTRACT_ATI                            0x8746
+/* #define ONE */
+/* #define ZERO */
+#endif
+
+/* GL_ATI_texture_mirror_once */
+#ifndef GL_ATI_texture_mirror_once
+#define GL_ATI_texture_mirror_once 1
+#define GL_MIRROR_CLAMP_ATI                                 0x8742
+#define GL_MIRROR_CLAMP_TO_EDGE_ATI                         0x8743
+#endif
+
+/* GL_EXT_blend_equation_separate */
+typedef void (WINE_GLAPI *PGLFNBLENDEQUATIONSEPARATEEXTPROC)(GLenum modeRGB, GLenum modeAlpha);
+
+/* GL_EXT_blend_func_separate */
+#ifndef GL_EXT_blend_func_separate
+#define GL_EXT_blend_func_separate 1
+#define GL_BLEND_DST_RGB_EXT                                0x80c8
+#define GL_BLEND_SRC_RGB_EXT                                0x80c9
+#define GL_BLEND_DST_ALPHA_EXT                              0x80ca
+#define GL_BLEND_SRC_ALPHA_EXT                              0x80cb
+#endif
+typedef void (WINE_GLAPI *PGLFNBLENDFUNCSEPARATEEXTPROC)(GLenum sfactorRGB, GLenum dfactorRGB,
+        GLenum sfactorAlpha, GLenum dfactorAlpha);
+
+/* GL_EXT_draw_buffers2 */
+typedef GLvoid (WINE_GLAPI *PGLFNCOLORMASKINDEXEDEXTPROC)(GLuint buffer_idx, GLboolean r, GLboolean g,
+        GLboolean b, GLboolean a);
+typedef GLvoid (WINE_GLAPI *PGLFNGETBOOLEANINDEXEDVEXTPROC)(GLenum param, GLuint index, GLboolean *value);
+typedef GLvoid (WINE_GLAPI *PGLFNGETINTEGERINDEXEDVEXTPROC)(GLenum param, GLuint index, GLint *value);
+typedef GLvoid (WINE_GLAPI *PGLFNENABLEINDEXEDEXTPROC)(GLenum target, GLuint index);
+typedef GLvoid (WINE_GLAPI *PGLFNDISABLEINDEXEDEXTPROC)(GLenum target, GLuint index);
+typedef GLboolean (WINE_GLAPI *PGLFNISENABLEDINDEXEDEXTPROC)(GLenum target, GLuint index);
+
+/* GL_EXT_fog_coord */
+#ifndef GL_EXT_fog_coord
+#define GL_EXT_fog_coord 1
+#define GL_FOG_COORDINATE_SOURCE_EXT                        0x8450
+#define GL_FOG_COORDINATE_EXT                               0x8451
+#define GL_FRAGMENT_DEPTH_EXT                               0x8452
+#define GL_CURRENT_FOG_COORDINATE_EXT                       0x8453
+#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT                    0x8454
+#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT                  0x8455
+#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT                 0x8456
+#define GL_FOG_COORDINATE_ARRAY_EXT                         0x8457
+#endif
+typedef void (WINE_GLAPI *PGLFNGLFOGCOORDFEXTPROC)(GLfloat coord);
+typedef void (WINE_GLAPI *PGLFNGLFOGCOORDFVEXTPROC)(const GLfloat *coord);
+typedef void (WINE_GLAPI *PGLFNGLFOGCOORDDEXTPROC)(GLdouble coord);
+typedef void (WINE_GLAPI *PGLFNGLFOGCOORDDVEXTPROC)(const GLdouble *coord);
+typedef void (WINE_GLAPI *PGLFNGLFOGCOORDPOINTEREXTPROC)(GLenum type, GLsizei stride, GLvoid *data);
+
+/* GL_EXT_framebuffer_blit */
+#ifndef GL_EXT_framebuffer_blit
+#define GL_EXT_framebuffer_blit 1
+#define GL_READ_FRAMEBUFFER_EXT                             0x8ca8
+#define GL_DRAW_FRAMEBUFFER_EXT                             0x8ca9
+#define GL_DRAW_FRAMEBUFFER_BINDING_EXT                     0x8ca6
+#define GL_READ_FRAMEBUFFER_BINDING_EXT                     0x8caa
+#endif
+typedef void (WINE_GLAPI *PGLFNGLBLITFRAMEBUFFEREXTPROC)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
+        GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+
+/* GL_EXT_framebuffer_multisample */
+#ifndef GL_EXT_framebuffer_multisample
+#define GL_EXT_framebuffer_multisample 1
+#define GL_RENDERBUFFER_SAMPLES_EXT                         0x8cab
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT           0x8d56
+#define GL_MAX_SAMPLES_EXT                                  0x8d57
+#endif
+typedef void (WINE_GLAPI *PGLFNRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)(GLenum target, GLsizei samples,
+        GLenum internalformat, GLsizei width, GLsizei height);
+
 /* GL_EXT_framebuffer_object */
 #ifndef GL_EXT_framebuffer_object
 #define GL_EXT_framebuffer_object 1
-#define GL_FRAMEBUFFER_EXT                     0x8D40
-#define GL_RENDERBUFFER_EXT                    0x8D41
-#define GL_STENCIL_INDEX1_EXT                  0x8D46
-#define GL_STENCIL_INDEX4_EXT                  0x8D47
-#define GL_STENCIL_INDEX8_EXT                  0x8D48
-#define GL_STENCIL_INDEX16_EXT                 0x8D49
-#define GL_RENDERBUFFER_WIDTH_EXT              0x8D42
-#define GL_RENDERBUFFER_HEIGHT_EXT             0x8D43
-#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT    0x8D44
-#define GL_RENDERBUFFER_RED_SIZE_EXT           0x8D50
-#define GL_RENDERBUFFER_GREEN_SIZE_EXT         0x8D51
-#define GL_RENDERBUFFER_BLUE_SIZE_EXT          0x8D52
-#define GL_RENDERBUFFER_ALPHA_SIZE_EXT         0x8D53
-#define GL_RENDERBUFFER_DEPTH_SIZE_EXT         0x8D54
-#define GL_RENDERBUFFER_STENCIL_SIZE_EXT       0x8D55
-#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT            0x8CD0
-#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT            0x8CD1
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT          0x8CD2
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT  0x8CD3
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT     0x8CD4
-#define GL_COLOR_ATTACHMENT0_EXT                0x8CE0
-#define GL_COLOR_ATTACHMENT1_EXT                0x8CE1
-#define GL_COLOR_ATTACHMENT2_EXT                0x8CE2
-#define GL_COLOR_ATTACHMENT3_EXT                0x8CE3
-#define GL_COLOR_ATTACHMENT4_EXT                0x8CE4
-#define GL_COLOR_ATTACHMENT5_EXT                0x8CE5
-#define GL_COLOR_ATTACHMENT6_EXT                0x8CE6
-#define GL_COLOR_ATTACHMENT7_EXT                0x8CE7
-#define GL_COLOR_ATTACHMENT8_EXT                0x8CE8
-#define GL_COLOR_ATTACHMENT9_EXT                0x8CE9
-#define GL_COLOR_ATTACHMENT10_EXT               0x8CEA
-#define GL_COLOR_ATTACHMENT11_EXT               0x8CEB
-#define GL_COLOR_ATTACHMENT12_EXT               0x8CEC
-#define GL_COLOR_ATTACHMENT13_EXT               0x8CED
-#define GL_COLOR_ATTACHMENT14_EXT               0x8CEE
-#define GL_COLOR_ATTACHMENT15_EXT               0x8CEF
-#define GL_DEPTH_ATTACHMENT_EXT                 0x8D00
-#define GL_STENCIL_ATTACHMENT_EXT               0x8D20
-#define GL_FRAMEBUFFER_COMPLETE_EXT                          0x8CD5
-#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT             0x8CD6
-#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT     0x8CD7
-#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT             0x8CD9
-#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT                0x8CDA
-#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT            0x8CDB
-#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT            0x8CDC
-#define GL_FRAMEBUFFER_UNSUPPORTED_EXT                       0x8CDD
-#define GL_FRAMEBUFFER_BINDING_EXT             0x8CA6
-#define GL_RENDERBUFFER_BINDING_EXT            0x8CA7
-#define GL_MAX_COLOR_ATTACHMENTS_EXT           0x8CDF
-#define GL_MAX_RENDERBUFFER_SIZE_EXT           0x84E8
-#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT   0x0506
-
-#endif
-typedef GLboolean (WINE_GLAPI * PGLFNGLISRENDERBUFFEREXTPROC)(GLuint renderbuffer);
-typedef void (WINE_GLAPI * PGLFNGLBINDRENDERBUFFEREXTPROC)(GLenum target, GLuint renderbuffer);
-typedef void (WINE_GLAPI * PGLFNGLDELETERENDERBUFFERSEXTPROC)(GLsizei n, const GLuint *renderbuffers);
-typedef void (WINE_GLAPI * PGLFNGLGENRENDERBUFFERSEXTPROC)(GLsizei n, GLuint *renderbuffers);
-typedef void (WINE_GLAPI * PGLFNGLRENDERBUFFERSTORAGEEXTPROC)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
-typedef void (WINE_GLAPI * PGLFNGLGETRENDERBUFFERPARAMETERIVEXTPROC)(GLenum target, GLenum pname, GLint *params);
-typedef GLboolean (WINE_GLAPI * PGLFNGLISFRAMEBUFFEREXTPROC)(GLuint framebuffer);
-typedef void (WINE_GLAPI * PGLFNGLBINDFRAMEBUFFEREXTPROC)(GLenum target, GLuint framebuffer);
-typedef void (WINE_GLAPI * PGLFNGLDELETEFRAMEBUFFERSEXTPROC)(GLsizei n, const GLuint *framebuffers);
-typedef void (WINE_GLAPI * PGLFNGLGENFRAMEBUFFERSEXTPROC)(GLsizei n, GLuint *framebuffers);
-typedef GLenum (WINE_GLAPI * PGLFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)(GLenum target);
-typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERTEXTURE1DEXTPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
-typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERTEXTURE2DEXTPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
-typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERTEXTURE3DEXTPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
-typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
-typedef void (WINE_GLAPI * PGLFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC)(GLenum target, GLenum attachment, GLenum pname, GLint *params);
-typedef void (WINE_GLAPI * PGLFNGLGENERATEMIPMAPEXTPROC)(GLenum target);
-/* GL_EXT_framebuffer_blit */
-#ifndef GL_EXT_framebuffer_blit
-#define GL_EXT_framebuffer_blit 1
-#define GL_READ_FRAMEBUFFER_EXT                0x8CA8
-#define GL_DRAW_FRAMEBUFFER_EXT                0x8CA9
-#define GL_DRAW_FRAMEBUFFER_BINDING_EXT        0x8CA6
-#define GL_READ_FRAMEBUFFER_BINDING_EXT        0x8CAA
-#endif
-typedef void (WINE_GLAPI * PGLFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
-
-/* GL_EXT_framebuffer_multisample */
-#ifndef GL_EXT_framebuffer_multisample
-#define GL_EXT_framebuffer_multisample 1
-#define GL_RENDERBUFFER_SAMPLES_EXT                 0x8cab
-#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT   0x8d56
-#define GL_MAX_SAMPLES_EXT                          0x8d57
-#endif
-typedef void (WINE_GLAPI * PGLFNRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+#define GL_FRAMEBUFFER_EXT                                  0x8d40
+#define GL_RENDERBUFFER_EXT                                 0x8d41
+#define GL_STENCIL_INDEX1_EXT                               0x8d46
+#define GL_STENCIL_INDEX4_EXT                               0x8d47
+#define GL_STENCIL_INDEX8_EXT                               0x8d48
+#define GL_STENCIL_INDEX16_EXT                              0x8d49
+#define GL_RENDERBUFFER_WIDTH_EXT                           0x8d42
+#define GL_RENDERBUFFER_HEIGHT_EXT                          0x8d43
+#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT                 0x8d44
+#define GL_RENDERBUFFER_RED_SIZE_EXT                        0x8d50
+#define GL_RENDERBUFFER_GREEN_SIZE_EXT                      0x8d51
+#define GL_RENDERBUFFER_BLUE_SIZE_EXT                       0x8d52
+#define GL_RENDERBUFFER_ALPHA_SIZE_EXT                      0x8d53
+#define GL_RENDERBUFFER_DEPTH_SIZE_EXT                      0x8d54
+#define GL_RENDERBUFFER_STENCIL_SIZE_EXT                    0x8d55
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT           0x8cd0
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT           0x8cd1
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT         0x8cd2
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8cd3
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT    0x8cd4
+#define GL_COLOR_ATTACHMENT0_EXT                            0x8ce0
+#define GL_COLOR_ATTACHMENT1_EXT                            0x8ce1
+#define GL_COLOR_ATTACHMENT2_EXT                            0x8ce2
+#define GL_COLOR_ATTACHMENT3_EXT                            0x8ce3
+#define GL_COLOR_ATTACHMENT4_EXT                            0x8ce4
+#define GL_COLOR_ATTACHMENT5_EXT                            0x8ce5
+#define GL_COLOR_ATTACHMENT6_EXT                            0x8ce6
+#define GL_COLOR_ATTACHMENT7_EXT                            0x8ce7
+#define GL_COLOR_ATTACHMENT8_EXT                            0x8ce8
+#define GL_COLOR_ATTACHMENT9_EXT                            0x8ce9
+#define GL_COLOR_ATTACHMENT10_EXT                           0x8cea
+#define GL_COLOR_ATTACHMENT11_EXT                           0x8ceb
+#define GL_COLOR_ATTACHMENT12_EXT                           0x8cec
+#define GL_COLOR_ATTACHMENT13_EXT                           0x8ced
+#define GL_COLOR_ATTACHMENT14_EXT                           0x8cee
+#define GL_COLOR_ATTACHMENT15_EXT                           0x8cef
+#define GL_DEPTH_ATTACHMENT_EXT                             0x8d00
+#define GL_STENCIL_ATTACHMENT_EXT                           0x8d20
+#define GL_FRAMEBUFFER_COMPLETE_EXT                         0x8cd5
+#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT            0x8cd6
+#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT    0x8cd7
+#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT            0x8cd9
+#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT               0x8cda
+#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT           0x8cdb
+#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT           0x8cdc
+#define GL_FRAMEBUFFER_UNSUPPORTED_EXT                      0x8cdd
+#define GL_FRAMEBUFFER_BINDING_EXT                          0x8ca6
+#define GL_RENDERBUFFER_BINDING_EXT                         0x8ca7
+#define GL_MAX_COLOR_ATTACHMENTS_EXT                        0x8cdF
+#define GL_MAX_RENDERBUFFER_SIZE_EXT                        0x84e8
+#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT                0x0506
+#endif
+typedef GLboolean (WINE_GLAPI *PGLFNGLISRENDERBUFFEREXTPROC)(GLuint renderbuffer);
+typedef void (WINE_GLAPI *PGLFNGLBINDRENDERBUFFEREXTPROC)(GLenum target, GLuint renderbuffer);
+typedef void (WINE_GLAPI *PGLFNGLDELETERENDERBUFFERSEXTPROC)(GLsizei n, const GLuint *renderbuffers);
+typedef void (WINE_GLAPI *PGLFNGLGENRENDERBUFFERSEXTPROC)(GLsizei n, GLuint *renderbuffers);
+typedef void (WINE_GLAPI *PGLFNGLRENDERBUFFERSTORAGEEXTPROC)(GLenum target,
+        GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (WINE_GLAPI *PGLFNGLGETRENDERBUFFERPARAMETERIVEXTPROC)(GLenum target, GLenum pname, GLint *params);
+typedef GLboolean (WINE_GLAPI *PGLFNGLISFRAMEBUFFEREXTPROC)(GLuint framebuffer);
+typedef void (WINE_GLAPI *PGLFNGLBINDFRAMEBUFFEREXTPROC)(GLenum target, GLuint framebuffer);
+typedef void (WINE_GLAPI *PGLFNGLDELETEFRAMEBUFFERSEXTPROC)(GLsizei n, const GLuint *framebuffers);
+typedef void (WINE_GLAPI *PGLFNGLGENFRAMEBUFFERSEXTPROC)(GLsizei n, GLuint *framebuffers);
+typedef GLenum (WINE_GLAPI *PGLFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)(GLenum target);
+typedef void (WINE_GLAPI *PGLFNGLFRAMEBUFFERTEXTURE1DEXTPROC)(GLenum target, GLenum attachment,
+        GLenum textarget, GLuint texture, GLint level);
+typedef void (WINE_GLAPI *PGLFNGLFRAMEBUFFERTEXTURE2DEXTPROC)(GLenum target, GLenum attachment,
+        GLenum textarget, GLuint texture, GLint level);
+typedef void (WINE_GLAPI *PGLFNGLFRAMEBUFFERTEXTURE3DEXTPROC)(GLenum target, GLenum attachment,
+        GLenum textarget, GLuint texture, GLint level, GLint zoffset);
+typedef void (WINE_GLAPI *PGLFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)(GLenum target, GLenum attachment,
+        GLenum renderbuffertarget, GLuint renderbuffer);
+typedef void (WINE_GLAPI *PGLFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC)(GLenum target,
+        GLenum attachment, GLenum pname, GLint *params);
+typedef void (WINE_GLAPI *PGLFNGLGENERATEMIPMAPEXTPROC)(GLenum target);
+
+/* GL_EXT_gpu_program_parameters */
+#ifndef GL_EXT_gpu_program_parameters
+#define GL_EXT_gpu_program_parameters 1
+typedef void (WINE_GLAPI *PGLFNPROGRAMENVPARAMETERS4FVEXTPROC)(GLenum target,
+        GLuint index, GLsizei count, const float *params);
+typedef void (WINE_GLAPI *PGLFNPROGRAMLOCALPARAMETERS4FVEXTPROC)(GLenum target,
+        GLuint index, GLsizei count, const float *params);
+#endif
+
+/* GL_EXT_gpu_shader4 */
+#ifndef GL_EXT_gpu_shader4
+#define GL_EXT_gpu_shader4 1
+#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT                  0x88fd
+#define GL_SAMPLER_1D_ARRAY_EXT                             0x8dc0
+#define GL_SAMPLER_2D_ARRAY_EXT                             0x8dc1
+#define GL_SAMPLER_BUFFER_EXT                               0x8dc2
+#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT                      0x8dc3
+#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT                      0x8dc4
+#define GL_SAMPLER_CUBE_SHADOW_EXT                          0x8dc5
+#define GL_UNSIGNED_INT_VEC2_EXT                            0x8dc6
+#define GL_UNSIGNED_INT_VEC3_EXT                            0x8dc7
+#define GL_UNSIGNED_INT_VEC4_EXT                            0x8dc8
+#define GL_INT_SAMPLER_1D_EXT                               0x8dc9
+#define GL_INT_SAMPLER_2D_EXT                               0x8dca
+#define GL_INT_SAMPLER_3D_EXT                               0x8dcb
+#define GL_INT_SAMPLER_CUBE_EXT                             0x8dcc
+#define GL_INT_SAMPLER_2D_RECT_EXT                          0x8dcd
+#define GL_INT_SAMPLER_1D_ARRAY_EXT                         0x8dce
+#define GL_INT_SAMPLER_2D_ARRAY_EXT                         0x8dcf
+#define GL_INT_SAMPLER_BUFFER_EXT                           0x8dd0
+#define GL_UNSIGNED_INT_SAMPLER_1D_EXT                      0x8dd1
+#define GL_UNSIGNED_INT_SAMPLER_2D_EXT                      0x8dd2
+#define GL_UNSIGNED_INT_SAMPLER_3D_EXT                      0x8dd3
+#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT                    0x8dd4
+#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT                 0x8dd5
+#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT                0x8dd6
+#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT                0x8dd7
+#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT                  0x8dd8
+#define GL_MIN_PROGRAM_TEXEL_OFFSET_EXT                     0x8904
+#define GL_MAX_PROGRAM_TEXEL_OFFSET_EXT                     0x8905
+#endif
+typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI1IEXTPROC)(GLuint index, GLint x);
+typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI2IEXTPROC)(GLuint index, GLint x, GLint y);
+typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI3IEXTPROC)(GLuint index, GLint x, GLint y, GLint z);
+typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI4IEXTPROC)(GLuint index, GLint x, GLint y, GLint z, GLint w);
+typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI1UIEXTPROC)(GLuint index, GLuint x);
+typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI2UIEXTPROC)(GLuint index, GLuint x, GLuint y);
+typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI3UIEXTPROC)(GLuint index, GLuint x, GLuint y, GLuint z);
+typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI4UIEXTPROC)(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
+typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI1IVEXTPROC)(GLuint index, const GLint *v);
+typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI2IVEXTPROC)(GLuint index, const GLint *v);
+typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI3IVEXTPROC)(GLuint index, const GLint *v);
+typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI4IVEXTPROC)(GLuint index, const GLint *v);
+typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI1UIVEXTPROC)(GLuint index, const GLuint *v);
+typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI2UIVEXTPROC)(GLuint index, const GLuint *v);
+typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI3UIVEXTPROC)(GLuint index, const GLuint *v);
+typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI4UIVEXTPROC)(GLuint index, const GLuint *v);
+typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI4BVEXTPROC)(GLuint index, const GLbyte *v);
+typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI4SVEXTPROC)(GLuint index, const GLshort *v);
+typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI4UBVEXTPROC)(GLuint index, const GLubyte *v);
+typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBI4USVEXTPROC)(GLuint index, const GLushort *v);
+typedef GLvoid (WINE_GLAPI *PGLFNVERTEXATTRIBIPOINTEREXTPROC)(GLuint index, GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer);
+typedef GLvoid (WINE_GLAPI *PGLFNGETVERTEXATTRIBIIVEXTPROC)(GLuint index, GLenum pname, GLint *params);
+typedef GLvoid (WINE_GLAPI *PGLFNGETVERTEXATTRIBIUIVEXTPROC)(GLuint index, GLenum pname, GLuint *params);
+typedef GLvoid (WINE_GLAPI *PGLFNUNIFORM1UIEXTPROC)(GLint location, GLuint v0);
+typedef GLvoid (WINE_GLAPI *PGLFNUNIFORM2UIEXTPROC)(GLint location, GLuint v0, GLuint v1);
+typedef GLvoid (WINE_GLAPI *PGLFNUNIFORM3UIEXTPROC)(GLint location, GLuint v0, GLuint v1, GLuint v2);
+typedef GLvoid (WINE_GLAPI *PGLFNUNIFORM4UIEXTPROC)(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+typedef GLvoid (WINE_GLAPI *PGLFNUNIFORM1UIVEXTPROC)(GLint location, GLsizei count, const GLuint *value);
+typedef GLvoid (WINE_GLAPI *PGLFNUNIFORM2UIVEXTPROC)(GLint location, GLsizei count, const GLuint *value);
+typedef GLvoid (WINE_GLAPI *PGLFNUNIFORM3UIVEXTPROC)(GLint location, GLsizei count, const GLuint *value);
+typedef GLvoid (WINE_GLAPI *PGLFNUNIFORM4UIVEXTPROC)(GLint location, GLsizei count, const GLuint *value);
+typedef GLvoid (WINE_GLAPI *PGLFNGETUNIFORMUIVEXTPROC)(GLuint program, GLint location, const GLuint *params);
+typedef GLvoid (WINE_GLAPI *PGLFNBINDFRAGDATALOCATIONEXTPROC)(GLuint program, GLuint color_number, const GLchar *name);
+typedef GLint (WINE_GLAPI *PGLFNGETFRAGDATALOCATIONEXTPROC)(GLuint program, const GLchar *name);
 
 /* GL_EXT_packed_depth_stencil */
 #ifndef GL_EXT_packed_depth_stencil
 #define GL_EXT_packed_depth_stencil 1
-#define GL_DEPTH_STENCIL_EXT                0x84f9
-#define GL_UNSIGNED_INT_24_8_EXT            0x84fa
-#define GL_DEPTH24_STENCIL8_EXT             0x88f0
-#define GL_TEXTURE_STENCIL_SIZE_EXT         0x88f1
-#endif
-
-/* GL_EXT_secondary_color */
-#ifndef GL_EXT_secondary_color
-#define GL_EXT_secondary_color 1
-#define GL_COLOR_SUM_EXT                     0x8458
-#define GL_CURRENT_SECONDARY_COLOR_EXT       0x8459
-#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT    0x845A
-#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT    0x845B
-#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT  0x845C
-#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D
-#define GL_SECONDARY_COLOR_ARRAY_EXT         0x845E
-#endif
-typedef void (WINE_GLAPI * PGLFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue);
-typedef void (WINE_GLAPI * PGLFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v);
-typedef void (WINE_GLAPI * PGLFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue);
-typedef void (WINE_GLAPI * PGLFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v);
-typedef void (WINE_GLAPI * PGLFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+#define GL_DEPTH_STENCIL_EXT                                0x84f9
+#define GL_UNSIGNED_INT_24_8_EXT                            0x84fa
+#define GL_DEPTH24_STENCIL8_EXT                             0x88f0
+#define GL_TEXTURE_STENCIL_SIZE_EXT                         0x88f1
+#endif
+
 /* GL_EXT_paletted_texture */
 #ifndef GL_EXT_paletted_texture
 #define GL_EXT_paletted_texture 1
-#define GL_COLOR_INDEX1_EXT               0x80E2
-#define GL_COLOR_INDEX2_EXT               0x80E3
-#define GL_COLOR_INDEX4_EXT               0x80E4
-#define GL_COLOR_INDEX8_EXT               0x80E5
-#define GL_COLOR_INDEX12_EXT              0x80E6
-#define GL_COLOR_INDEX16_EXT              0x80E7
-#define GL_TEXTURE_INDEX_SIZE_EXT         0x80ED
-#endif
-typedef void (WINE_GLAPI * PGLFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
+#define GL_COLOR_INDEX1_EXT                                 0x80e2
+#define GL_COLOR_INDEX2_EXT                                 0x80e3
+#define GL_COLOR_INDEX4_EXT                                 0x80e4
+#define GL_COLOR_INDEX8_EXT                                 0x80e5
+#define GL_COLOR_INDEX12_EXT                                0x80e6
+#define GL_COLOR_INDEX16_EXT                                0x80e7
+#define GL_TEXTURE_INDEX_SIZE_EXT                           0x80ed
+#endif
+typedef void (WINE_GLAPI *PGLFNGLCOLORTABLEEXTPROC)(GLenum target, GLenum internalFormat,
+        GLsizei width, GLenum format, GLenum type, const GLvoid *table);
+
 /* GL_EXT_point_parameters */
 #ifndef GL_EXT_point_parameters
 #define GL_EXT_point_parameters 1
-#define GL_POINT_SIZE_MIN_EXT             0x8126
-#define GL_POINT_SIZE_MAX_EXT             0x8127
-#define GL_POINT_FADE_THRESHOLD_SIZE_EXT  0x8128
-#define GL_DISTANCE_ATTENUATION_EXT       0x8129
-#endif
-typedef void (WINE_GLAPI * PGLFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param);
-typedef void (WINE_GLAPI * PGLFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params);
+#define GL_POINT_SIZE_MIN_EXT                               0x8126
+#define GL_POINT_SIZE_MAX_EXT                               0x8127
+#define GL_POINT_FADE_THRESHOLD_SIZE_EXT                    0x8128
+#define GL_DISTANCE_ATTENUATION_EXT                         0x8129
+#endif
+typedef void (WINE_GLAPI *PGLFNGLPOINTPARAMETERFEXTPROC)(GLenum pname, GLfloat param);
+typedef void (WINE_GLAPI *PGLFNGLPOINTPARAMETERFVEXTPROC)(GLenum pname, const GLfloat *params);
 
 /* GL_EXT_provoking_vertex */
@@ -2119,744 +3215,323 @@
 #define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT     0x8e4c
 #endif
-typedef void (WINE_GLAPI * PGLFNGLPROVOKINGVERTEXEXTPROC)(GLenum mode);
+typedef void (WINE_GLAPI *PGLFNGLPROVOKINGVERTEXEXTPROC)(GLenum mode);
+
+/* GL_EXT_secondary_color */
+#ifndef GL_EXT_secondary_color
+#define GL_EXT_secondary_color 1
+#define GL_COLOR_SUM_EXT                                    0x8458
+#define GL_CURRENT_SECONDARY_COLOR_EXT                      0x8459
+#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT                   0x845a
+#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT                   0x845b
+#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT                 0x845c
+#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT                0x845d
+#define GL_SECONDARY_COLOR_ARRAY_EXT                        0x845e
+#endif
+typedef void (WINE_GLAPI *PGLFNGLSECONDARYCOLOR3FEXTPROC)(GLfloat red, GLfloat green, GLfloat blue);
+typedef void (WINE_GLAPI *PGLFNGLSECONDARYCOLOR3FVEXTPROC)(const GLfloat *v);
+typedef void (WINE_GLAPI *PGLFNGLSECONDARYCOLOR3UBEXTPROC)(GLubyte red, GLubyte green, GLubyte blue);
+typedef void (WINE_GLAPI *PGLFNGLSECONDARYCOLOR3UBVEXTPROC)(const GLubyte *v);
+typedef void (WINE_GLAPI *PGLFNGLSECONDARYCOLORPOINTEREXTPROC)(GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer);
+
+/* GL_EXT_stencil_two_side */
+#ifndef GL_EXT_stencil_two_side
+#define GL_EXT_stencil_two_side 1
+#define GL_STENCIL_TEST_TWO_SIDE_EXT                        0x8910
+#define GL_ACTIVE_STENCIL_FACE_EXT                          0x8911
+#endif
+typedef void (WINE_GLAPI *PGLFNACTIVESTENCILFACEEXTPROC)(GLenum face);
+
+/* GL_EXT_stencil_wrap */
+#ifndef GL_EXT_stencil_wrap
+#define GL_EXT_stencil_wrap 1
+#define GL_INCR_WRAP_EXT                                    0x8507
+#define GL_DECR_WRAP_EXT                                    0x8508
+#endif
 
 /* GL_EXT_texture3D */
 #ifndef GL_EXT_texture3D
 #define GL_EXT_texture3D 1
-#define GL_PACK_SKIP_IMAGES_EXT           0x806B
-#define GL_PACK_IMAGE_HEIGHT_EXT          0x806C
-#define GL_UNPACK_SKIP_IMAGES_EXT         0x806D
-#define GL_UNPACK_IMAGE_HEIGHT_EXT        0x806E
-#define GL_TEXTURE_3D_EXT                 0x806F
-#define GL_PROXY_TEXTURE_3D_EXT           0x8070
-#define GL_TEXTURE_DEPTH_EXT              0x8071
-#define GL_TEXTURE_WRAP_R_EXT             0x8072
-#define GL_MAX_3D_TEXTURE_SIZE_EXT        0x8073
-#endif
-typedef void (WINE_GLAPI * PGLFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
-typedef void (WINE_GLAPI * PGLFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
+#define GL_PACK_SKIP_IMAGES_EXT                             0x806b
+#define GL_PACK_IMAGE_HEIGHT_EXT                            0x806c
+#define GL_UNPACK_SKIP_IMAGES_EXT                           0x806d
+#define GL_UNPACK_IMAGE_HEIGHT_EXT                          0x806e
+#define GL_TEXTURE_3D_EXT                                   0x806f
+#define GL_PROXY_TEXTURE_3D_EXT                             0x8070
+#define GL_TEXTURE_DEPTH_EXT                                0x8071
+#define GL_TEXTURE_WRAP_R_EXT                               0x8072
+#define GL_MAX_3D_TEXTURE_SIZE_EXT                          0x8073
+#endif
+typedef void (WINE_GLAPI *PGLFNGLTEXIMAGE3DEXTPROC)(GLenum target, GLint level, GLenum internalformat,
+        GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (WINE_GLAPI *PGLFNGLTEXSUBIMAGE3DEXTPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset,
+        GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
+
+/* GL_EXT_texture_compression_rgtc */
+#ifndef GL_EXT_texture_compression_rgtc
+#define GL_EXT_texture_compression_rgtc 1
+#define GL_COMPRESSED_RED_RGTC1_EXT                         0x8dbb
+#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT                  0x8dbc
+#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT                   0x8dbd
+#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT            0x8dbe
+#endif
+
+/* GL_EXT_texture_compression_s3tc */
+#ifndef GL_EXT_texture_compression_s3tc
+#define GL_EXT_texture_compression_s3tc 1
+#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT                     0x83f0
+#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT                    0x83f1
+#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT                    0x83f2
+#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT                    0x83f3
+#endif
+typedef void (WINE_GLAPI *PGLFNCOMPRESSEDTEXIMAGE3DPROC)(GLenum target, GLint level, GLenum internalformat,
+        GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (WINE_GLAPI *PGLFNCOMPRESSEDTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat,
+        GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (WINE_GLAPI *PGLFNCOMPRESSEDTEXIMAGE1DPROC)(GLenum target, GLint level, GLenum internalformat,
+        GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (WINE_GLAPI *PGLFNCOMPRESSEDTEXSUBIMAGE3DPROC)(GLenum target, GLint level,
+        GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
+        GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (WINE_GLAPI *PGLFNCOMPRESSEDTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset,
+        GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (WINE_GLAPI *PGLFNCOMPRESSEDTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset,
+        GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (WINE_GLAPI *PGLFNGETCOMPRESSEDTEXIMAGEPROC)(GLenum target, GLint level, void *img);
+
 /* GL_EXT_texture_env_combine */
 #ifndef GL_EXT_texture_env_combine
 #define GL_EXT_texture_env_combine 1
-#define GL_COMBINE_EXT                    0x8570
-#define GL_COMBINE_RGB_EXT                0x8571
-#define GL_COMBINE_ALPHA_EXT              0x8572
-#define GL_RGB_SCALE_EXT                  0x8573
-#define GL_ADD_SIGNED_EXT                 0x8574
-#define GL_INTERPOLATE_EXT                0x8575
-#define GL_SUBTRACT_EXT                   0x84E7
-#define GL_CONSTANT_EXT                   0x8576
-#define GL_PRIMARY_COLOR_EXT              0x8577
-#define GL_PREVIOUS_EXT                   0x8578
-#define GL_SOURCE0_RGB_EXT                0x8580
-#define GL_SOURCE1_RGB_EXT                0x8581
-#define GL_SOURCE2_RGB_EXT                0x8582
-#define GL_SOURCE3_RGB_EXT                0x8583
-#define GL_SOURCE4_RGB_EXT                0x8584
-#define GL_SOURCE5_RGB_EXT                0x8585
-#define GL_SOURCE6_RGB_EXT                0x8586
-#define GL_SOURCE7_RGB_EXT                0x8587
-#define GL_SOURCE0_ALPHA_EXT              0x8588
-#define GL_SOURCE1_ALPHA_EXT              0x8589
-#define GL_SOURCE2_ALPHA_EXT              0x858A
-#define GL_SOURCE3_ALPHA_EXT              0x858B
-#define GL_SOURCE4_ALPHA_EXT              0x858C
-#define GL_SOURCE5_ALPHA_EXT              0x858D
-#define GL_SOURCE6_ALPHA_EXT              0x858E
-#define GL_SOURCE7_ALPHA_EXT              0x858F
-#define GL_OPERAND0_RGB_EXT               0x8590
-#define GL_OPERAND1_RGB_EXT               0x8591
-#define GL_OPERAND2_RGB_EXT               0x8592
-#define GL_OPERAND3_RGB_EXT               0x8593
-#define GL_OPERAND4_RGB_EXT               0x8594
-#define GL_OPERAND5_RGB_EXT               0x8595
-#define GL_OPERAND6_RGB_EXT               0x8596
-#define GL_OPERAND7_RGB_EXT               0x8597
-#define GL_OPERAND0_ALPHA_EXT             0x8598
-#define GL_OPERAND1_ALPHA_EXT             0x8599
-#define GL_OPERAND2_ALPHA_EXT             0x859A
-#define GL_OPERAND3_ALPHA_EXT             0x859B
-#define GL_OPERAND4_ALPHA_EXT             0x859C
-#define GL_OPERAND5_ALPHA_EXT             0x859D
-#define GL_OPERAND6_ALPHA_EXT             0x859E
-#define GL_OPERAND7_ALPHA_EXT             0x859F
-#endif
+#define GL_COMBINE_EXT                                      0x8570
+#define GL_COMBINE_RGB_EXT                                  0x8571
+#define GL_COMBINE_ALPHA_EXT                                0x8572
+#define GL_RGB_SCALE_EXT                                    0x8573
+#define GL_ADD_SIGNED_EXT                                   0x8574
+#define GL_INTERPOLATE_EXT                                  0x8575
+#define GL_SUBTRACT_EXT                                     0x84e7
+#define GL_CONSTANT_EXT                                     0x8576
+#define GL_PRIMARY_COLOR_EXT                                0x8577
+#define GL_PREVIOUS_EXT                                     0x8578
+#define GL_SOURCE0_RGB_EXT                                  0x8580
+#define GL_SOURCE1_RGB_EXT                                  0x8581
+#define GL_SOURCE2_RGB_EXT                                  0x8582
+#define GL_SOURCE3_RGB_EXT                                  0x8583
+#define GL_SOURCE4_RGB_EXT                                  0x8584
+#define GL_SOURCE5_RGB_EXT                                  0x8585
+#define GL_SOURCE6_RGB_EXT                                  0x8586
+#define GL_SOURCE7_RGB_EXT                                  0x8587
+#define GL_SOURCE0_ALPHA_EXT                                0x8588
+#define GL_SOURCE1_ALPHA_EXT                                0x8589
+#define GL_SOURCE2_ALPHA_EXT                                0x858a
+#define GL_SOURCE3_ALPHA_EXT                                0x858b
+#define GL_SOURCE4_ALPHA_EXT                                0x858c
+#define GL_SOURCE5_ALPHA_EXT                                0x858d
+#define GL_SOURCE6_ALPHA_EXT                                0x858e
+#define GL_SOURCE7_ALPHA_EXT                                0x858f
+#define GL_OPERAND0_RGB_EXT                                 0x8590
+#define GL_OPERAND1_RGB_EXT                                 0x8591
+#define GL_OPERAND2_RGB_EXT                                 0x8592
+#define GL_OPERAND3_RGB_EXT                                 0x8593
+#define GL_OPERAND4_RGB_EXT                                 0x8594
+#define GL_OPERAND5_RGB_EXT                                 0x8595
+#define GL_OPERAND6_RGB_EXT                                 0x8596
+#define GL_OPERAND7_RGB_EXT                                 0x8597
+#define GL_OPERAND0_ALPHA_EXT                               0x8598
+#define GL_OPERAND1_ALPHA_EXT                               0x8599
+#define GL_OPERAND2_ALPHA_EXT                               0x859a
+#define GL_OPERAND3_ALPHA_EXT                               0x859b
+#define GL_OPERAND4_ALPHA_EXT                               0x859c
+#define GL_OPERAND5_ALPHA_EXT                               0x859d
+#define GL_OPERAND6_ALPHA_EXT                               0x859e
+#define GL_OPERAND7_ALPHA_EXT                               0x859f
+#endif
+
 /* GL_EXT_texture_env_dot3 */
 #ifndef GL_EXT_texture_env_dot3
 #define GL_EXT_texture_env_dot3 1
-#define GL_DOT3_RGB_EXT                   0x8740
-#define GL_DOT3_RGBA_EXT                  0x8741
-#endif
+#define GL_DOT3_RGB_EXT                                     0x8740
+#define GL_DOT3_RGBA_EXT                                    0x8741
+#endif
+
+/* GL_EXT_texture_filter_anisotropic */
+#ifndef GL_EXT_texture_filter_anisotropic
+#define GL_EXT_texture_filter_anisotropic 1
+#define GL_TEXTURE_MAX_ANISOTROPY_EXT                       0x84fe
+#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT                   0x84ff
+#endif
+
 /* GL_EXT_texture_lod_bias */
 #ifndef GL_EXT_texture_lod_bias
 #define GL_EXT_texture_lod_bias 1
-#define GL_MAX_TEXTURE_LOD_BIAS_EXT       0x84FD
-#define GL_TEXTURE_FILTER_CONTROL_EXT     0x8500
-#define GL_TEXTURE_LOD_BIAS_EXT           0x8501
-#endif
-/* GL_ARB_texture_border_clamp */
-#ifndef GL_ARB_texture_border_clamp
-#define GL_ARB_texture_border_clamp 1
-#define GL_CLAMP_TO_BORDER_ARB            0x812D
-#endif
-/* GL_EXT_texture_filter_anisotropic */
-#ifndef GL_EXT_texture_filter_anisotropic
-#define GL_EXT_texture_filter_anisotropic 1
-#define GL_TEXTURE_MAX_ANISOTROPY_EXT     0x84FE
-#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
-#endif
-/* GL_ARB_texture_mirrored_repeat (full support GL1.4) */
-#ifndef GL_ARB_texture_mirrored_repeat
-#define GL_ARB_texture_mirrored_repeat 1
-#define GL_MIRRORED_REPEAT_ARB            0x8370
-#endif
-/* GL_ATI_texture_mirror_once */
-#ifndef GL_ATI_texture_mirror_once
-#define GL_ATI_texture_mirror_once 1
-#define GL_MIRROR_CLAMP_ATI               0x8742
-#define GL_MIRROR_CLAMP_TO_EDGE_ATI       0x8743
-#endif
-/* GL_ARB_texture_env_dot3 */
-#ifndef GL_ARB_texture_env_dot3
-#define GL_ARB_texture_env_dot3 1
-#define GL_DOT3_RGB_ARB                   0x86AE
-#define GL_DOT3_RGBA_ARB                  0x86AF
-#endif
-/* GL_EXT_texture_env_dot3 */
-#ifndef GL_EXT_texture_env_dot3
-#define GL_EXT_texture_env_dot3 1
-#define GL_DOT3_RGB_EXT                   0x8740
-#define GL_DOT3_RGBA_EXT                  0x8741
-#endif
+#define GL_MAX_TEXTURE_LOD_BIAS_EXT                         0x84fd
+#define GL_TEXTURE_FILTER_CONTROL_EXT                       0x8500
+#define GL_TEXTURE_LOD_BIAS_EXT                             0x8501
+#endif
+
 /* GL_EXT_texture_sRGB */
 #ifndef GL_EXT_texture_sRGB
 #define GL_EXT_texture_sRGB 1
-#define GL_SRGB_EXT                            0x8C40
-#define GL_SRGB8_EXT                           0x8C41
-#define GL_SRGB_ALPHA_EXT                      0x8C42
-#define GL_SRGB8_ALPHA8_EXT                    0x8C43
-#define GL_SLUMINANCE_ALPHA_EXT                0x8C44
-#define GL_SLUMINANCE8_ALPHA8_EXT              0x8C45
-#define GL_SLUMINANCE_EXT                      0x8C46
-#define GL_SLUMINANCE8_EXT                     0x8C47
-#define GL_COMPRESSED_SRGB_EXT                 0x8C48
-#define GL_COMPRESSED_SRGB_ALPHA_EXT           0x8C49
-#define GL_COMPRESSED_SLUMINANCE_EXT           0x8C4A
-#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT     0x8C4B
-#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT       0x8C4C
-#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D
-#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E
-#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F
-#endif
-/* GL_ARB_texture_float */
-#ifndef GL_ARB_texture_float
-#define GL_ARB_texture_float 1
-#define GL_RGBA32F_ARB                    0x8814
-#define GL_RGB32F_ARB                     0x8815
-#define GL_RGBA16F_ARB                    0x881A
-#define GL_RGB16F_ARB                     0x881B
-#endif
-/* GL_ARB_texture_rg */
-#ifndef GL_ARB_texture_rg
-#define GL_RG                             0x8227
-#define GL_RG_INTEGER                     0x8228
-#define GL_R8                             0x8229
-#define GL_R16                            0x822A
-#define GL_RG8                            0x822B
-#define GL_RG16                           0x822C
-#define GL_R16F                           0x822D
-#define GL_R32F                           0x822E
-#define GL_RG16F                          0x822F
-#define GL_RG32F                          0x8230
-#define GL_R8I                            0x8231
-#define GL_R8UI                           0x8232
-#define GL_R16I                           0x8233
-#define GL_R16UI                          0x8234
-#define GL_R32I                           0x8235
-#define GL_R32UI                          0x8236
-#define GL_RG8I                           0x8237
-#define GL_RG8UI                          0x8238
-#define GL_RG16I                          0x8239
-#define GL_RG16UI                         0x823A
-#define GL_RG32I                          0x823B
-#define GL_RG32UI                         0x823C
-#endif
-/* GL_EXT_texture_swizzle */
-#ifndef GL_EXT_texture_swizzle
-#define GL_TEXTURE_SWIZZLE_R_EXT          0x8E42
-#define GL_TEXTURE_SWIZZLE_G_EXT          0x8E43
-#define GL_TEXTURE_SWIZZLE_B_EXT          0x8E44
-#define GL_TEXTURE_SWIZZLE_A_EXT          0x8E45
-#define GL_TEXTURE_SWIZZLE_RGBA_EXT       0x8E46
-#endif
-/* GL_ARB_half_float_pixel */
-#ifndef GL_ARB_half_float_pixel
-#define GL_ARB_half_float_pixel
-#define GL_HALF_FLOAT_ARB                 0x140B
-#endif
-/* GL_ARB_vertex_program */
-#ifndef GL_ARB_vertex_program
-#define GL_ARB_vertex_program 1
-#define GL_VERTEX_PROGRAM_ARB             0x8620
-#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB  0x8642
-#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB    0x8643
-#define GL_COLOR_SUM_ARB                  0x8458
-#define GL_PROGRAM_FORMAT_ASCII_ARB       0x8875
-#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622
-#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB   0x8623
-#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624
-#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB   0x8625
-#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A
-#define GL_CURRENT_VERTEX_ATTRIB_ARB      0x8626
-#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645
-#define GL_PROGRAM_LENGTH_ARB             0x8627
-#define GL_PROGRAM_FORMAT_ARB             0x8876
-#define GL_PROGRAM_BINDING_ARB            0x8677
-#define GL_PROGRAM_INSTRUCTIONS_ARB       0x88A0
-#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB   0x88A1
-#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2
-#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3
-#define GL_PROGRAM_TEMPORARIES_ARB        0x88A4
-#define GL_MAX_PROGRAM_TEMPORARIES_ARB    0x88A5
-#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6
-#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7
-#define GL_PROGRAM_PARAMETERS_ARB         0x88A8
-#define GL_MAX_PROGRAM_PARAMETERS_ARB     0x88A9
-#define GL_PROGRAM_NATIVE_PARAMETERS_ARB  0x88AA
-#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB
-#define GL_PROGRAM_ATTRIBS_ARB            0x88AC
-#define GL_MAX_PROGRAM_ATTRIBS_ARB        0x88AD
-#define GL_PROGRAM_NATIVE_ATTRIBS_ARB     0x88AE
-#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF
-#define GL_PROGRAM_ADDRESS_REGISTERS_ARB  0x88B0
-#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1
-#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2
-#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3
-#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4
-#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5
-#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6
-#define GL_PROGRAM_STRING_ARB             0x8628
-#define GL_PROGRAM_ERROR_POSITION_ARB     0x864B
-#define GL_CURRENT_MATRIX_ARB             0x8641
-#define GL_TRANSPOSE_CURRENT_MATRIX_ARB   0x88B7
-#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640
-#define GL_MAX_VERTEX_ATTRIBS_ARB         0x8869
-#define GL_MAX_PROGRAM_MATRICES_ARB       0x862F
-#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E
-#define GL_PROGRAM_ERROR_STRING_ARB       0x8874
-#define GL_MATRIX0_ARB                    0x88C0
-#define GL_MATRIX1_ARB                    0x88C1
-#define GL_MATRIX2_ARB                    0x88C2
-#define GL_MATRIX3_ARB                    0x88C3
-#define GL_MATRIX4_ARB                    0x88C4
-#define GL_MATRIX5_ARB                    0x88C5
-#define GL_MATRIX6_ARB                    0x88C6
-#define GL_MATRIX7_ARB                    0x88C7
-#define GL_MATRIX8_ARB                    0x88C8
-#define GL_MATRIX9_ARB                    0x88C9
-#define GL_MATRIX10_ARB                   0x88CA
-#define GL_MATRIX11_ARB                   0x88CB
-#define GL_MATRIX12_ARB                   0x88CC
-#define GL_MATRIX13_ARB                   0x88CD
-#define GL_MATRIX14_ARB                   0x88CE
-#define GL_MATRIX15_ARB                   0x88CF
-#define GL_MATRIX16_ARB                   0x88D0
-#define GL_MATRIX17_ARB                   0x88D1
-#define GL_MATRIX18_ARB                   0x88D2
-#define GL_MATRIX19_ARB                   0x88D3
-#define GL_MATRIX20_ARB                   0x88D4
-#define GL_MATRIX21_ARB                   0x88D5
-#define GL_MATRIX22_ARB                   0x88D6
-#define GL_MATRIX23_ARB                   0x88D7
-#define GL_MATRIX24_ARB                   0x88D8
-#define GL_MATRIX25_ARB                   0x88D9
-#define GL_MATRIX26_ARB                   0x88DA
-#define GL_MATRIX27_ARB                   0x88DB
-#define GL_MATRIX28_ARB                   0x88DC
-#define GL_MATRIX29_ARB                   0x88DD
-#define GL_MATRIX30_ARB                   0x88DE
-#define GL_MATRIX31_ARB                   0x88DF
-#endif
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
-typedef void (WINE_GLAPI * PGLFNENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index);
-typedef void (WINE_GLAPI * PGLFNDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index);
-typedef void (WINE_GLAPI * PGLFNPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string);
-typedef void (WINE_GLAPI * PGLFNBINDPROGRAMARBPROC) (GLenum target, GLuint program);
-typedef void (WINE_GLAPI * PGLFNDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs);
-typedef void (WINE_GLAPI * PGLFNGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs);
-typedef void (WINE_GLAPI * PGLFNPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-typedef void (WINE_GLAPI * PGLFNPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params);
-typedef void (WINE_GLAPI * PGLFNPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-typedef void (WINE_GLAPI * PGLFNPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params);
-typedef void (WINE_GLAPI * PGLFNPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-typedef void (WINE_GLAPI * PGLFNPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params);
-typedef void (WINE_GLAPI * PGLFNPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-typedef void (WINE_GLAPI * PGLFNPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params);
-typedef void (WINE_GLAPI * PGLFNGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params);
-typedef void (WINE_GLAPI * PGLFNGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params);
-typedef void (WINE_GLAPI * PGLFNGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params);
-typedef void (WINE_GLAPI * PGLFNGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params);
-typedef void (WINE_GLAPI * PGLFNGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (WINE_GLAPI * PGLFNGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string);
-typedef void (WINE_GLAPI * PGLFNGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params);
-typedef void (WINE_GLAPI * PGLFNGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params);
-typedef void (WINE_GLAPI * PGLFNGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params);
-typedef void (WINE_GLAPI * PGLFNGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer);
-typedef GLboolean (WINE_GLAPI * PGLFNISPROGRAMARBPROC) (GLuint program);
-#ifndef GL_ARB_fragment_program
-#define GL_ARB_fragment_program 1
-#define GL_FRAGMENT_PROGRAM_ARB           0x8804
-#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB   0x8805
-#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB   0x8806
-#define GL_PROGRAM_TEX_INDIRECTIONS_ARB   0x8807
-#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808
-#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809
-#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A
-#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B
-#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C
-#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D
-#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E
-#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F
-#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810
-#define GL_MAX_TEXTURE_COORDS_ARB         0x8871
-#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB    0x8872
-/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */
-#endif
-/* GL_ARB_multisample */
-#ifndef GL_ARB_multisample
-#define GL_ARB_multisample 1
-#define GL_MULTISAMPLE_ARB                0x809D
-#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB   0x809E
-#define GL_SAMPLE_ALPHA_TO_ONE_ARB        0x809F
-#define GL_SAMPLE_COVERAGE_ARB            0x80A0
-#define GL_SAMPLE_BUFFERS_ARB             0x80A8
-#define GL_SAMPLES_ARB                    0x80A9
-#define GL_SAMPLE_COVERAGE_VALUE_ARB      0x80AA
-#define GL_SAMPLE_COVERAGE_INVERT_ARB     0x80AB
-#define GL_MULTISAMPLE_BIT_ARB            0x20000000
-#endif
-typedef void (WINE_GLAPI * WINED3D_PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert);
-/* GL_ARB_vertex_buffer_object */
-#ifndef GL_ARB_vertex_buffer_object
-#define GL_ARB_vertex_buffer_object 1
-#define GL_BUFFER_SIZE_ARB                0x8764
-#define GL_BUFFER_USAGE_ARB               0x8765
-#define GL_ARRAY_BUFFER_ARB               0x8892
-#define GL_ELEMENT_ARRAY_BUFFER_ARB       0x8893
-#define GL_ARRAY_BUFFER_BINDING_ARB       0x8894
-#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895
-#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB  0x8896
-#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB  0x8897
-#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB   0x8898
-#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB   0x8899
-#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB   0x889A
-#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB       0x889B
-#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C
-#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB  0x889D
-#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB          0x889E
-#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB   0x889F
-#define GL_READ_ONLY_ARB                  0x88B8
-#define GL_WRITE_ONLY_ARB                 0x88B9
-#define GL_READ_WRITE_ARB                 0x88BA
-#define GL_BUFFER_ACCESS_ARB              0x88BB
-#define GL_BUFFER_MAPPED_ARB              0x88BC
-#define GL_BUFFER_MAP_POINTER_ARB         0x88BD
-#define GL_STREAM_DRAW_ARB                0x88E0
-#define GL_STREAM_READ_ARB                0x88E1
-#define GL_STREAM_COPY_ARB                0x88E2
-#define GL_STATIC_DRAW_ARB                0x88E4
-#define GL_STATIC_READ_ARB                0x88E5
-#define GL_STATIC_COPY_ARB                0x88E6
-#define GL_DYNAMIC_DRAW_ARB               0x88E8
-#define GL_DYNAMIC_READ_ARB               0x88E9
-#define GL_DYNAMIC_COPY_ARB               0x88EA
-#endif
-typedef void (WINE_GLAPI * PGLFNBINDBUFFERARBPROC) (GLenum target, GLuint buffer);
-typedef void (WINE_GLAPI * PGLFNDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers);
-typedef void (WINE_GLAPI * PGLFNGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers);
-typedef GLboolean (WINE_GLAPI * PGLFNISBUFFERARBPROC) (GLuint buffer);
-typedef void (WINE_GLAPI * PGLFNBUFFERDATAARBPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
-typedef void (WINE_GLAPI * PGLFNBUFFERSUBDATAARBPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data);
-typedef void (WINE_GLAPI * PGLFNGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data);
-typedef GLvoid* (WINE_GLAPI * PGLFNMAPBUFFERARBPROC) (GLenum target, GLenum access);
-typedef GLboolean (WINE_GLAPI * PGLFNUNMAPBUFFERARBPROC) (GLenum target);
-typedef void (WINE_GLAPI * PGLFNGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (WINE_GLAPI * PGLFNGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params);
-/* GL_EXT_blend_equation_separate */
-typedef void (WINE_GLAPI * PGLFNBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
-/* GL_EXT_blend_func_separate */
-#ifndef GL_EXT_blend_func_separate
-#define GL_BLEND_DST_RGB_EXT              0x80C8
-#define GL_BLEND_SRC_RGB_EXT              0x80C9
-#define GL_BLEND_DST_ALPHA_EXT            0x80CA
-#define GL_BLEND_SRC_ALPHA_EXT            0x80CB
-#endif
-typedef void (WINE_GLAPI * PGLFNBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha);
-/* GL_EXT_fog_coord */
-#ifndef GL_EXT_fog_coord
-#define GL_EXT_fog_coord 1
-#define GL_FOG_COORDINATE_SOURCE_EXT            0x8450
-#define GL_FOG_COORDINATE_EXT                   0x8451
-#define GL_FRAGMENT_DEPTH_EXT                   0x8452
-#define GL_CURRENT_FOG_COORDINATE_EXT           0x8453
-#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT        0x8454
-#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT      0x8455
-#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT     0x8456
-#define GL_FOG_COORDINATE_ARRAY_EXT             0x8457
-#endif /* GL_EXT_fog_coord */
-typedef void (WINE_GLAPI * PGLFNGLFOGCOORDFEXTPROC) (GLfloat coord);
-typedef void (WINE_GLAPI * PGLFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord);
-typedef void (WINE_GLAPI * PGLFNGLFOGCOORDDEXTPROC) (GLdouble coord);
-typedef void (WINE_GLAPI * PGLFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord);
-typedef void (WINE_GLAPI * PGLFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, GLvoid *data);
-/* GL_ARB_shader_objects (GLSL) */
-#ifndef GL_ARB_shader_objects
-#define GL_ARB_shader_objects 1
-typedef char GLcharARB;
-typedef unsigned int GLhandleARB;
-#define GL_PROGRAM_OBJECT_ARB                   0x8B40
-#define GL_OBJECT_TYPE_ARB                      0x8B4E
-#define GL_OBJECT_SUBTYPE_ARB                   0x8B4F
-#define GL_OBJECT_DELETE_STATUS_ARB             0x8B80
-#define GL_OBJECT_COMPILE_STATUS_ARB            0x8B81
-#define GL_OBJECT_LINK_STATUS_ARB               0x8B82
-#define GL_OBJECT_VALIDATE_STATUS_ARB           0x8B83
-#define GL_OBJECT_INFO_LOG_LENGTH_ARB           0x8B84
-#define GL_OBJECT_ATTACHED_OBJECTS_ARB          0x8B85
-#define GL_OBJECT_ACTIVE_UNIFORMS_ARB           0x8B86
-#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87
-#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB      0x8B88
-#define GL_SHADER_OBJECT_ARB                    0x8B48
-#define GL_FLOAT_VEC2_ARB                       0x8B50
-#define GL_FLOAT_VEC3_ARB                       0x8B51
-#define GL_FLOAT_VEC4_ARB                       0x8B52
-#define GL_INT_VEC2_ARB                         0x8B53
-#define GL_INT_VEC3_ARB                         0x8B54
-#define GL_INT_VEC4_ARB                         0x8B55
-#define GL_BOOL_ARB                             0x8B56
-#define GL_BOOL_VEC2_ARB                        0x8B57
-#define GL_BOOL_VEC3_ARB                        0x8B58
-#define GL_BOOL_VEC4_ARB                        0x8B59
-#define GL_FLOAT_MAT2_ARB                       0x8B5A
-#define GL_FLOAT_MAT3_ARB                       0x8B5B
-#define GL_FLOAT_MAT4_ARB                       0x8B5C
-#define GL_SAMPLER_1D_ARB                       0x8B5D
-#define GL_SAMPLER_2D_ARB                       0x8B5E
-#define GL_SAMPLER_3D_ARB                       0x8B5F
-#define GL_SAMPLER_CUBE_ARB                     0x8B60
-#define GL_SAMPLER_1D_SHADOW_ARB                0x8B61
-#define GL_SAMPLER_2D_SHADOW_ARB                0x8B62
-#define GL_SAMPLER_2D_RECT_ARB                  0x8B63
-#define GL_SAMPELR_2D_RECT_SHADOW_ARB           0x8B64
-#endif
-#ifndef GL_ARB_shading_language_100
-#define GL_ARB_shading_language_100         1
-#define GL_SHADING_LANGUAGE_VERSION_ARB     0x8B8C
-#endif
-#ifndef GL_ARB_fragment_shader
-#define GL_ARB_fragment_shader 1
-#define GL_FRAGMENT_SHADER_ARB                  0x8B30
-#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB  0x8B49
-#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB  0x8B8B
-#endif
-#ifndef GL_ARB_vertex_shader
-#define GL_ARB_vertex_shader 1
-#define GL_VERTEX_SHADER_ARB                        0x8B31
-#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB        0x8B4A
-#define GL_MAX_VARYING_FLOATS_ARB                   0x8B4B
-#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB       0x8B4C
-#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB     0x8B4D
-#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB             0x8B89
-#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB   0x8B8A
-#endif
-typedef void (WINE_GLAPI * WINED3D_PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params);
-typedef void (WINE_GLAPI * WINED3D_PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params);
-typedef GLint (WINE_GLAPI * WINED3D_PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name);
-typedef void (WINE_GLAPI * WINED3D_PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name);
-typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0);
-typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1);
-typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2);
-typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
-typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0);
-typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1);
-typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
-typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
-typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value);
-typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value);
-typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value);
-typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value);
-typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);
-typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);
-typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);
-typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);
-typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (WINE_GLAPI * WINED3D_PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params);
-typedef void (WINE_GLAPI * WINED3D_PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params);
-typedef void (WINE_GLAPI * WINED3D_PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog);
-typedef void (WINE_GLAPI * WINED3D_PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj);
-typedef GLhandleARB (WINE_GLAPI * WINED3D_PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType);
-typedef void (WINE_GLAPI * WINED3D_PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length);
-typedef void (WINE_GLAPI * WINED3D_PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj);
-typedef GLhandleARB (WINE_GLAPI * WINED3D_PFNGLCREATEPROGRAMOBJECTARBPROC) (void);
-typedef void (WINE_GLAPI * WINED3D_PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj);
-typedef void (WINE_GLAPI * WINED3D_PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj);
-typedef void (WINE_GLAPI * WINED3D_PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj);
-typedef void (WINE_GLAPI * WINED3D_PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj);
-typedef void (WINE_GLAPI * WINED3D_PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj);
-typedef void (WINE_GLAPI * WINED3D_PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj);
-typedef GLhandleARB (WINE_GLAPI * WINED3D_PFNGLGETHANDLEARBPROC) (GLenum pname);
-typedef void (WINE_GLAPI * WINED3D_PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source);
-typedef void (WINE_GLAPI * WINED3D_PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name);
-typedef GLint (WINE_GLAPI * WINED3D_PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name);
-/* GL_ARB_pixel_buffer_object */
-#ifndef GL_ARB_pixel_buffer_object
-#define GL_PIXEL_PACK_BUFFER_ARB          0x88EB
-#define GL_PIXEL_UNPACK_BUFFER_ARB        0x88EC
-#define GL_PIXEL_PACK_BUFFER_BINDING_ARB  0x88ED
-#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF
-#endif
-/* GL_EXT_texture */
-#ifndef GL_EXT_texture
-#define GL_EXT_texture 1
-#define GL_ALPHA4_EXT                     0x803B
-#define GL_ALPHA8_EXT                     0x803C
-#define GL_ALPHA12_EXT                    0x803D
-#define GL_ALPHA16_EXT                    0x803E
-#define GL_LUMINANCE4_EXT                 0x803F
-#define GL_LUMINANCE8_EXT                 0x8040
-#define GL_LUMINANCE12_EXT                0x8041
-#define GL_LUMINANCE16_EXT                0x8042
-#define GL_LUMINANCE4_ALPHA4_EXT          0x8043
-#define GL_LUMINANCE6_ALPHA2_EXT          0x8044
-#define GL_LUMINANCE8_ALPHA8_EXT          0x8045
-#define GL_LUMINANCE12_ALPHA4_EXT         0x8046
-#define GL_LUMINANCE12_ALPHA12_EXT        0x8047
-#define GL_LUMINANCE16_ALPHA16_EXT        0x8048
-#define GL_INTENSITY_EXT                  0x8049
-#define GL_INTENSITY4_EXT                 0x804A
-#define GL_INTENSITY8_EXT                 0x804B
-#define GL_INTENSITY12_EXT                0x804C
-#define GL_INTENSITY16_EXT                0x804D
-#define GL_RGB2_EXT                       0x804E
-#define GL_RGB4_EXT                       0x804F
-#define GL_RGB5_EXT                       0x8050
-#define GL_RGB8_EXT                       0x8051
-#define GL_RGB10_EXT                      0x8052
-#define GL_RGB12_EXT                      0x8053
-#define GL_RGB16_EXT                      0x8054
-#define GL_RGBA2_EXT                      0x8055
-#define GL_RGBA4_EXT                      0x8056
-#define GL_RGB5_A1_EXT                    0x8057
-#define GL_RGBA8_EXT                      0x8058
-#define GL_RGB10_A2_EXT                   0x8059
-#define GL_RGBA12_EXT                     0x805A
-#define GL_RGBA16_EXT                     0x805B
-#define GL_TEXTURE_RED_SIZE_EXT           0x805C
-#define GL_TEXTURE_GREEN_SIZE_EXT         0x805D
-#define GL_TEXTURE_BLUE_SIZE_EXT          0x805E
-#define GL_TEXTURE_ALPHA_SIZE_EXT         0x805F
-#define GL_TEXTURE_LUMINANCE_SIZE_EXT     0x8060
-#define GL_TEXTURE_INTENSITY_SIZE_EXT     0x8061
-#define GL_REPLACE_EXT                    0x8062
-#define GL_PROXY_TEXTURE_1D_EXT           0x8063
-#define GL_PROXY_TEXTURE_2D_EXT           0x8064
-#define GL_TEXTURE_TOO_LARGE_EXT          0x8065
-#endif
-/* GL_EXT_texture_compression_s3tc */
-#ifndef GL_EXT_texture_compression_s3tc
-#define GL_EXT_texture_compression_s3tc 1
-#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT   0x83F0
-#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT  0x83F1
-#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT  0x83F2
-#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT  0x83F3
-#endif
-typedef void (WINE_GLAPI * PGLFNCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
-typedef void (WINE_GLAPI * PGLFNCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
-typedef void (WINE_GLAPI * PGLFNCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
-typedef void (WINE_GLAPI * PGLFNCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
-typedef void (WINE_GLAPI * PGLFNCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
-typedef void (WINE_GLAPI * PGLFNCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);
-typedef void (WINE_GLAPI * PGLFNGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, void *img);
-/* GL_EXT_stencil_wrap */
-#ifndef GL_EXT_stencil_wrap
-#define GL_EXT_stencil_wrap 1
-#define GL_INCR_WRAP_EXT                  0x8507
-#define GL_DECR_WRAP_EXT                  0x8508
-#endif
-
-/* GL_ARB_half_float_vertex */
-#ifndef GL_ARB_half_float_vertex
-#define GL_ARB_half_float_vertex
-/* No _ARB, see extension spec */
-#define GL_HALF_FLOAT                     0x140B
-#endif
+#define GL_SRGB_EXT                                         0x8c40
+#define GL_SRGB8_EXT                                        0x8c41
+#define GL_SRGB_ALPHA_EXT                                   0x8c42
+#define GL_SRGB8_ALPHA8_EXT                                 0x8c43
+#define GL_SLUMINANCE_ALPHA_EXT                             0x8c44
+#define GL_SLUMINANCE8_ALPHA8_EXT                           0x8c45
+#define GL_SLUMINANCE_EXT                                   0x8c46
+#define GL_SLUMINANCE8_EXT                                  0x8c47
+#define GL_COMPRESSED_SRGB_EXT                              0x8c48
+#define GL_COMPRESSED_SRGB_ALPHA_EXT                        0x8c49
+#define GL_COMPRESSED_SLUMINANCE_EXT                        0x8c4a
+#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT                  0x8c4b
+#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT                    0x8c4c
+#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT              0x8c4d
+#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT              0x8c4e
+#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT              0x8c4f
+#endif
+
+/* GL_NV_depth_clamp */
+#ifndef GL_NV_depth_clamp
+#define GL_NV_depth_clamp 1
+#define GL_DEPTH_CLAMP_NV                                   0x864f
+#endif
+
+/* GL_NV_fence */
+#ifndef GL_NV_fence
+#define GL_NV_fence 1
+#define GL_ALL_COMPLETED_NV                                 0x84f2
+#define GL_FENCE_STATUS_NV                                  0x84f3
+#define GL_FENCE_CONDITION_NV                               0x84f4
+#endif
+typedef void (WINE_GLAPI *PGLFNGENFENCESNVPROC)(GLsizei, GLuint *);
+typedef void (WINE_GLAPI *PGLFNDELETEFENCESNVPROC)(GLuint, const GLuint *);
+typedef void (WINE_GLAPI *PGLFNSETFENCENVPROC)(GLuint, GLenum);
+typedef GLboolean (WINE_GLAPI *PGLFNTESTFENCENVPROC)(GLuint);
+typedef void (WINE_GLAPI *PGLFNFINISHFENCENVPROC)(GLuint);
+typedef GLboolean (WINE_GLAPI *PGLFNISFENCENVPROC)(GLuint);
+typedef void (WINE_GLAPI *PGLFNGETFENCEIVNVPROC)(GLuint, GLenum, GLint *);
+
+/* GL_NV_fog_distance */
+#ifndef GL_NV_fog_distance
+#define GL_NV_fog_distance 1
+#define GL_FOG_DISTANCE_MODE_NV                             0x855a
+#define GL_EYE_RADIAL_NV                                    0x855b
+#define GL_EYE_PLANE_ABSOLUTE_NV                            0x855c
+/* reuse GL_EYE_PLANE */
+#endif
+
 /* GL_NV_half_float */
 #ifndef GL_NV_half_float
 #define GL_NV_half_float 1
 typedef unsigned short GLhalfNV;
-#define GL_HALF_FLOAT_NV                  0x140B
-#endif
-typedef void (WINE_GLAPI * PGLFNVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y);
-typedef void (WINE_GLAPI * PGLFNVERTEX2HVNVPROC) (const GLhalfNV *v);
-typedef void (WINE_GLAPI * PGLFNVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z);
-typedef void (WINE_GLAPI * PGLFNVERTEX3HVNVPROC) (const GLhalfNV *v);
-typedef void (WINE_GLAPI * PGLFNVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w);
-typedef void (WINE_GLAPI * PGLFNVERTEX4HVNVPROC) (const GLhalfNV *v);
-typedef void (WINE_GLAPI * PGLFNNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz);
-typedef void (WINE_GLAPI * PGLFNNORMAL3HVNVPROC) (const GLhalfNV *v);
-typedef void (WINE_GLAPI * PGLFNCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue);
-typedef void (WINE_GLAPI * PGLFNCOLOR3HVNVPROC) (const GLhalfNV *v);
-typedef void (WINE_GLAPI * PGLFNCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha);
-typedef void (WINE_GLAPI * PGLFNCOLOR4HVNVPROC) (const GLhalfNV *v);
-typedef void (WINE_GLAPI * PGLFNTEXCOORD1HNVPROC) (GLhalfNV s);
-typedef void (WINE_GLAPI * PGLFNTEXCOORD1HVNVPROC) (const GLhalfNV *v);
-typedef void (WINE_GLAPI * PGLFNTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t);
-typedef void (WINE_GLAPI * PGLFNTEXCOORD2HVNVPROC) (const GLhalfNV *v);
-typedef void (WINE_GLAPI * PGLFNTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r);
-typedef void (WINE_GLAPI * PGLFNTEXCOORD3HVNVPROC) (const GLhalfNV *v);
-typedef void (WINE_GLAPI * PGLFNTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q);
-typedef void (WINE_GLAPI * PGLFNTEXCOORD4HVNVPROC) (const GLhalfNV *v);
-typedef void (WINE_GLAPI * PGLFNMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s);
-typedef void (WINE_GLAPI * PGLFNMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v);
-typedef void (WINE_GLAPI * PGLFNMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t);
-typedef void (WINE_GLAPI * PGLFNMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v);
-typedef void (WINE_GLAPI * PGLFNMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r);
-typedef void (WINE_GLAPI * PGLFNMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v);
-typedef void (WINE_GLAPI * PGLFNMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q);
-typedef void (WINE_GLAPI * PGLFNMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v);
-typedef void (WINE_GLAPI * PGLFNFOGCOORDHNVPROC) (GLhalfNV fog);
-typedef void (WINE_GLAPI * PGLFNFOGCOORDHVNVPROC) (const GLhalfNV *fog);
-typedef void (WINE_GLAPI * PGLFNSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue);
-typedef void (WINE_GLAPI * PGLFNSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXWEIGHTHNVPROC) (GLhalfNV weight);
-typedef void (WINE_GLAPI * PGLFNVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);
-
-/* GL_NV_fog_distance */
-#ifndef GL_NV_fog_distance
-#define GL_NV_fog_distance 1
-#define GL_FOG_DISTANCE_MODE_NV           0x855A
-#define GL_EYE_RADIAL_NV                  0x855B
-#define GL_EYE_PLANE_ABSOLUTE_NV          0x855C
-/* reuse GL_EYE_PLANE */
-#endif
-/* GL_NV_texgen_reflection */
-#ifndef GL_NV_texgen_reflection
-#define GL_NV_texgen_reflection 1
-#define GL_NORMAL_MAP_NV                  0x8511
-#define GL_REFLECTION_MAP_NV              0x8512
-#endif
-/* GL_NV_texture_env_combine4 */
-#ifndef GL_NV_texture_env_combine4
-#define GL_NV_texture_env_combine4 1
-#define GL_COMBINE4_NV                    0x8503
-#define GL_SOURCE3_RGB_NV                 0x8583
-#define GL_SOURCE3_ALPHA_NV               0x858B
-#define GL_OPERAND3_RGB_NV                0x8593
-#define GL_OPERAND3_ALPHA_NV              0x859B
-#endif
+#define GL_HALF_FLOAT_NV                                    0x140b
+#endif
+typedef void (WINE_GLAPI *PGLFNVERTEX2HNVPROC)(GLhalfNV x, GLhalfNV y);
+typedef void (WINE_GLAPI *PGLFNVERTEX2HVNVPROC)(const GLhalfNV *v);
+typedef void (WINE_GLAPI *PGLFNVERTEX3HNVPROC)(GLhalfNV x, GLhalfNV y, GLhalfNV z);
+typedef void (WINE_GLAPI *PGLFNVERTEX3HVNVPROC)(const GLhalfNV *v);
+typedef void (WINE_GLAPI *PGLFNVERTEX4HNVPROC)(GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w);
+typedef void (WINE_GLAPI *PGLFNVERTEX4HVNVPROC)(const GLhalfNV *v);
+typedef void (WINE_GLAPI *PGLFNNORMAL3HNVPROC)(GLhalfNV nx, GLhalfNV ny, GLhalfNV nz);
+typedef void (WINE_GLAPI *PGLFNNORMAL3HVNVPROC)(const GLhalfNV *v);
+typedef void (WINE_GLAPI *PGLFNCOLOR3HNVPROC)(GLhalfNV red, GLhalfNV green, GLhalfNV blue);
+typedef void (WINE_GLAPI *PGLFNCOLOR3HVNVPROC)(const GLhalfNV *v);
+typedef void (WINE_GLAPI *PGLFNCOLOR4HNVPROC)(GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha);
+typedef void (WINE_GLAPI *PGLFNCOLOR4HVNVPROC)(const GLhalfNV *v);
+typedef void (WINE_GLAPI *PGLFNTEXCOORD1HNVPROC)(GLhalfNV s);
+typedef void (WINE_GLAPI *PGLFNTEXCOORD1HVNVPROC)(const GLhalfNV *v);
+typedef void (WINE_GLAPI *PGLFNTEXCOORD2HNVPROC)(GLhalfNV s, GLhalfNV t);
+typedef void (WINE_GLAPI *PGLFNTEXCOORD2HVNVPROC)(const GLhalfNV *v);
+typedef void (WINE_GLAPI *PGLFNTEXCOORD3HNVPROC)(GLhalfNV s, GLhalfNV t, GLhalfNV r);
+typedef void (WINE_GLAPI *PGLFNTEXCOORD3HVNVPROC)(const GLhalfNV *v);
+typedef void (WINE_GLAPI *PGLFNTEXCOORD4HNVPROC)(GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q);
+typedef void (WINE_GLAPI *PGLFNTEXCOORD4HVNVPROC)(const GLhalfNV *v);
+typedef void (WINE_GLAPI *PGLFNMULTITEXCOORD1HNVPROC)(GLenum target, GLhalfNV s);
+typedef void (WINE_GLAPI *PGLFNMULTITEXCOORD1HVNVPROC)(GLenum target, const GLhalfNV *v);
+typedef void (WINE_GLAPI *PGLFNMULTITEXCOORD2HNVPROC)(GLenum target, GLhalfNV s, GLhalfNV t);
+typedef void (WINE_GLAPI *PGLFNMULTITEXCOORD2HVNVPROC)(GLenum target, const GLhalfNV *v);
+typedef void (WINE_GLAPI *PGLFNMULTITEXCOORD3HNVPROC)(GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r);
+typedef void (WINE_GLAPI *PGLFNMULTITEXCOORD3HVNVPROC)(GLenum target, const GLhalfNV *v);
+typedef void (WINE_GLAPI *PGLFNMULTITEXCOORD4HNVPROC)(GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q);
+typedef void (WINE_GLAPI *PGLFNMULTITEXCOORD4HVNVPROC)(GLenum target, const GLhalfNV *v);
+typedef void (WINE_GLAPI *PGLFNFOGCOORDHNVPROC)(GLhalfNV fog);
+typedef void (WINE_GLAPI *PGLFNFOGCOORDHVNVPROC)(const GLhalfNV *fog);
+typedef void (WINE_GLAPI *PGLFNSECONDARYCOLOR3HNVPROC)(GLhalfNV red, GLhalfNV green, GLhalfNV blue);
+typedef void (WINE_GLAPI *PGLFNSECONDARYCOLOR3HVNVPROC)(const GLhalfNV *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXWEIGHTHNVPROC)(GLhalfNV weight);
+typedef void (WINE_GLAPI *PGLFNVERTEXWEIGHTHVNVPROC)(const GLhalfNV *weight);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1HNVPROC)(GLuint index, GLhalfNV x);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB1HVNVPROC)(GLuint index, const GLhalfNV *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2HNVPROC)(GLuint index, GLhalfNV x, GLhalfNV y);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB2HVNVPROC)(GLuint index, const GLhalfNV *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3HNVPROC)(GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB3HVNVPROC)(GLuint index, const GLhalfNV *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4HNVPROC)(GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIB4HVNVPROC)(GLuint index, const GLhalfNV *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIBS1HVNVPROC)(GLuint index, GLsizei n, const GLhalfNV *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIBS2HVNVPROC)(GLuint index, GLsizei n, const GLhalfNV *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIBS3HVNVPROC)(GLuint index, GLsizei n, const GLhalfNV *v);
+typedef void (WINE_GLAPI *PGLFNVERTEXATTRIBS4HVNVPROC)(GLuint index, GLsizei n, const GLhalfNV *v);
+
+/* GL_NV_light_max_exponent */
+#ifndef GL_NV_light_max_exponent
+#define GL_NV_light_max_exponent 1
+#define GL_MAX_SHININESS_NV                                 0x8504
+#define GL_MAX_SPOT_EXPONENT_NV                             0x8505
+#endif
+
 /* GL_NV_register_combiners */
 #ifndef GL_NV_register_combiners
 #define GL_NV_register_combiners 1
-#define GL_REGISTER_COMBINERS_NV          0x8522
-#define GL_VARIABLE_A_NV                  0x8523
-#define GL_VARIABLE_B_NV                  0x8524
-#define GL_VARIABLE_C_NV                  0x8525
-#define GL_VARIABLE_D_NV                  0x8526
-#define GL_VARIABLE_E_NV                  0x8527
-#define GL_VARIABLE_F_NV                  0x8528
-#define GL_VARIABLE_G_NV                  0x8529
-#define GL_CONSTANT_COLOR0_NV             0x852A
-#define GL_CONSTANT_COLOR1_NV             0x852B
-#define GL_PRIMARY_COLOR_NV               0x852C
-#define GL_SECONDARY_COLOR_NV             0x852D
-#define GL_SPARE0_NV                      0x852E
-#define GL_SPARE1_NV                      0x852F
-#define GL_DISCARD_NV                     0x8530
-#define GL_E_TIMES_F_NV                   0x8531
-#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532
-#define GL_UNSIGNED_IDENTITY_NV           0x8536
-#define GL_UNSIGNED_INVERT_NV             0x8537
-#define GL_EXPAND_NORMAL_NV               0x8538
-#define GL_EXPAND_NEGATE_NV               0x8539
-#define GL_HALF_BIAS_NORMAL_NV            0x853A
-#define GL_HALF_BIAS_NEGATE_NV            0x853B
-#define GL_SIGNED_IDENTITY_NV             0x853C
-#define GL_SIGNED_NEGATE_NV               0x853D
-#define GL_SCALE_BY_TWO_NV                0x853E
-#define GL_SCALE_BY_FOUR_NV               0x853F
-#define GL_SCALE_BY_ONE_HALF_NV           0x8540
-#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV   0x8541
-#define GL_COMBINER_INPUT_NV              0x8542
-#define GL_COMBINER_MAPPING_NV            0x8543
-#define GL_COMBINER_COMPONENT_USAGE_NV    0x8544
-#define GL_COMBINER_AB_DOT_PRODUCT_NV     0x8545
-#define GL_COMBINER_CD_DOT_PRODUCT_NV     0x8546
-#define GL_COMBINER_MUX_SUM_NV            0x8547
-#define GL_COMBINER_SCALE_NV              0x8548
-#define GL_COMBINER_BIAS_NV               0x8549
-#define GL_COMBINER_AB_OUTPUT_NV          0x854A
-#define GL_COMBINER_CD_OUTPUT_NV          0x854B
-#define GL_COMBINER_SUM_OUTPUT_NV         0x854C
-#define GL_MAX_GENERAL_COMBINERS_NV       0x854D
-#define GL_NUM_GENERAL_COMBINERS_NV       0x854E
-#define GL_COLOR_SUM_CLAMP_NV             0x854F
-#define GL_COMBINER0_NV                   0x8550
-#define GL_COMBINER1_NV                   0x8551
-#define GL_COMBINER2_NV                   0x8552
-#define GL_COMBINER3_NV                   0x8553
-#define GL_COMBINER4_NV                   0x8554
-#define GL_COMBINER5_NV                   0x8555
-#define GL_COMBINER6_NV                   0x8556
-#define GL_COMBINER7_NV                   0x8557
+#define GL_REGISTER_COMBINERS_NV                            0x8522
+#define GL_VARIABLE_A_NV                                    0x8523
+#define GL_VARIABLE_B_NV                                    0x8524
+#define GL_VARIABLE_C_NV                                    0x8525
+#define GL_VARIABLE_D_NV                                    0x8526
+#define GL_VARIABLE_E_NV                                    0x8527
+#define GL_VARIABLE_F_NV                                    0x8528
+#define GL_VARIABLE_G_NV                                    0x8529
+#define GL_CONSTANT_COLOR0_NV                               0x852a
+#define GL_CONSTANT_COLOR1_NV                               0x852b
+#define GL_PRIMARY_COLOR_NV                                 0x852c
+#define GL_SECONDARY_COLOR_NV                               0x852d
+#define GL_SPARE0_NV                                        0x852e
+#define GL_SPARE1_NV                                        0x852f
+#define GL_DISCARD_NV                                       0x8530
+#define GL_E_TIMES_F_NV                                     0x8531
+#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV                   0x8532
+#define GL_UNSIGNED_IDENTITY_NV                             0x8536
+#define GL_UNSIGNED_INVERT_NV                               0x8537
+#define GL_EXPAND_NORMAL_NV                                 0x8538
+#define GL_EXPAND_NEGATE_NV                                 0x8539
+#define GL_HALF_BIAS_NORMAL_NV                              0x853a
+#define GL_HALF_BIAS_NEGATE_NV                              0x853b
+#define GL_SIGNED_IDENTITY_NV                               0x853c
+#define GL_SIGNED_NEGATE_NV                                 0x853d
+#define GL_SCALE_BY_TWO_NV                                  0x853e
+#define GL_SCALE_BY_FOUR_NV                                 0x853f
+#define GL_SCALE_BY_ONE_HALF_NV                             0x8540
+#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV                     0x8541
+#define GL_COMBINER_INPUT_NV                                0x8542
+#define GL_COMBINER_MAPPING_NV                              0x8543
+#define GL_COMBINER_COMPONENT_USAGE_NV                      0x8544
+#define GL_COMBINER_AB_DOT_PRODUCT_NV                       0x8545
+#define GL_COMBINER_CD_DOT_PRODUCT_NV                       0x8546
+#define GL_COMBINER_MUX_SUM_NV                              0x8547
+#define GL_COMBINER_SCALE_NV                                0x8548
+#define GL_COMBINER_BIAS_NV                                 0x8549
+#define GL_COMBINER_AB_OUTPUT_NV                            0x854a
+#define GL_COMBINER_CD_OUTPUT_NV                            0x854b
+#define GL_COMBINER_SUM_OUTPUT_NV                           0x854c
+#define GL_MAX_GENERAL_COMBINERS_NV                         0x854d
+#define GL_NUM_GENERAL_COMBINERS_NV                         0x854e
+#define GL_COLOR_SUM_CLAMP_NV                               0x854f
+#define GL_COMBINER0_NV                                     0x8550
+#define GL_COMBINER1_NV                                     0x8551
+#define GL_COMBINER2_NV                                     0x8552
+#define GL_COMBINER3_NV                                     0x8553
+#define GL_COMBINER4_NV                                     0x8554
+#define GL_COMBINER5_NV                                     0x8555
+#define GL_COMBINER6_NV                                     0x8556
+#define GL_COMBINER7_NV                                     0x8557
 /* reuse GL_TEXTURE0_ARB */
 /* reuse GL_TEXTURE1_ARB */
@@ -2865,1278 +3540,966 @@
 /* reuse GL_FOG */
 #endif
-typedef void (WINE_GLAPI * PGLFNCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params);
-typedef void (WINE_GLAPI * PGLFNCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param);
-typedef void (WINE_GLAPI * PGLFNCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params);
-typedef void (WINE_GLAPI * PGLFNCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param);
-typedef void (WINE_GLAPI * PGLFNCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);
-typedef void (WINE_GLAPI * PGLFNCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum);
-typedef void (WINE_GLAPI * PGLFNFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);
-typedef void (WINE_GLAPI * PGLFNGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params);
-typedef void (WINE_GLAPI * PGLFNGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params);
-typedef void (WINE_GLAPI * PGLFNGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params);
-typedef void (WINE_GLAPI * PGLFNGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params);
-typedef void (WINE_GLAPI * PGLFNGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params);
-typedef void (WINE_GLAPI * PGLFNGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params);
+typedef void (WINE_GLAPI *PGLFNCOMBINERPARAMETERFVNVPROC)(GLenum pname, const GLfloat *params);
+typedef void (WINE_GLAPI *PGLFNCOMBINERPARAMETERFNVPROC)(GLenum pname, GLfloat param);
+typedef void (WINE_GLAPI *PGLFNCOMBINERPARAMETERIVNVPROC)(GLenum pname, const GLint *params);
+typedef void (WINE_GLAPI *PGLFNCOMBINERPARAMETERINVPROC)(GLenum pname, GLint param);
+typedef void (WINE_GLAPI *PGLFNCOMBINERINPUTNVPROC)(GLenum stage, GLenum portion,
+        GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);
+typedef void (WINE_GLAPI *PGLFNCOMBINEROUTPUTNVPROC)(GLenum stage, GLenum portion,
+        GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias,
+        GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum);
+typedef void (WINE_GLAPI *PGLFNFINALCOMBINERINPUTNVPROC)(GLenum variable, GLenum input,
+        GLenum mapping, GLenum componentUsage);
+typedef void (WINE_GLAPI *PGLFNGETCOMBINERINPUTPARAMETERFVNVPROC)(GLenum stage, GLenum portion,
+        GLenum variable, GLenum pname, GLfloat *params);
+typedef void (WINE_GLAPI *PGLFNGETCOMBINERINPUTPARAMETERIVNVPROC)(GLenum stage, GLenum portion,
+        GLenum variable, GLenum pname, GLint *params);
+typedef void (WINE_GLAPI *PGLFNGETCOMBINEROUTPUTPARAMETERFVNVPROC)(GLenum stage, GLenum portion,
+        GLenum pname, GLfloat *params);
+typedef void (WINE_GLAPI *PGLFNGETCOMBINEROUTPUTPARAMETERIVNVPROC)(GLenum stage, GLenum portion,
+        GLenum pname, GLint *params);
+typedef void (WINE_GLAPI *PGLFNGETFINALCOMBINERINPUTPARAMETERFVNVPROC)(GLenum variable, GLenum pname, GLfloat *params);
+typedef void (WINE_GLAPI *PGLFNGETFINALCOMBINERINPUTPARAMETERIVNVPROC)(GLenum variable, GLenum pname, GLint *params);
+
 /* GL_NV_register_combiners2 */
 #ifndef GL_NV_register_combiners2
 #define GL_NV_register_combiners2 1
-#define GL_PER_STAGE_CONSTANTS_NV         0x8535
-#endif
-typedef void (WINE_GLAPI * PGLFNCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params);
-typedef void (WINE_GLAPI * PGLFNGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params);
+#define GL_PER_STAGE_CONSTANTS_NV                           0x8535
+#endif
+typedef void (WINE_GLAPI *PGLFNCOMBINERSTAGEPARAMETERFVNVPROC)(GLenum stage, GLenum pname, const GLfloat *params);
+typedef void (WINE_GLAPI *PGLFNGETCOMBINERSTAGEPARAMETERFVNVPROC)(GLenum stage, GLenum pname, GLfloat *params);
+
+/* GL_NV_texgen_reflection */
+#ifndef GL_NV_texgen_reflection
+#define GL_NV_texgen_reflection 1
+#define GL_NORMAL_MAP_NV                                    0x8511
+#define GL_REFLECTION_MAP_NV                                0x8512
+#endif
+
+/* GL_NV_texture_env_combine4 */
+#ifndef GL_NV_texture_env_combine4
+#define GL_NV_texture_env_combine4 1
+#define GL_COMBINE4_NV                                      0x8503
+#define GL_SOURCE3_RGB_NV                                   0x8583
+#define GL_SOURCE3_ALPHA_NV                                 0x858b
+#define GL_OPERAND3_RGB_NV                                  0x8593
+#define GL_OPERAND3_ALPHA_NV                                0x859b
+#endif
+
 /* GL_NV_texture_shader */
 #ifndef GL_NV_texture_shader
 #define GL_NV_texture_shader 1
-#define GL_OFFSET_TEXTURE_RECTANGLE_NV    0x864C
-#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D
-#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E
-#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9
-#define GL_UNSIGNED_INT_S8_S8_8_8_NV      0x86DA
-#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV  0x86DB
-#define GL_DSDT_MAG_INTENSITY_NV          0x86DC
-#define GL_SHADER_CONSISTENT_NV           0x86DD
-#define GL_TEXTURE_SHADER_NV              0x86DE
-#define GL_SHADER_OPERATION_NV            0x86DF
-#define GL_CULL_MODES_NV                  0x86E0
-#define GL_OFFSET_TEXTURE_MATRIX_NV       0x86E1
-#define GL_OFFSET_TEXTURE_SCALE_NV        0x86E2
-#define GL_OFFSET_TEXTURE_BIAS_NV         0x86E3
-#define GL_OFFSET_TEXTURE_2D_MATRIX_NV    GL_OFFSET_TEXTURE_MATRIX_NV
-#define GL_OFFSET_TEXTURE_2D_SCALE_NV     GL_OFFSET_TEXTURE_SCALE_NV
-#define GL_OFFSET_TEXTURE_2D_BIAS_NV      GL_OFFSET_TEXTURE_BIAS_NV
-#define GL_PREVIOUS_TEXTURE_INPUT_NV      0x86E4
-#define GL_CONST_EYE_NV                   0x86E5
-#define GL_PASS_THROUGH_NV                0x86E6
-#define GL_CULL_FRAGMENT_NV               0x86E7
-#define GL_OFFSET_TEXTURE_2D_NV           0x86E8
-#define GL_DEPENDENT_AR_TEXTURE_2D_NV     0x86E9
-#define GL_DEPENDENT_GB_TEXTURE_2D_NV     0x86EA
-#define GL_DOT_PRODUCT_NV                 0x86EC
-#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV   0x86ED
-#define GL_DOT_PRODUCT_TEXTURE_2D_NV      0x86EE
-#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0
-#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1
-#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2
-#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3
-#define GL_HILO_NV                        0x86F4
-#define GL_DSDT_NV                        0x86F5
-#define GL_DSDT_MAG_NV                    0x86F6
-#define GL_DSDT_MAG_VIB_NV                0x86F7
-#define GL_HILO16_NV                      0x86F8
-#define GL_SIGNED_HILO_NV                 0x86F9
-#define GL_SIGNED_HILO16_NV               0x86FA
-#define GL_SIGNED_RGBA_NV                 0x86FB
-#define GL_SIGNED_RGBA8_NV                0x86FC
-#define GL_SIGNED_RGB_NV                  0x86FE
-#define GL_SIGNED_RGB8_NV                 0x86FF
-#define GL_SIGNED_LUMINANCE_NV            0x8701
-#define GL_SIGNED_LUMINANCE8_NV           0x8702
-#define GL_SIGNED_LUMINANCE_ALPHA_NV      0x8703
-#define GL_SIGNED_LUMINANCE8_ALPHA8_NV    0x8704
-#define GL_SIGNED_ALPHA_NV                0x8705
-#define GL_SIGNED_ALPHA8_NV               0x8706
-#define GL_SIGNED_INTENSITY_NV            0x8707
-#define GL_SIGNED_INTENSITY8_NV           0x8708
-#define GL_DSDT8_NV                       0x8709
-#define GL_DSDT8_MAG8_NV                  0x870A
-#define GL_DSDT8_MAG8_INTENSITY8_NV       0x870B
-#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV   0x870C
-#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D
-#define GL_HI_SCALE_NV                    0x870E
-#define GL_LO_SCALE_NV                    0x870F
-#define GL_DS_SCALE_NV                    0x8710
-#define GL_DT_SCALE_NV                    0x8711
-#define GL_MAGNITUDE_SCALE_NV             0x8712
-#define GL_VIBRANCE_SCALE_NV              0x8713
-#define GL_HI_BIAS_NV                     0x8714
-#define GL_LO_BIAS_NV                     0x8715
-#define GL_DS_BIAS_NV                     0x8716
-#define GL_DT_BIAS_NV                     0x8717
-#define GL_MAGNITUDE_BIAS_NV              0x8718
-#define GL_VIBRANCE_BIAS_NV               0x8719
-#define GL_TEXTURE_BORDER_VALUES_NV       0x871A
-#define GL_TEXTURE_HI_SIZE_NV             0x871B
-#define GL_TEXTURE_LO_SIZE_NV             0x871C
-#define GL_TEXTURE_DS_SIZE_NV             0x871D
-#define GL_TEXTURE_DT_SIZE_NV             0x871E
-#define GL_TEXTURE_MAG_SIZE_NV            0x871F
-#endif
+#define GL_OFFSET_TEXTURE_RECTANGLE_NV                      0x864c
+#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV                0x864d
+#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV                 0x864e
+#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV             0x86d9
+#define GL_UNSIGNED_INT_S8_S8_8_8_NV                        0x86da
+#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV                    0x86db
+#define GL_DSDT_MAG_INTENSITY_NV                            0x86dc
+#define GL_SHADER_CONSISTENT_NV                             0x86dd
+#define GL_TEXTURE_SHADER_NV                                0x86de
+#define GL_SHADER_OPERATION_NV                              0x86df
+#define GL_CULL_MODES_NV                                    0x86e0
+#define GL_OFFSET_TEXTURE_MATRIX_NV                         0x86e1
+#define GL_OFFSET_TEXTURE_SCALE_NV                          0x86e2
+#define GL_OFFSET_TEXTURE_BIAS_NV                           0x86e3
+#define GL_OFFSET_TEXTURE_2D_MATRIX_NV                      GL_OFFSET_TEXTURE_MATRIX_NV
+#define GL_OFFSET_TEXTURE_2D_SCALE_NV                       GL_OFFSET_TEXTURE_SCALE_NV
+#define GL_OFFSET_TEXTURE_2D_BIAS_NV                        GL_OFFSET_TEXTURE_BIAS_NV
+#define GL_PREVIOUS_TEXTURE_INPUT_NV                        0x86e4
+#define GL_CONST_EYE_NV                                     0x86e5
+#define GL_PASS_THROUGH_NV                                  0x86e6
+#define GL_CULL_FRAGMENT_NV                                 0x86e7
+#define GL_OFFSET_TEXTURE_2D_NV                             0x86e8
+#define GL_DEPENDENT_AR_TEXTURE_2D_NV                       0x86e9
+#define GL_DEPENDENT_GB_TEXTURE_2D_NV                       0x86ea
+#define GL_DOT_PRODUCT_NV                                   0x86ec
+#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV                     0x86ed
+#define GL_DOT_PRODUCT_TEXTURE_2D_NV                        0x86ee
+#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV                  0x86f0
+#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV                  0x86f1
+#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV                  0x86f2
+#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV        0x86f3
+#define GL_HILO_NV                                          0x86f4
+#define GL_DSDT_NV                                          0x86f5
+#define GL_DSDT_MAG_NV                                      0x86f6
+#define GL_DSDT_MAG_VIB_NV                                  0x86f7
+#define GL_HILO16_NV                                        0x86f8
+#define GL_SIGNED_HILO_NV                                   0x86f9
+#define GL_SIGNED_HILO16_NV                                 0x86fa
+#define GL_SIGNED_RGBA_NV                                   0x86fb
+#define GL_SIGNED_RGBA8_NV                                  0x86fc
+#define GL_SIGNED_RGB_NV                                    0x86fe
+#define GL_SIGNED_RGB8_NV                                   0x86ff
+#define GL_SIGNED_LUMINANCE_NV                              0x8701
+#define GL_SIGNED_LUMINANCE8_NV                             0x8702
+#define GL_SIGNED_LUMINANCE_ALPHA_NV                        0x8703
+#define GL_SIGNED_LUMINANCE8_ALPHA8_NV                      0x8704
+#define GL_SIGNED_ALPHA_NV                                  0x8705
+#define GL_SIGNED_ALPHA8_NV                                 0x8706
+#define GL_SIGNED_INTENSITY_NV                              0x8707
+#define GL_SIGNED_INTENSITY8_NV                             0x8708
+#define GL_DSDT8_NV                                         0x8709
+#define GL_DSDT8_MAG8_NV                                    0x870a
+#define GL_DSDT8_MAG8_INTENSITY8_NV                         0x870b
+#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV                     0x870c
+#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV                   0x870d
+#define GL_HI_SCALE_NV                                      0x870e
+#define GL_LO_SCALE_NV                                      0x870f
+#define GL_DS_SCALE_NV                                      0x8710
+#define GL_DT_SCALE_NV                                      0x8711
+#define GL_MAGNITUDE_SCALE_NV                               0x8712
+#define GL_VIBRANCE_SCALE_NV                                0x8713
+#define GL_HI_BIAS_NV                                       0x8714
+#define GL_LO_BIAS_NV                                       0x8715
+#define GL_DS_BIAS_NV                                       0x8716
+#define GL_DT_BIAS_NV                                       0x8717
+#define GL_MAGNITUDE_BIAS_NV                                0x8718
+#define GL_VIBRANCE_BIAS_NV                                 0x8719
+#define GL_TEXTURE_BORDER_VALUES_NV                         0x871a
+#define GL_TEXTURE_HI_SIZE_NV                               0x871b
+#define GL_TEXTURE_LO_SIZE_NV                               0x871c
+#define GL_TEXTURE_DS_SIZE_NV                               0x871d
+#define GL_TEXTURE_DT_SIZE_NV                               0x871e
+#define GL_TEXTURE_MAG_SIZE_NV                              0x871f
+#endif
+
 /* GL_NV_texture_shader2 */
 #ifndef GL_NV_texture_shader2
 #define GL_NV_texture_shader2 1
-#define GL_DOT_PRODUCT_TEXTURE_3D_NV      0x86EF
-#endif
-/* GL_NV_texture_shader3 */
-#ifndef GL_NV_texture_shader3
-#define GL_NV_texture_shader3 1
-#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850
-#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851
-#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852
-#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853
-#define GL_OFFSET_HILO_TEXTURE_2D_NV      0x8854
-#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855
-#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856
-#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857
-#define GL_DEPENDENT_HILO_TEXTURE_2D_NV   0x8858
-#define GL_DEPENDENT_RGB_TEXTURE_3D_NV    0x8859
-#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A
-#define GL_DOT_PRODUCT_PASS_THROUGH_NV    0x885B
-#define GL_DOT_PRODUCT_TEXTURE_1D_NV      0x885C
-#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D
-#define GL_HILO8_NV                       0x885E
-#define GL_SIGNED_HILO8_NV                0x885F
-#define GL_FORCE_BLUE_TO_ONE_NV           0x8860
-#endif
-/* GL_ATI_texture_env_combine3 */
-#ifndef GL_ATI_texture_env_combine3
-#define GL_ATI_texture_env_combine3 1
-#define GL_MODULATE_ADD_ATI               0x8744
-#define GL_MODULATE_SIGNED_ADD_ATI        0x8745
-#define GL_MODULATE_SUBTRACT_ATI          0x8746
-/* #define ONE */
-/* #define ZERO */
-#endif
-
-/**
- * Point sprites
- */
-/* GL_ARB_point_sprite */
-#ifndef GL_ARB_point_sprite
-#define GL_ARB_point_sprite 1
-#define GL_POINT_SPRITE_ARB               0x8861
-#define GL_COORD_REPLACE_ARB              0x8862
-#endif
-/**
- * @TODO: GL_NV_point_sprite
- */
-
-/**
- * Occlusion Queries
- */
-/* GL_ARB_occlusion_query */
-#ifndef GL_ARB_occlusion_query
-#define GL_ARB_occlusion_query 1
-#define GL_SAMPLES_PASSED_ARB                             0x8914
-#define GL_QUERY_COUNTER_BITS_ARB                         0x8864
-#define GL_CURRENT_QUERY_ARB                              0x8865
-#define GL_QUERY_RESULT_ARB                               0x8866
-#define GL_QUERY_RESULT_AVAILABLE_ARB                     0x8867
-#endif
-typedef void (WINE_GLAPI * PGLFNGENQUERIESARBPROC) (GLsizei n, GLuint *queries);
-typedef void (WINE_GLAPI * PGLFNDELETEQUERIESARBPROC) (GLsizei n, const GLuint *queries);
-typedef GLboolean (WINE_GLAPI * PGLFNISQUERYARBPROC) (GLuint query);
-typedef void (WINE_GLAPI * PGLFNBEGINQUERYARBPROC) (GLenum target, GLuint query);
-typedef void (WINE_GLAPI * PGLFNENDQUERYARBPROC) (GLenum target);
-typedef void (WINE_GLAPI * PGLFNGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (WINE_GLAPI * PGLFNGETQUERYOBJECTIVARBPROC) (GLuint query, GLenum pname, GLint *params);
-typedef void (WINE_GLAPI * PGLFNGETQUERYOBJECTUIVARBPROC) (GLuint query, GLenum pname, GLuint *params);
-/* GL_HP_occlusion_test isn't complete, but it's constants are used by GL_NV_occlusion_query */
-#ifndef GL_HP_occlusion_test
-#define GL_HP_occlusion_test 1
-#define GL_OCCLUSION_TEST_HP                 0x8165
-#define GL_OCCLUSION_TEST_RESULT_HP          0x8165
-#endif
-/*  GL_NV_occlusion_query */
-#ifndef GL_NV_occlusion_query
-#define GL_NV_occlusion_query 1
-#define GL_PIXEL_COUNTER_BITS_NV          0x8864
-#define GL_CURRENT_OCCLUSION_QUERY_ID_NV  0x8865
-#define GL_PIXEL_COUNT_NV                 0x8866
-#define GL_PIXEL_COUNT_AVAILABLE_NV       0x8867
-#endif
-typedef void (WINE_GLAPI * PGLFNGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids);
-typedef void (WINE_GLAPI * PGLFNDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids);
-typedef GLboolean (WINE_GLAPI * PGLFNISOCCLUSIONQUERYNVPROC) (GLuint id);
-typedef void (WINE_GLAPI * PGLFNBEGINOCCLUSIONQUERYNVPROC) (GLuint id);
-typedef void (WINE_GLAPI * PGLFNENDOCCLUSIONQUERYNVPROC) (void);
-typedef void (WINE_GLAPI * PGLFNGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params);
-typedef void (WINE_GLAPI * PGLFNGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params);
-/* GL_EXT_stencil_two_side */
-#ifndef GL_EXT_stencil_two_side
-#define GL_EXT_stencil_two_side 1
-#define GL_STENCIL_TEST_TWO_SIDE_EXT      0x8910
-#define GL_ACTIVE_STENCIL_FACE_EXT        0x8911
-#endif
-typedef void (WINE_GLAPI * PGLFNACTIVESTENCILFACEEXTPROC) (GLenum face);
-/* GL_ATI_separate_stencil */
-#ifndef GL_ATI_separate_stencil
-#define GL_ATI_separate_stencil 1
-#define GL_STENCIL_BACK_FUNC_ATI          0x8800
-#define GL_STENCIL_BACK_FAIL_ATI          0x8801
-#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802
-#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803
-#endif
-typedef void (WINE_GLAPI * PGLFNSTENCILOPSEPARATEATIPROC) (GLenum, GLenum, GLenum, GLenum);
-typedef void (WINE_GLAPI * PGLFNSTENCILFUNCSEPARATEATIPROC) (GLenum, GLenum, GLint, GLuint);
-/* GL_NV_fence */
-#ifndef GL_NV_fence
-#define GL_NV_fence 1
-#define GL_ALL_COMPLETED_NV                 0x84F2
-#define GL_FENCE_STATUS_NV                  0x84F3
-#define GL_FENCE_CONDITION_NV               0x84F4
-#endif
-typedef void (WINE_GLAPI * PGLFNGENFENCESNVPROC) (GLsizei, GLuint *);
-typedef void (WINE_GLAPI * PGLFNDELETEFENCESNVPROC) (GLuint, const GLuint *);
-typedef void (WINE_GLAPI * PGLFNSETFENCENVPROC) (GLuint, GLenum);
-typedef GLboolean (WINE_GLAPI * PGLFNTESTFENCENVPROC) (GLuint);
-typedef void (WINE_GLAPI * PGLFNFINISHFENCENVPROC) (GLuint);
-typedef GLboolean (WINE_GLAPI * PGLFNISFENCENVPROC) (GLuint);
-typedef void (WINE_GLAPI * PGLFNGETFENCEIVNVPROC) (GLuint, GLenum, GLint *);
-/* GL_APPLE_fence */
-#ifndef GL_APPLE_fence
-#define GL_APPLE_fence 1
-#define GL_DRAW_PIXELS_APPLE                0x8A0A
-#define GL_FENCE_APPLE                      0x8A0B
-#endif
-typedef void (WINE_GLAPI * PGLFNGENFENCESAPPLEPROC) (GLsizei, GLuint *);
-typedef void (WINE_GLAPI * PGLFNDELETEFENCESAPPLEPROC) (GLuint, const GLuint *);
-typedef void (WINE_GLAPI * PGLFNSETFENCEAPPLEPROC) (GLuint);
-typedef GLboolean (WINE_GLAPI * PGLFNTESTFENCEAPPLEPROC) (GLuint);
-typedef void (WINE_GLAPI * PGLFNFINISHFENCEAPPLEPROC) (GLuint);
-typedef GLboolean (WINE_GLAPI * PGLFNISFENCEAPPLEPROC) (GLuint);
-typedef GLboolean (WINE_GLAPI * PGLFNTESTOBJECTAPPLEPROC) (GLenum, GLuint);
-typedef void (WINE_GLAPI * PGLFNFINISHOBJECTAPPLEPROC) (GLenum, GLuint);
-/* GL_APPLE_client_storage */
-#ifndef GL_APPLE_client_storage
-#define GL_APPLE_client_storage 1
-#define GL_UNPACK_CLIENT_STORAGE_APPLE      0x85B2
-#endif
-/* GLX_SGI_video_sync */
-typedef int (WINE_GLAPI * PGLXFNGETVIDEOSYNCSGIPROC) (unsigned int *);
-typedef int (WINE_GLAPI * PGLXFNWAITVIDEOSYNCSGIPROC) (int, int, unsigned int *);
+#define GL_DOT_PRODUCT_TEXTURE_3D_NV                        0x86ef
+#endif
+
+/* GL_NV_vertex_program2_option */
+#ifndef GL_NV_vertex_program2_option
+#define GL_NV_vertex_program2_option 1
+#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV                 0x88f4
+#define GL_MAX_PROGRAM_CALL_DEPTH_NV                        0x88f5
+#endif
 
 /* GL_SGIS_generate_mipmap */
 #ifndef GLX_SGIS_generate_mipmap
-#define GL_GENERATE_MIPMAP_SGIS             0x8191
-#define GL_GENERATE_MIPMAP_HINT_SGIS        0x8192
-#define GLX_SGIS_generate_mipmap
-#endif
-
-/* GL_NV_depth_clamp */
-#ifndef GL_NV_depth_clamp
-#define GL_DEPTH_CLAMP_NV                   0x864F
-#endif
-
-/* GL_APPLE_flush_render */
-typedef void (WINE_GLAPI * PGLFNFLUSHRENDERAPPLEPROC) (void);
-typedef void (WINE_GLAPI * PGLFNFINISHRENDERAPPLEPROC) (void);
-
-/* GL_APPLE_ycbcr_422 */
-#ifndef GL_APPLE_ycbcr_422
-#define GL_APPLE_ycbcr_422
-#define GL_YCBCR_422_APPLE                  0x85B9
-#define UNSIGNED_SHORT_8_8_APPLE            0x85BA
-#define UNSIGNED_SHORT_8_8_REV_APPLE        0x85BB
-#endif
-
-/* GL_ARB_texture_rectangle */
-#ifndef GL_ARB_texture_rectangle
-#define GL_ARB_texture_rectangle
-#define GL_TEXTURE_RECTANGLE_ARB            0x84F5
-#define GL_TEXTURE_BINDING_RECTANGLE_ARB    0x84F6
-#define GL_PROXY_TEXTURE_RECTANGLE_ARB      0x84F7
-#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB   0x84F8
-#define GL_SAMPLER_2D_RECT_ARB              0x8B63
-#define GL_SAMPLER_2D_RECT_SHADOW_ARB       0x8B64
-#endif
-
-/* GL_APPLE_float_pixels */
-#ifndef GL_APPLE_float_pixels
-#define GL_APPLE_float_pixels
-#define GL_HALF_APPLE                       0x140B
-#define GL_COLOR_FLOAT_APPLE                0x8A0F
-#define GL_RGBA_FLOAT32_APPLE               0x8814
-#define GL_RGB_FLOAT32_APPLE                0x8815
-#define GL_ALPHA_FLOAT32_APPLE              0x8816
-#define GL_INTENSITY_FLOAT32_APPLE          0x8817
-#define GL_LUMINANCE_FLOAT32_APPLE          0x8818
-#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE    0x8819
-#define GL_RGBA_FLOAT16_APPLE               0x881A
-#define GL_RGB_FLOAT16_APPLE                0x881B
-#define GL_ALPHA_FLOAT16_APPLE              0x881C
-#define GL_INTENSITY_FLOAT16_APPLE          0x881D
-#define GL_LUMINANCE_FLOAT16_APPLE          0x881E
-#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE    0x881F
-#endif
-
-/* GL_EXT_gpu_program_parameters */
-#ifndef GL_EXT_gpu_program_parameters
-#define GL_EXT_gpu_program_parameters
-typedef void (WINE_GLAPI * PGLFNPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const float *params);
-typedef void (WINE_GLAPI * PGLFNPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const float *params);
-#endif
-
-/* GL_NV_light_max_exponent */
-#ifndef GL_NV_light_max_exponent
-#define GL_NV_light_max_exponent
-#define GL_MAX_SHININESS_NV                 0x8504
-#define GL_MAX_SPOT_EXPONENT_NV             0x8505
-#endif
-
-/* GL_ATI_fragment_shader */
-#ifndef GL_ATI_fragment_shader
-#define GL_ATI_fragment_shader
-typedef GLuint (WINE_GLAPI *PGLFNGENFRAGMENTSHADERSATI) (GLuint range);
-typedef void (WINE_GLAPI *PGLFNBINDFRAGMENTSHADERATI) (GLuint id);
-typedef void (WINE_GLAPI *PGLFNDELETEFRAGMENTSHADERATI) (GLuint id);
-typedef void (WINE_GLAPI *PGLFNBEGINFRAGMENTSHADERATI) (void);
-typedef void (WINE_GLAPI *PGLFNENDFRAGMENTSHADERATI) (void);
-typedef void (WINE_GLAPI *PGLFNPASSTEXCOORDATI) (GLuint dst, GLuint coord, GLenum swizzle);
-typedef void (WINE_GLAPI *PGLFNSAMPLEMAPATI) (GLuint dst, GLuint interp, GLenum swizzle);
-typedef void (WINE_GLAPI *PGLFNCOLORFRAGMENTOP1ATI) (GLenum op, GLuint dst, GLuint dstMask,
-                                                     GLuint dstMod, GLuint arg1, GLuint arg1Rep,
-                                                     GLuint arg1Mod);
-typedef void (WINE_GLAPI *PGLFNCOLORFRAGMENTOP2ATI) (GLenum op, GLuint dst, GLuint dstMask,
-                                                     GLuint dstMod, GLuint arg1, GLuint arg1Rep,
-                                                     GLuint arg1Mod, GLuint arg2, GLuint arg2Rep,
-                                                     GLuint arg2Mod);
-typedef void (WINE_GLAPI *PGLFNCOLORFRAGMENTOP3ATI) (GLenum op, GLuint dst, GLuint dstMask,
-                                                     GLuint dstMod, GLuint arg1, GLuint arg1Rep,
-                                                     GLuint arg1Mod, GLuint arg2, GLuint arg2Rep,
-                                                     GLuint arg2Mod, GLuint arg3, GLuint arg3Rep,
-                                                     GLuint arg3Mod);
-typedef void (WINE_GLAPI *PGLFNALPHAFRAGMENTOP1ATI) (GLenum op, GLuint dst, GLuint dstMod,
-                                                     GLuint arg1, GLuint arg1Rep, GLuint arg1Mod);
-typedef void (WINE_GLAPI *PGLFNALPHAFRAGMENTOP2ATI) (GLenum op, GLuint dst, GLuint dstMod,
-                                                     GLuint arg1, GLuint arg1Rep, GLuint arg1Mod,
-                                                     GLuint arg2, GLuint arg2Rep, GLuint arg2Mod);
-typedef void (WINE_GLAPI *PGLFNALPHAFRAGMENTOP3ATI) (GLenum op, GLuint dst, GLuint dstMod,
-                                                     GLuint arg1, GLuint arg1Rep, GLuint arg1Mod,
-                                                     GLuint arg2, GLuint arg2Rep, GLuint arg2Mod,
-                                                     GLuint arg3, GLuint arg3Rep, GLuint arg3Mod);
-typedef void (WINE_GLAPI *PGLFNSETFRAGMENTSHADERCONSTANTATI) (GLuint dst, const GLfloat *value);
-#define GL_FRAGMENT_SHADER_ATI              0x8920
-#define GL_REG_0_ATI                        0x8921
-#define GL_REG_1_ATI                        0x8922
-#define GL_REG_2_ATI                        0x8923
-#define GL_REG_3_ATI                        0x8924
-#define GL_REG_4_ATI                        0x8925
-#define GL_REG_5_ATI                        0x8926
-#define GL_CON_0_ATI                        0x8941
-#define GL_CON_1_ATI                        0x8942
-#define GL_CON_2_ATI                        0x8943
-#define GL_CON_3_ATI                        0x8944
-#define GL_CON_4_ATI                        0x8945
-#define GL_CON_5_ATI                        0x8946
-#define GL_CON_6_ATI                        0x8947
-#define GL_CON_7_ATI                        0x8948
-#define GL_MOV_ATI                          0x8961
-#define GL_ADD_ATI                          0x8963
-#define GL_MUL_ATI                          0x8964
-#define GL_SUB_ATI                          0x8965
-#define GL_DOT3_ATI                         0x8966
-#define GL_DOT4_ATI                         0x8967
-#define GL_MAD_ATI                          0x8968
-#define GL_LERP_ATI                         0x8969
-#define GL_CND_ATI                          0x896A
-#define GL_CND0_ATI                         0x896B
-#define GL_DOT2_ADD_ATI                     0x896C
-#define GL_SECONDARY_INTERPOLATOR_ATI       0x896D
-#define GL_SWIZZLE_STR_ATI                  0x8976
-#define GL_SWIZZLE_STQ_ATI                  0x8977
-#define GL_SWIZZLE_STR_DR_ATI               0x8978
-#define GL_SWIZZLE_STQ_DQ_ATI               0x8979
-#define GL_RED_BIT_ATI                      0x00000001
-#define GL_GREEN_BIT_ATI                    0x00000002
-#define GL_BLUE_BIT_ATI                     0x00000004
-#define GL_2X_BIT_ATI                       0x00000001
-#define GL_4X_BIT_ATI                       0x00000002
-#define GL_8X_BIT_ATI                       0x00000004
-#define GL_HALF_BIT_ATI                     0x00000008
-#define GL_QUARTER_BIT_ATI                  0x00000010
-#define GL_EIGHTH_BIT_ATI                   0x00000020
-#define GL_SATURATE_BIT_ATI                 0x00000040
-#define GL_2X_BIT_ATI                       0x00000001
-#define GL_COMP_BIT_ATI                     0x00000002
-#define GL_NEGATE_BIT_ATI                   0x00000004
-#define GL_BIAS_BIT_ATI                     0x00000008
-#endif
-/* GL_ATI_texture_compression_3dc */
-#ifndef GL_ATI_texture_compression_3dc
-#define GL_ATI_texture_compression_3dc
-#define GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI 0x8837
-#endif
-/* GL_EXT_texture_compression_rgtc */
-#ifndef GL_EXT_texture_compression_rgtc
-#define GL_EXT_texture_compression_rgtc
-#define GL_COMPRESSED_RED_RGTC1_EXT                       0x8DBB
-#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT                0x8DBC
-#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT                 0x8DBD
-#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT          0x8DBE
-#endif
-
-/* GL_NV_vertex_program2_option */
-#ifndef GL_NV_vertex_program2_option
-#define GL_NV_vertex_program2_option
-#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV               0x88F4
-#define GL_MAX_PROGRAM_CALL_DEPTH_NV                      0x88F5
-#endif
-
-/* GL_APPLE_flush_buffer_range */
-#ifndef GL_APPLE_flush_buffer_range
-#define GL_APPLE_flush_buffer_range
-#define GL_BUFFER_SERIALIZED_MODIFY_APPLE                 0x8A12
-#define GL_BUFFER_FLUSHING_UNMAP_APPLE                    0x8A13
-typedef void (WINE_GLAPI *PGLFNBUFFERPARAMETERIAPPLE) (GLenum target, GLenum pname, GLint param);
-typedef void (WINE_GLAPI *PGLFNFLUSHMAPPEDBUFFERRANGEAPPLE) (GLenum target, GLintptr offset, GLsizeiptr size);
-#endif
-
-/* GL_VERSION_2_0 */
-#ifndef GL_VERSION_2_0
-#define GL_VERSION_2_0 1
-#define GL_BLEND_EQUATION_RGB             GL_BLEND_EQUATION
-#define GL_VERTEX_ATTRIB_ARRAY_ENABLED    0x8622
-#define GL_VERTEX_ATTRIB_ARRAY_SIZE       0x8623
-#define GL_VERTEX_ATTRIB_ARRAY_STRIDE     0x8624
-#define GL_VERTEX_ATTRIB_ARRAY_TYPE       0x8625
-#define GL_CURRENT_VERTEX_ATTRIB          0x8626
-#define GL_VERTEX_PROGRAM_POINT_SIZE      0x8642
-#define GL_VERTEX_PROGRAM_TWO_SIDE        0x8643
-#define GL_VERTEX_ATTRIB_ARRAY_POINTER    0x8645
-#define GL_STENCIL_BACK_FUNC              0x8800
-#define GL_STENCIL_BACK_FAIL              0x8801
-#define GL_STENCIL_BACK_PASS_DEPTH_FAIL   0x8802
-#define GL_STENCIL_BACK_PASS_DEPTH_PASS   0x8803
-#define GL_MAX_DRAW_BUFFERS               0x8824
-#define GL_DRAW_BUFFER0                   0x8825
-#define GL_DRAW_BUFFER1                   0x8826
-#define GL_DRAW_BUFFER2                   0x8827
-#define GL_DRAW_BUFFER3                   0x8828
-#define GL_DRAW_BUFFER4                   0x8829
-#define GL_DRAW_BUFFER5                   0x882A
-#define GL_DRAW_BUFFER6                   0x882B
-#define GL_DRAW_BUFFER7                   0x882C
-#define GL_DRAW_BUFFER8                   0x882D
-#define GL_DRAW_BUFFER9                   0x882E
-#define GL_DRAW_BUFFER10                  0x882F
-#define GL_DRAW_BUFFER11                  0x8830
-#define GL_DRAW_BUFFER12                  0x8831
-#define GL_DRAW_BUFFER13                  0x8832
-#define GL_DRAW_BUFFER14                  0x8833
-#define GL_DRAW_BUFFER15                  0x8834
-#define GL_BLEND_EQUATION_ALPHA           0x883D
-#define GL_POINT_SPRITE                   0x8861
-#define GL_COORD_REPLACE                  0x8862
-#define GL_MAX_VERTEX_ATTRIBS             0x8869
-#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
-#define GL_MAX_TEXTURE_COORDS             0x8871
-#define GL_MAX_TEXTURE_IMAGE_UNITS        0x8872
-#define GL_FRAGMENT_SHADER                0x8B30
-#define GL_VERTEX_SHADER                  0x8B31
-#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49
-#define GL_MAX_VERTEX_UNIFORM_COMPONENTS  0x8B4A
-#define GL_MAX_VARYING_FLOATS             0x8B4B
-#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
-#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
-#define GL_SHADER_TYPE                    0x8B4F
-#define GL_FLOAT_VEC2                     0x8B50
-#define GL_FLOAT_VEC3                     0x8B51
-#define GL_FLOAT_VEC4                     0x8B52
-#define GL_INT_VEC2                       0x8B53
-#define GL_INT_VEC3                       0x8B54
-#define GL_INT_VEC4                       0x8B55
-#define GL_BOOL                           0x8B56
-#define GL_BOOL_VEC2                      0x8B57
-#define GL_BOOL_VEC3                      0x8B58
-#define GL_BOOL_VEC4                      0x8B59
-#define GL_FLOAT_MAT2                     0x8B5A
-#define GL_FLOAT_MAT3                     0x8B5B
-#define GL_FLOAT_MAT4                     0x8B5C
-#define GL_SAMPLER_1D                     0x8B5D
-#define GL_SAMPLER_2D                     0x8B5E
-#define GL_SAMPLER_3D                     0x8B5F
-#define GL_SAMPLER_CUBE                   0x8B60
-#define GL_SAMPLER_1D_SHADOW              0x8B61
-#define GL_SAMPLER_2D_SHADOW              0x8B62
-#define GL_DELETE_STATUS                  0x8B80
-#define GL_COMPILE_STATUS                 0x8B81
-#define GL_LINK_STATUS                    0x8B82
-#define GL_VALIDATE_STATUS                0x8B83
-#define GL_INFO_LOG_LENGTH                0x8B84
-#define GL_ATTACHED_SHADERS               0x8B85
-#define GL_ACTIVE_UNIFORMS                0x8B86
-#define GL_ACTIVE_UNIFORM_MAX_LENGTH      0x8B87
-#define GL_SHADER_SOURCE_LENGTH           0x8B88
-#define GL_ACTIVE_ATTRIBUTES              0x8B89
-#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH    0x8B8A
-#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B
-#define GL_SHADING_LANGUAGE_VERSION       0x8B8C
-#define GL_CURRENT_PROGRAM                0x8B8D
-#define GL_POINT_SPRITE_COORD_ORIGIN      0x8CA0
-#define GL_LOWER_LEFT                     0x8CA1
-#define GL_UPPER_LEFT                     0x8CA2
-#define GL_STENCIL_BACK_REF               0x8CA3
-#define GL_STENCIL_BACK_VALUE_MASK        0x8CA4
-#define GL_STENCIL_BACK_WRITEMASK         0x8CA5
-typedef char GLchar;
-#endif
-typedef void (WINE_GLAPI * PGLFNBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha);
-typedef void (WINE_GLAPI * PGLFNDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs);
-typedef void (WINE_GLAPI * PGLFNSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
-typedef void (WINE_GLAPI * PGLFNSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);
-typedef void (WINE_GLAPI * PGLFNSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask);
-typedef void (WINE_GLAPI * PGLFNATTACHSHADERPROC) (GLuint program, GLuint shader);
-typedef void (WINE_GLAPI * PGLFNBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name);
-typedef void (WINE_GLAPI * PGLFNCOMPILESHADERPROC) (GLuint shader);
-typedef GLuint (WINE_GLAPI * PGLFNCREATEPROGRAMPROC) (void);
-typedef GLuint (WINE_GLAPI * PGLFNCREATESHADERPROC) (GLenum type);
-typedef void (WINE_GLAPI * PGLFNDELETEPROGRAMPROC) (GLuint program);
-typedef void (WINE_GLAPI * PGLFNDELETESHADERPROC) (GLuint shader);
-typedef void (WINE_GLAPI * PGLFNDETACHSHADERPROC) (GLuint program, GLuint shader);
-typedef void (WINE_GLAPI * PGLFNDISABLEVERTEXATTRIBARRAYPROC) (GLuint index);
-typedef void (WINE_GLAPI * PGLFNENABLEVERTEXATTRIBARRAYPROC) (GLuint index);
-typedef void (WINE_GLAPI * PGLFNGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
-typedef void (WINE_GLAPI * PGLFNGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
-typedef void (WINE_GLAPI * PGLFNGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj);
-typedef GLint (WINE_GLAPI * PGLFNGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name);
-typedef void (WINE_GLAPI * PGLFNGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params);
-typedef void (WINE_GLAPI * PGLFNGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
-typedef void (WINE_GLAPI * PGLFNGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params);
-typedef void (WINE_GLAPI * PGLFNGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
-typedef void (WINE_GLAPI * PGLFNGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source);
-typedef GLint (WINE_GLAPI * PGLFNGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name);
-typedef void (WINE_GLAPI * PGLFNGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params);
-typedef void (WINE_GLAPI * PGLFNGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params);
-typedef void (WINE_GLAPI * PGLFNGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params);
-typedef void (WINE_GLAPI * PGLFNGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params);
-typedef void (WINE_GLAPI * PGLFNGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params);
-typedef void (WINE_GLAPI * PGLFNGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer);
-typedef GLboolean (WINE_GLAPI * PGLFNISPROGRAMPROC) (GLuint program);
-typedef GLboolean (WINE_GLAPI * PGLFNISSHADERPROC) (GLuint shader);
-typedef void (WINE_GLAPI * PGLFNLINKPROGRAMPROC) (GLuint program);
-typedef void (WINE_GLAPI * PGLFNSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length);
-typedef void (WINE_GLAPI * PGLFNUSEPROGRAMPROC) (GLuint program);
-typedef void (WINE_GLAPI * PGLFNUNIFORM1FPROC) (GLint location, GLfloat v0);
-typedef void (WINE_GLAPI * PGLFNUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1);
-typedef void (WINE_GLAPI * PGLFNUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
-typedef void (WINE_GLAPI * PGLFNUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
-typedef void (WINE_GLAPI * PGLFNUNIFORM1IPROC) (GLint location, GLint v0);
-typedef void (WINE_GLAPI * PGLFNUNIFORM2IPROC) (GLint location, GLint v0, GLint v1);
-typedef void (WINE_GLAPI * PGLFNUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2);
-typedef void (WINE_GLAPI * PGLFNUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
-typedef void (WINE_GLAPI * PGLFNUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value);
-typedef void (WINE_GLAPI * PGLFNUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value);
-typedef void (WINE_GLAPI * PGLFNUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value);
-typedef void (WINE_GLAPI * PGLFNUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value);
-typedef void (WINE_GLAPI * PGLFNUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value);
-typedef void (WINE_GLAPI * PGLFNUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value);
-typedef void (WINE_GLAPI * PGLFNUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value);
-typedef void (WINE_GLAPI * PGLFNUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value);
-typedef void (WINE_GLAPI * PGLFNUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (WINE_GLAPI * PGLFNUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (WINE_GLAPI * PGLFNUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (WINE_GLAPI * PGLFNVALIDATEPROGRAMPROC) (GLuint program);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1DPROC) (GLuint index, GLdouble x);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1FPROC) (GLuint index, GLfloat x);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1SPROC) (GLuint index, GLshort x);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v);
-typedef void (WINE_GLAPI * PGLFNVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
-
-
-/****************************************************
- * OpenGL Official Version
- *  defines
- ****************************************************/
-/* GL_VERSION_1_3 */
-#if !defined(GL_DOT3_RGBA)
-# define GL_DOT3_RGBA                     0x8741
-#endif
-#if !defined(GL_SUBTRACT)
-# define GL_SUBTRACT                      0x84E7
-#endif
-
-
-/****************************************************
- * Enumerated types
- ****************************************************/
-#define WINE_DEFAULT_VIDMEM 64*1024*1024
-
-#define MAKEDWORD_VERSION(maj, min)  ((maj & 0x0000FFFF) << 16) | (min & 0x0000FFFF)
-
-/* OpenGL Supported Extensions (ARB and EXT) */
-typedef enum _GL_SupportedExt {
-  WINED3D_GL_EXT_NONE,
-  /* ARB */
-  ARB_COLOR_BUFFER_FLOAT,
-  ARB_DEPTH_BUFFER_FLOAT,
-  ARB_DEPTH_CLAMP,
-  ARB_DEPTH_TEXTURE,
-  ARB_DRAW_BUFFERS,
-  ARB_FRAGMENT_PROGRAM,
-  ARB_FRAGMENT_SHADER,
-  ARB_FRAMEBUFFER_OBJECT,
-  ARB_GEOMETRY_SHADER4,
-  ARB_IMAGING,
-  ARB_MULTISAMPLE,
-  ARB_MULTITEXTURE,
-  ARB_OCCLUSION_QUERY,
-  ARB_POINT_PARAMETERS,
-  ARB_PROVOKING_VERTEX,
-  ARB_PIXEL_BUFFER_OBJECT,
-  ARB_POINT_SPRITE,
-  ARB_TEXTURE_COMPRESSION,
-  ARB_TEXTURE_CUBE_MAP,
-  ARB_TEXTURE_ENV_ADD,
-  ARB_TEXTURE_ENV_COMBINE,
-  ARB_TEXTURE_ENV_DOT3,
-  ARB_TEXTURE_FLOAT,
-  ARB_HALF_FLOAT_PIXEL,
-  ARB_TEXTURE_BORDER_CLAMP,
-  ARB_TEXTURE_MIRRORED_REPEAT,
-  ARB_TEXTURE_NON_POWER_OF_TWO,
-  ARB_TEXTURE_RECTANGLE,
-  ARB_TEXTURE_RG,
-  ARB_VERTEX_PROGRAM,
-  ARB_VERTEX_BLEND,
-  ARB_VERTEX_BUFFER_OBJECT,
-  ARB_VERTEX_SHADER,
-  ARB_SHADER_OBJECTS,
-  ARB_SHADER_TEXTURE_LOD,
-  ARB_HALF_FLOAT_VERTEX,
-  /* EXT */
-  EXT_BLEND_COLOR,
-  EXT_BLEND_MINMAX,
-  EXT_BLEND_EQUATION_SEPARATE,
-  EXT_BLEND_FUNC_SEPARATE,
-  EXT_FOG_COORD,
-  EXT_FRAMEBUFFER_OBJECT,
-  EXT_FRAMEBUFFER_BLIT,
-  EXT_FRAMEBUFFER_MULTISAMPLE,
-  EXT_PACKED_DEPTH_STENCIL,
-  EXT_PALETTED_TEXTURE,
-  EXT_PIXEL_BUFFER_OBJECT,
-  EXT_POINT_PARAMETERS,
-  EXT_PROVOKING_VERTEX,
-  EXT_SECONDARY_COLOR,
-  EXT_STENCIL_TWO_SIDE,
-  EXT_STENCIL_WRAP,
-  EXT_TEXTURE3D,
-  EXT_TEXTURE_COMPRESSION_S3TC,
-  EXT_TEXTURE_COMPRESSION_RGTC,
-  EXT_TEXTURE_FILTER_ANISOTROPIC,
-  EXT_TEXTURE_LOD,
-  EXT_TEXTURE_LOD_BIAS,
-  EXT_TEXTURE_ENV_ADD,
-  EXT_TEXTURE_ENV_COMBINE,
-  EXT_TEXTURE_ENV_DOT3,
-  EXT_TEXTURE_SRGB,
-  EXT_TEXTURE_SWIZZLE,
-  EXT_GPU_PROGRAM_PARAMETERS,
-  EXT_VERTEX_ARRAY_BGRA,
-  /* NVIDIA */
-  NV_HALF_FLOAT,
-  NV_FOG_DISTANCE,
-  NV_FRAGMENT_PROGRAM,
-  NV_FRAGMENT_PROGRAM2,
-  NV_OCCLUSION_QUERY,
-  NV_REGISTER_COMBINERS,
-  NV_REGISTER_COMBINERS2,
-  NV_TEXGEN_REFLECTION,
-  NV_TEXTURE_ENV_COMBINE4,
-  NV_TEXTURE_SHADER,
-  NV_TEXTURE_SHADER2,
-  NV_TEXTURE_SHADER3,
-  NV_VERTEX_PROGRAM,
-  NV_VERTEX_PROGRAM1_1,
-  NV_VERTEX_PROGRAM2,
-  NV_VERTEX_PROGRAM2_OPTION,
-  NV_VERTEX_PROGRAM3,
-  NV_FRAGMENT_PROGRAM_OPTION,
-  NV_FENCE,
-  NV_DEPTH_CLAMP,
-  NV_LIGHT_MAX_EXPONENT,
-  /* ATI */
-  ATI_SEPARATE_STENCIL,
-  ATI_TEXTURE_ENV_COMBINE3,
-  ATI_TEXTURE_MIRROR_ONCE,
-  EXT_VERTEX_SHADER,
-  ATI_FRAGMENT_SHADER,
-  ATI_TEXTURE_COMPRESSION_3DC,
-  /* APPLE */
-  APPLE_FENCE,
-  APPLE_CLIENT_STORAGE,
-  APPLE_FLUSH_RENDER,
-  APPLE_YCBCR_422,
-  APPLE_FLOAT_PIXELS,
-  APPLE_FLUSH_BUFFER_RANGE,
-  /* SGI */
-  SGI_VIDEO_SYNC,
-  SGIS_GENERATE_MIPMAP,
-
-  /* Internally used */
-  WINE_NORMALIZED_TEXRECT,
-
-  /* WGL extensions */
-  WGL_ARB_PBUFFER,
-  WGL_ARB_PIXEL_FORMAT,
-  WGL_WINE_PIXEL_FORMAT_PASSTHROUGH,
-
-  WINED3D_GL_EXT_COUNT,
-} GL_SupportedExt;
-
-
-/****************************************************
- * #Defines
- ****************************************************/
-#define GL_EXT_FUNCS_GEN \
-    /** ARB Extensions **/ \
-    /* GL_ARB_color_buffer_float */ \
-    USE_GL_FUNC(PGLFNCLAMPCOLORARBPROC,                             glClampColorARB,                            ARB_COLOR_BUFFER_FLOAT, NULL )\
-    /* GL_ARB_draw_buffers */ \
-    USE_GL_FUNC(PGLFNDRAWBUFFERSARBPROC,                            glDrawBuffersARB,                           ARB_DRAW_BUFFERS,       NULL )\
-    /* GL_ARB_framebuffer_object */ \
-    USE_GL_FUNC(PGLFNGLISRENDERBUFFERPROC,                          glIsRenderbuffer,                           ARB_FRAMEBUFFER_OBJECT, NULL )\
-    USE_GL_FUNC(PGLFNGLBINDRENDERBUFFERPROC,                        glBindRenderbuffer,                         ARB_FRAMEBUFFER_OBJECT, NULL )\
-    USE_GL_FUNC(PGLFNGLDELETERENDERBUFFERSPROC,                     glDeleteRenderbuffers,                      ARB_FRAMEBUFFER_OBJECT, NULL )\
-    USE_GL_FUNC(PGLFNGLGENRENDERBUFFERSPROC,                        glGenRenderbuffers,                         ARB_FRAMEBUFFER_OBJECT, NULL )\
-    USE_GL_FUNC(PGLFNGLRENDERBUFFERSTORAGEPROC,                     glRenderbufferStorage,                      ARB_FRAMEBUFFER_OBJECT, NULL )\
-    USE_GL_FUNC(PGLFNRENDERBUFFERSTORAGEMULTISAMPLEPROC,            glRenderbufferStorageMultisample,           ARB_FRAMEBUFFER_OBJECT, NULL )\
-    USE_GL_FUNC(PGLFNGLGETRENDERBUFFERPARAMETERIVPROC,              glGetRenderbufferParameteriv,               ARB_FRAMEBUFFER_OBJECT, NULL )\
-    USE_GL_FUNC(PGLFNGLISFRAMEBUFFERPROC,                           glIsFramebuffer,                            ARB_FRAMEBUFFER_OBJECT, NULL )\
-    USE_GL_FUNC(PGLFNGLBINDFRAMEBUFFERPROC,                         glBindFramebuffer,                          ARB_FRAMEBUFFER_OBJECT, NULL )\
-    USE_GL_FUNC(PGLFNGLDELETEFRAMEBUFFERSPROC,                      glDeleteFramebuffers,                       ARB_FRAMEBUFFER_OBJECT, NULL )\
-    USE_GL_FUNC(PGLFNGLGENFRAMEBUFFERSPROC,                         glGenFramebuffers,                          ARB_FRAMEBUFFER_OBJECT, NULL )\
-    USE_GL_FUNC(PGLFNGLCHECKFRAMEBUFFERSTATUSPROC,                  glCheckFramebufferStatus,                   ARB_FRAMEBUFFER_OBJECT, NULL )\
-    USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE1DPROC,                    glFramebufferTexture1D,                     ARB_FRAMEBUFFER_OBJECT, NULL )\
-    USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE2DPROC,                    glFramebufferTexture2D,                     ARB_FRAMEBUFFER_OBJECT, NULL )\
-    USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE3DPROC,                    glFramebufferTexture3D,                     ARB_FRAMEBUFFER_OBJECT, NULL )\
-    USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURELAYERPROC,                 glFramebufferTextureLayer,                  ARB_FRAMEBUFFER_OBJECT, NULL )\
-    USE_GL_FUNC(PGLFNGLFRAMEBUFFERRENDERBUFFERPROC,                 glFramebufferRenderbuffer,                  ARB_FRAMEBUFFER_OBJECT, NULL )\
-    USE_GL_FUNC(PGLFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC,     glGetFramebufferAttachmentParameteriv,      ARB_FRAMEBUFFER_OBJECT, NULL )\
-    USE_GL_FUNC(PGLFNGLBLITFRAMEBUFFERPROC,                         glBlitFramebuffer,                          ARB_FRAMEBUFFER_OBJECT, NULL )\
-    USE_GL_FUNC(PGLFNGLGENERATEMIPMAPPROC,                          glGenerateMipmap,                           ARB_FRAMEBUFFER_OBJECT, NULL )\
-    /* GL_ARB_geometry_shader4 */ \
-    USE_GL_FUNC(PGLFNPROGRAMPARAMETERIARBPROC,                      glProgramParameteriARB,                     ARB_GEOMETRY_SHADER4,   NULL ) \
-    USE_GL_FUNC(PGLFNFRAMEBUFFERTEXTUREARBPROC,                     glFramebufferTextureARB,                    ARB_GEOMETRY_SHADER4,   NULL ) \
-    USE_GL_FUNC(PGLFNFRAMEBUFFERTEXTURELAYERARBPROC,                glFramebufferTextureLayerARB,               ARB_GEOMETRY_SHADER4,   NULL ) \
-    USE_GL_FUNC(PGLFNFRAMEBUFFERTEXTUREFACEARBPROC,                 glFramebufferTextureFaceARB,                ARB_GEOMETRY_SHADER4,   NULL ) \
-    /* GL_ARB_imaging, GL_EXT_blend_minmax */ \
-    USE_GL_FUNC(PGLFNBLENDCOLORPROC,                                glBlendColorEXT,                            EXT_BLEND_COLOR,        NULL )\
-    USE_GL_FUNC(PGLFNBLENDEQUATIONPROC,                             glBlendEquationEXT,                         EXT_BLEND_MINMAX,       NULL )\
-    /* GL_ARB_multisample */ \
-    USE_GL_FUNC(WINED3D_PFNGLSAMPLECOVERAGEARBPROC,                 glSampleCoverageARB,                        ARB_MULTISAMPLE,        NULL )\
-    /* GL_ARB_multitexture */ \
-    USE_GL_FUNC(WINED3D_PFNGLACTIVETEXTUREARBPROC,                  glActiveTextureARB,                         ARB_MULTITEXTURE,       NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLCLIENTACTIVETEXTUREARBPROC,            glClientActiveTextureARB,                   ARB_MULTITEXTURE,       NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD1FARBPROC,                glMultiTexCoord1fARB,                       ARB_MULTITEXTURE,       NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD1FVARBPROC,               glMultiTexCoord1fvARB,                      ARB_MULTITEXTURE,       NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD2FARBPROC,                glMultiTexCoord2fARB,                       ARB_MULTITEXTURE,       NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD2FVARBPROC,               glMultiTexCoord2fvARB,                      ARB_MULTITEXTURE,       NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD3FARBPROC,                glMultiTexCoord3fARB,                       ARB_MULTITEXTURE,       NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD3FVARBPROC,               glMultiTexCoord3fvARB,                      ARB_MULTITEXTURE,       NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD4FARBPROC,                glMultiTexCoord4fARB,                       ARB_MULTITEXTURE,       NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD4FVARBPROC,               glMultiTexCoord4fvARB,                      ARB_MULTITEXTURE,       NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD2SVARBPROC,               glMultiTexCoord2svARB,                      ARB_MULTITEXTURE,       NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD4SVARBPROC,               glMultiTexCoord4svARB,                      ARB_MULTITEXTURE,       NULL )\
-    /* GL_ARB_occlusion_query */ \
-    USE_GL_FUNC(PGLFNGENQUERIESARBPROC,                             glGenQueriesARB,                            ARB_OCCLUSION_QUERY,    NULL )\
-    USE_GL_FUNC(PGLFNDELETEQUERIESARBPROC,                          glDeleteQueriesARB,                         ARB_OCCLUSION_QUERY,    NULL )\
-    USE_GL_FUNC(PGLFNBEGINQUERYARBPROC,                             glBeginQueryARB,                            ARB_OCCLUSION_QUERY,    NULL )\
-    USE_GL_FUNC(PGLFNENDQUERYARBPROC,                               glEndQueryARB,                              ARB_OCCLUSION_QUERY,    NULL )\
-    USE_GL_FUNC(PGLFNGETQUERYOBJECTIVARBPROC,                       glGetQueryObjectivARB,                      ARB_OCCLUSION_QUERY,    NULL )\
-    USE_GL_FUNC(PGLFNGETQUERYOBJECTUIVARBPROC,                      glGetQueryObjectuivARB,                     ARB_OCCLUSION_QUERY,    NULL )\
-    /* GL_ARB_point_parameters */ \
-    USE_GL_FUNC(PGLFNGLPOINTPARAMETERFARBPROC,                      glPointParameterfARB,                       ARB_POINT_PARAMETERS,   NULL )\
-    USE_GL_FUNC(PGLFNGLPOINTPARAMETERFVARBPROC,                     glPointParameterfvARB,                      ARB_POINT_PARAMETERS,   NULL )\
-    /* GL_ARB_provoking_vertex */ \
-    USE_GL_FUNC(PGLFNGLPROVOKINGVERTEXPROC,                         glProvokingVertex,                          ARB_PROVOKING_VERTEX,   NULL)\
-    /* GL_ARB_texture_compression */ \
-    USE_GL_FUNC(PGLFNCOMPRESSEDTEXIMAGE2DPROC,                      glCompressedTexImage2DARB,                  ARB_TEXTURE_COMPRESSION,NULL )\
-    USE_GL_FUNC(PGLFNCOMPRESSEDTEXIMAGE3DPROC,                      glCompressedTexImage3DARB,                  ARB_TEXTURE_COMPRESSION,NULL )\
-    USE_GL_FUNC(PGLFNCOMPRESSEDTEXSUBIMAGE2DPROC,                   glCompressedTexSubImage2DARB,               ARB_TEXTURE_COMPRESSION,NULL )\
-    USE_GL_FUNC(PGLFNCOMPRESSEDTEXSUBIMAGE3DPROC,                   glCompressedTexSubImage3DARB,               ARB_TEXTURE_COMPRESSION,NULL )\
-    USE_GL_FUNC(PGLFNGETCOMPRESSEDTEXIMAGEPROC,                     glGetCompressedTexImageARB,                 ARB_TEXTURE_COMPRESSION,NULL )\
-    /* GL_ARB_vertex_blend */ \
-    USE_GL_FUNC(PGLFNGLWEIGHTPOINTERARB,                            glWeightPointerARB,                         ARB_VERTEX_BLEND,       NULL )\
-    USE_GL_FUNC(PGLFNGLWEIGHTBV,                                    glWeightbvARB,                              ARB_VERTEX_BLEND,       NULL )\
-    USE_GL_FUNC(PGLFNGLWEIGHTSV,                                    glWeightsvARB,                              ARB_VERTEX_BLEND,       NULL )\
-    USE_GL_FUNC(PGLFNGLWEIGHTIV,                                    glWeightivARB,                              ARB_VERTEX_BLEND,       NULL )\
-    USE_GL_FUNC(PGLFNGLWEIGHTFV,                                    glWeightfvARB,                              ARB_VERTEX_BLEND,       NULL )\
-    USE_GL_FUNC(PGLFNGLWEIGHTDV,                                    glWeightdvARB,                              ARB_VERTEX_BLEND,       NULL )\
-    USE_GL_FUNC(PGLFNGLWEIGHTUBV,                                   glWeightubvARB,                             ARB_VERTEX_BLEND,       NULL )\
-    USE_GL_FUNC(PGLFNGLWEIGHTUSV,                                   glWeightusvARB,                             ARB_VERTEX_BLEND,       NULL )\
-    USE_GL_FUNC(PGLFNGLWEIGHTUIV,                                   glWeightuivARB,                             ARB_VERTEX_BLEND,       NULL )\
-    USE_GL_FUNC(PGLFNGLVERTEXBLENDARB,                              glVertexBlendARB,                           ARB_VERTEX_BLEND,       NULL )\
-    /* GL_ARB_vertex_buffer_object */ \
-    USE_GL_FUNC(PGLFNBINDBUFFERARBPROC,                             glBindBufferARB,                            ARB_VERTEX_BUFFER_OBJECT,NULL)\
-    USE_GL_FUNC(PGLFNDELETEBUFFERSARBPROC,                          glDeleteBuffersARB,                         ARB_VERTEX_BUFFER_OBJECT,NULL)\
-    USE_GL_FUNC(PGLFNGENBUFFERSARBPROC,                             glGenBuffersARB,                            ARB_VERTEX_BUFFER_OBJECT,NULL)\
-    USE_GL_FUNC(PGLFNISBUFFERARBPROC,                               glIsBufferARB,                              ARB_VERTEX_BUFFER_OBJECT,NULL)\
-    USE_GL_FUNC(PGLFNBUFFERDATAARBPROC,                             glBufferDataARB,                            ARB_VERTEX_BUFFER_OBJECT,NULL)\
-    USE_GL_FUNC(PGLFNBUFFERSUBDATAARBPROC,                          glBufferSubDataARB,                         ARB_VERTEX_BUFFER_OBJECT,NULL)\
-    USE_GL_FUNC(PGLFNGETBUFFERSUBDATAARBPROC,                       glGetBufferSubDataARB,                      ARB_VERTEX_BUFFER_OBJECT,NULL)\
-    USE_GL_FUNC(PGLFNMAPBUFFERARBPROC,                              glMapBufferARB,                             ARB_VERTEX_BUFFER_OBJECT,NULL)\
-    USE_GL_FUNC(PGLFNUNMAPBUFFERARBPROC,                            glUnmapBufferARB,                           ARB_VERTEX_BUFFER_OBJECT,NULL)\
-    USE_GL_FUNC(PGLFNGETBUFFERPARAMETERIVARBPROC,                   glGetBufferParameterivARB,                  ARB_VERTEX_BUFFER_OBJECT,NULL)\
-    USE_GL_FUNC(PGLFNGETBUFFERPOINTERVARBPROC,                      glGetBufferPointervARB,                     ARB_VERTEX_BUFFER_OBJECT,NULL)\
-    /** EXT Extensions **/ \
-    /* GL_EXT_blend_equation_separate */ \
-    USE_GL_FUNC(PGLFNBLENDFUNCSEPARATEEXTPROC,                      glBlendFuncSeparateEXT,                     EXT_BLEND_FUNC_SEPARATE, NULL)\
-    /* GL_EXT_blend_func_separate */ \
-    USE_GL_FUNC(PGLFNBLENDEQUATIONSEPARATEEXTPROC,                  glBlendEquationSeparateEXT,                 EXT_BLEND_EQUATION_SEPARATE, NULL)\
-    /* GL_EXT_fog_coord */ \
-    USE_GL_FUNC(PGLFNGLFOGCOORDFEXTPROC,                            glFogCoordfEXT,                             EXT_FOG_COORD,          NULL )\
-    USE_GL_FUNC(PGLFNGLFOGCOORDFVEXTPROC,                           glFogCoordfvEXT,                            EXT_FOG_COORD,          NULL )\
-    USE_GL_FUNC(PGLFNGLFOGCOORDDEXTPROC,                            glFogCoorddEXT,                             EXT_FOG_COORD,          NULL )\
-    USE_GL_FUNC(PGLFNGLFOGCOORDDVEXTPROC,                           glFogCoorddvEXT,                            EXT_FOG_COORD,          NULL )\
-    USE_GL_FUNC(PGLFNGLFOGCOORDPOINTEREXTPROC,                      glFogCoordPointerEXT,                       EXT_FOG_COORD,          NULL )\
-    /* GL_EXT_framebuffer_object */ \
-    USE_GL_FUNC(PGLFNGLISRENDERBUFFEREXTPROC,                       glIsRenderbufferEXT,                        EXT_FRAMEBUFFER_OBJECT, NULL )\
-    USE_GL_FUNC(PGLFNGLBINDRENDERBUFFEREXTPROC,                     glBindRenderbufferEXT,                      EXT_FRAMEBUFFER_OBJECT, NULL )\
-    USE_GL_FUNC(PGLFNGLDELETERENDERBUFFERSEXTPROC,                  glDeleteRenderbuffersEXT,                   EXT_FRAMEBUFFER_OBJECT, NULL )\
-    USE_GL_FUNC(PGLFNGLGENRENDERBUFFERSEXTPROC,                     glGenRenderbuffersEXT,                      EXT_FRAMEBUFFER_OBJECT, NULL )\
-    USE_GL_FUNC(PGLFNGLRENDERBUFFERSTORAGEEXTPROC,                  glRenderbufferStorageEXT,                   EXT_FRAMEBUFFER_OBJECT, NULL )\
-    USE_GL_FUNC(PGLFNGLISFRAMEBUFFEREXTPROC,                        glIsFramebufferEXT,                         EXT_FRAMEBUFFER_OBJECT, NULL )\
-    USE_GL_FUNC(PGLFNGLBINDFRAMEBUFFEREXTPROC,                      glBindFramebufferEXT,                       EXT_FRAMEBUFFER_OBJECT, NULL )\
-    USE_GL_FUNC(PGLFNGLDELETEFRAMEBUFFERSEXTPROC,                   glDeleteFramebuffersEXT,                    EXT_FRAMEBUFFER_OBJECT, NULL )\
-    USE_GL_FUNC(PGLFNGLGENFRAMEBUFFERSEXTPROC,                      glGenFramebuffersEXT,                       EXT_FRAMEBUFFER_OBJECT, NULL )\
-    USE_GL_FUNC(PGLFNGLCHECKFRAMEBUFFERSTATUSEXTPROC,               glCheckFramebufferStatusEXT,                EXT_FRAMEBUFFER_OBJECT, NULL )\
-    USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE1DEXTPROC,                 glFramebufferTexture1DEXT,                  EXT_FRAMEBUFFER_OBJECT, NULL )\
-    USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE2DEXTPROC,                 glFramebufferTexture2DEXT,                  EXT_FRAMEBUFFER_OBJECT, NULL )\
-    USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE3DEXTPROC,                 glFramebufferTexture3DEXT,                  EXT_FRAMEBUFFER_OBJECT, NULL )\
-    USE_GL_FUNC(PGLFNGLFRAMEBUFFERRENDERBUFFEREXTPROC,              glFramebufferRenderbufferEXT,               EXT_FRAMEBUFFER_OBJECT, NULL )\
-    USE_GL_FUNC(PGLFNGLGENERATEMIPMAPEXTPROC,                       glGenerateMipmapEXT,                        EXT_FRAMEBUFFER_OBJECT, NULL )\
-    USE_GL_FUNC(PGLFNGLGETRENDERBUFFERPARAMETERIVEXTPROC,           glGetRenderbufferParameterivEXT,            EXT_FRAMEBUFFER_OBJECT, NULL )\
-    USE_GL_FUNC(PGLFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC,  glGetFramebufferAttachmentParameterivEXT,   EXT_FRAMEBUFFER_OBJECT, NULL )\
-    /* GL_EXT_framebuffer_blit */ \
-    USE_GL_FUNC(PGLFNGLBLITFRAMEBUFFEREXTPROC,                      glBlitFramebufferEXT,                       EXT_FRAMEBUFFER_BLIT,   NULL )\
-    /* GL_EXT_framebuffer_multisample */ \
-    USE_GL_FUNC(PGLFNRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC,         glRenderbufferStorageMultisampleEXT,        EXT_FRAMEBUFFER_MULTISAMPLE, NULL )\
-    /* GL_EXT_paletted_texture */ \
-    USE_GL_FUNC(PGLFNGLCOLORTABLEEXTPROC,                           glColorTableEXT,                            EXT_PALETTED_TEXTURE,   NULL )\
-    /* GL_EXT_point_parameters */ \
-    USE_GL_FUNC(PGLFNGLPOINTPARAMETERFEXTPROC,                      glPointParameterfEXT,                       EXT_POINT_PARAMETERS,   NULL )\
-    USE_GL_FUNC(PGLFNGLPOINTPARAMETERFVEXTPROC,                     glPointParameterfvEXT,                      EXT_POINT_PARAMETERS,   NULL )\
-    /* GL_EXT_provoking_vertex */ \
-    USE_GL_FUNC(PGLFNGLPROVOKINGVERTEXEXTPROC,                      glProvokingVertexEXT,                       EXT_PROVOKING_VERTEX,   NULL)\
-    /* GL_EXT_secondary_color */ \
-    USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3UBEXTPROC,                    glSecondaryColor3ubEXT,                     EXT_SECONDARY_COLOR,    NULL )\
-    USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3UBVEXTPROC,                   glSecondaryColor3ubvEXT,                    EXT_SECONDARY_COLOR,    NULL )\
-    USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3FEXTPROC,                     glSecondaryColor3fEXT,                      EXT_SECONDARY_COLOR,    NULL )\
-    USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3FVEXTPROC,                    glSecondaryColor3fvEXT,                     EXT_SECONDARY_COLOR,    NULL )\
-    USE_GL_FUNC(PGLFNGLSECONDARYCOLORPOINTEREXTPROC,                glSecondaryColorPointerEXT,                 EXT_SECONDARY_COLOR,    NULL )\
-    /* GL_EXT_texture3D */ \
-    USE_GL_FUNC(PGLFNGLTEXIMAGE3DEXTPROC,                           glTexImage3DEXT,                            EXT_TEXTURE3D,          glTexImage3D)\
-    USE_GL_FUNC(PGLFNGLTEXSUBIMAGE3DEXTPROC,                        glTexSubImage3DEXT,                         EXT_TEXTURE3D,          glTexSubImage3D)\
-    /* GL_ARB_vertex_program */ \
-    USE_GL_FUNC(PGLFNGENPROGRAMSARBPROC,                            glGenProgramsARB,                           ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNBINDPROGRAMARBPROC,                            glBindProgramARB,                           ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNPROGRAMSTRINGARBPROC,                          glProgramStringARB,                         ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNDELETEPROGRAMSARBPROC,                         glDeleteProgramsARB,                        ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNPROGRAMENVPARAMETER4FVARBPROC,                 glProgramEnvParameter4fvARB,                ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNPROGRAMLOCALPARAMETER4FVARBPROC,               glProgramLocalParameter4fvARB,                ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIBPOINTERARBPROC,                    glVertexAttribPointerARB,                   ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNENABLEVERTEXATTRIBARRAYARBPROC,                glEnableVertexAttribArrayARB,               ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNDISABLEVERTEXATTRIBARRAYARBPROC,               glDisableVertexAttribArrayARB,              ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB1DARBPROC,                         glVertexAttrib1dARB,                        ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB1DVARBPROC,                        glVertexAttrib1dvARB,                       ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB1FARBPROC,                         glVertexAttrib1fARB,                        ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB1FVARBPROC,                        glVertexAttrib1fvARB,                       ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB1SARBPROC,                         glVertexAttrib1sARB,                        ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB1SVARBPROC,                        glVertexAttrib1svARB,                       ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB2DARBPROC,                         glVertexAttrib2dARB,                        ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB2DVARBPROC,                        glVertexAttrib2dvARB,                       ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB2FARBPROC,                         glVertexAttrib2fARB,                        ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB2FVARBPROC,                        glVertexAttrib2fvARB,                       ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB2SARBPROC,                         glVertexAttrib2sARB,                        ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB2SVARBPROC,                        glVertexAttrib2svARB,                       ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB3DARBPROC,                         glVertexAttrib3dARB,                        ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB3DVARBPROC,                        glVertexAttrib3dvARB,                       ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB3FARBPROC,                         glVertexAttrib3fARB,                        ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB3FVARBPROC,                        glVertexAttrib3fvARB,                       ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB3SARBPROC,                         glVertexAttrib3sARB,                        ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB3SVARBPROC,                        glVertexAttrib3svARB,                       ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB4NBVARBPROC,                       glVertexAttrib4NbvARB,                      ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB4NIVARBPROC,                       glVertexAttrib4NivARB,                      ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB4NSVARBPROC,                       glVertexAttrib4NsvARB,                      ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB4NUBARBPROC,                       glVertexAttrib4NubARB,                      ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB4NUBVARBPROC,                      glVertexAttrib4NubvARB,                     ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB4NUIVARBPROC,                      glVertexAttrib4NuivARB,                     ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB4NUSVARBPROC,                      glVertexAttrib4NusvARB,                     ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB4BVARBPROC,                        glVertexAttrib4bvARB,                       ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB4DARBPROC,                         glVertexAttrib4dARB,                        ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB4DVARBPROC,                        glVertexAttrib4dvARB,                       ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB4FARBPROC,                         glVertexAttrib4fARB,                        ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB4FVARBPROC,                        glVertexAttrib4fvARB,                       ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB4IVARBPROC,                        glVertexAttrib4ivARB,                       ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB4SARBPROC,                         glVertexAttrib4sARB,                        ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB4SVARBPROC,                        glVertexAttrib4svARB,                       ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB4UBVARBPROC,                       glVertexAttrib4ubvARB,                      ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB4UIVARBPROC,                       glVertexAttrib4uivARB,                      ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB4USVARBPROC,                       glVertexAttrib4usvARB,                      ARB_VERTEX_PROGRAM,     NULL )\
-    USE_GL_FUNC(PGLFNGETPROGRAMIVARBPROC,                           glGetProgramivARB,                          ARB_VERTEX_PROGRAM,     NULL )\
-    /* GL_ARB_shader_objects */ \
-    USE_GL_FUNC(WINED3D_PFNGLGETOBJECTPARAMETERIVARBPROC,           glGetObjectParameterivARB,                  ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLGETOBJECTPARAMETERFVARBPROC,           glGetObjectParameterfvARB,                  ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLGETUNIFORMLOCATIONARBPROC,             glGetUniformLocationARB,                    ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLGETACTIVEUNIFORMARBPROC,               glGetActiveUniformARB,                      ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLUNIFORM1IARBPROC,                      glUniform1iARB,                             ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLUNIFORM2IARBPROC,                      glUniform2iARB,                             ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLUNIFORM3IARBPROC,                      glUniform3iARB,                             ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLUNIFORM4IARBPROC,                      glUniform4iARB,                             ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLUNIFORM1IARBPROC,                      glUniform1fARB,                             ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLUNIFORM2FARBPROC,                      glUniform2fARB,                             ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLUNIFORM3FARBPROC,                      glUniform3fARB,                             ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLUNIFORM4FARBPROC,                      glUniform4fARB,                             ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLUNIFORM1FVARBPROC,                     glUniform1fvARB,                            ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLUNIFORM2FVARBPROC,                     glUniform2fvARB,                            ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLUNIFORM3FVARBPROC,                     glUniform3fvARB,                            ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLUNIFORM4FVARBPROC,                     glUniform4fvARB,                            ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLUNIFORM1IVARBPROC,                     glUniform1ivARB,                            ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLUNIFORM2IVARBPROC,                     glUniform2ivARB,                            ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLUNIFORM3IVARBPROC,                     glUniform3ivARB,                            ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLUNIFORM4IVARBPROC,                     glUniform4ivARB,                            ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLUNIFORMMATRIX2FVARBPROC,               glUniformMatrix2fvARB,                      ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLUNIFORMMATRIX3FVARBPROC,               glUniformMatrix3fvARB,                      ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLUNIFORMMATRIX4FVARBPROC,               glUniformMatrix4fvARB,                      ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLGETUNIFORMFVARBPROC,                   glGetUniformfvARB,                          ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLGETUNIFORMIVARBPROC,                   glGetUniformivARB,                          ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLGETINFOLOGARBPROC,                     glGetInfoLogARB,                            ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLUSEPROGRAMOBJECTARBPROC,               glUseProgramObjectARB,                      ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLCREATESHADEROBJECTARBPROC,             glCreateShaderObjectARB,                    ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLSHADERSOURCEARBPROC,                   glShaderSourceARB,                          ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLCOMPILESHADERARBPROC,                  glCompileShaderARB,                         ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLCREATEPROGRAMOBJECTARBPROC,            glCreateProgramObjectARB,                   ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLATTACHOBJECTARBPROC,                   glAttachObjectARB,                          ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLLINKPROGRAMARBPROC,                    glLinkProgramARB,                           ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLDETACHOBJECTARBPROC,                   glDetachObjectARB,                          ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLDELETEOBJECTARBPROC,                   glDeleteObjectARB,                          ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLVALIDATEPROGRAMARBPROC,                glValidateProgramARB,                       ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLGETATTACHEDOBJECTSARBPROC,             glGetAttachedObjectsARB,                    ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLGETHANDLEARBPROC,                      glGetHandleARB,                             ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLGETSHADERSOURCEARBPROC,                glGetShaderSourceARB,                       ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLBINDATTRIBLOCATIONARBPROC,             glBindAttribLocationARB,                    ARB_SHADER_OBJECTS,     NULL )\
-    USE_GL_FUNC(WINED3D_PFNGLGETATTRIBLOCATIONARBPROC,              glGetAttribLocationARB,                     ARB_SHADER_OBJECTS,     NULL )\
-    /* GL_EXT_stencil_two_side */ \
-    USE_GL_FUNC(PGLFNACTIVESTENCILFACEEXTPROC,                      glActiveStencilFaceEXT,                     EXT_STENCIL_TWO_SIDE,   NULL )\
-    /* GL_ATI_separate_stencil */ \
-    USE_GL_FUNC(PGLFNSTENCILOPSEPARATEATIPROC,                      glStencilOpSeparateATI,                     ATI_SEPARATE_STENCIL,   NULL )\
-    USE_GL_FUNC(PGLFNSTENCILFUNCSEPARATEATIPROC,                    glStencilFuncSeparateATI,                   ATI_SEPARATE_STENCIL,   NULL )\
-    /* GL_NV_half_float */ \
-    USE_GL_FUNC(PGLFNVERTEX2HNVPROC,                                glVertex2hNV,                               NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNVERTEX2HVNVPROC,                               glVertex2hvNV,                              NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNVERTEX3HNVPROC,                                glVertex3hNV,                               NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNVERTEX3HVNVPROC,                               glVertex3hvNV,                              NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNVERTEX4HNVPROC,                                glVertex4hNV,                               NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNVERTEX4HVNVPROC,                               glVertex4hvNV,                              NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNNORMAL3HNVPROC,                                glNormal3hNV,                               NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNNORMAL3HVNVPROC,                               glNormal3hvNV,                              NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNCOLOR3HNVPROC,                                 glColor3hNV,                                NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNCOLOR3HVNVPROC,                                glColor3hvNV,                               NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNCOLOR4HNVPROC,                                 glColor4hNV,                                NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNCOLOR4HVNVPROC,                                glColor4hvNV,                               NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNTEXCOORD1HNVPROC,                              glTexCoord1hNV,                             NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNTEXCOORD1HVNVPROC,                             glTexCoord1hvNV,                            NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNTEXCOORD2HNVPROC,                              glTexCoord2hNV,                             NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNTEXCOORD2HVNVPROC,                             glTexCoord2hvNV,                            NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNTEXCOORD3HNVPROC,                              glTexCoord3hNV,                             NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNTEXCOORD3HVNVPROC,                             glTexCoord3hvNV,                            NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNTEXCOORD4HNVPROC,                              glTexCoord4hNV,                             NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNTEXCOORD4HVNVPROC,                             glTexCoord4hvNV,                            NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNMULTITEXCOORD1HNVPROC,                         glMultiTexCoord1hNV,                        NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNMULTITEXCOORD1HVNVPROC,                        glMultiTexCoord1hvNV,                       NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNMULTITEXCOORD2HNVPROC,                         glMultiTexCoord2hNV,                        NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNMULTITEXCOORD2HVNVPROC,                        glMultiTexCoord2hvNV,                       NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNMULTITEXCOORD3HNVPROC,                         glMultiTexCoord3hNV,                        NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNMULTITEXCOORD3HVNVPROC,                        glMultiTexCoord3hvNV,                       NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNMULTITEXCOORD4HNVPROC,                         glMultiTexCoord4hNV,                        NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNMULTITEXCOORD4HVNVPROC,                        glMultiTexCoord4hvNV,                       NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNFOGCOORDHNVPROC,                               glFogCoordhNV,                              NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNFOGCOORDHVNVPROC,                              glFogCoordhvNV,                             NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNSECONDARYCOLOR3HNVPROC,                        glSecondaryColor3hNV,                       NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNSECONDARYCOLOR3HVNVPROC,                       glSecondaryColor3hvNV,                      NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNVERTEXWEIGHTHNVPROC,                           glVertexWeighthNV,                          NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNVERTEXWEIGHTHVNVPROC,                          glVertexWeighthvNV,                         NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB1HNVPROC,                          glVertexAttrib1hNV,                         NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB1HVNVPROC,                         glVertexAttrib1hvNV,                        NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB2HNVPROC,                          glVertexAttrib2hNV,                         NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB2HVNVPROC,                         glVertexAttrib2hvNV,                        NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB3HNVPROC,                          glVertexAttrib3hNV,                         NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB3HVNVPROC,                         glVertexAttrib3hvNV,                        NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB4HNVPROC,                          glVertexAttrib4hNV,                         NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIB4HVNVPROC,                         glVertexAttrib4hvNV,                        NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIBS1HVNVPROC,                        glVertexAttribs1hvNV,                       NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIBS2HVNVPROC,                        glVertexAttribs2hvNV,                       NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIBS3HVNVPROC,                        glVertexAttribs3hvNV,                       NV_HALF_FLOAT,          NULL )\
-    USE_GL_FUNC(PGLFNVERTEXATTRIBS4HVNVPROC,                        glVertexAttribs4hvNV,                       NV_HALF_FLOAT,          NULL )\
-    /* GL_NV_register_combiners */ \
-    USE_GL_FUNC(PGLFNCOMBINERINPUTNVPROC,                           glCombinerInputNV,                          NV_REGISTER_COMBINERS,  NULL )\
-    USE_GL_FUNC(PGLFNCOMBINEROUTPUTNVPROC,                          glCombinerOutputNV,                         NV_REGISTER_COMBINERS,  NULL )\
-    USE_GL_FUNC(PGLFNCOMBINERPARAMETERFNVPROC,                      glCombinerParameterfNV,                     NV_REGISTER_COMBINERS,  NULL )\
-    USE_GL_FUNC(PGLFNCOMBINERPARAMETERFVNVPROC,                     glCombinerParameterfvNV,                    NV_REGISTER_COMBINERS,  NULL )\
-    USE_GL_FUNC(PGLFNCOMBINERPARAMETERINVPROC,                      glCombinerParameteriNV,                     NV_REGISTER_COMBINERS,  NULL )\
-    USE_GL_FUNC(PGLFNCOMBINERPARAMETERIVNVPROC,                     glCombinerParameterivNV,                    NV_REGISTER_COMBINERS,  NULL )\
-    USE_GL_FUNC(PGLFNFINALCOMBINERINPUTNVPROC,                      glFinalCombinerInputNV,                     NV_REGISTER_COMBINERS,  NULL )\
-    /* GL_NV_fence */ \
-    USE_GL_FUNC(PGLFNGENFENCESNVPROC,                               glGenFencesNV,                              NV_FENCE,               NULL )\
-    USE_GL_FUNC(PGLFNDELETEFENCESNVPROC,                            glDeleteFencesNV,                           NV_FENCE,               NULL )\
-    USE_GL_FUNC(PGLFNSETFENCENVPROC,                                glSetFenceNV,                               NV_FENCE,               NULL )\
-    USE_GL_FUNC(PGLFNTESTFENCENVPROC,                               glTestFenceNV,                              NV_FENCE,               NULL )\
-    USE_GL_FUNC(PGLFNFINISHFENCENVPROC,                             glFinishFenceNV,                            NV_FENCE,               NULL )\
-    USE_GL_FUNC(PGLFNISFENCENVPROC,                                 glIsFenceNV,                                NV_FENCE,               NULL )\
-    USE_GL_FUNC(PGLFNGETFENCEIVNVPROC,                              glGetFenceivNV,                             NV_FENCE,               NULL )\
-    /* GL_APPLE_fence */ \
-    USE_GL_FUNC(PGLFNGENFENCESAPPLEPROC,                            glGenFencesAPPLE,                           APPLE_FENCE,            NULL )\
-    USE_GL_FUNC(PGLFNDELETEFENCESAPPLEPROC,                         glDeleteFencesAPPLE,                        APPLE_FENCE,            NULL )\
-    USE_GL_FUNC(PGLFNSETFENCEAPPLEPROC,                             glSetFenceAPPLE,                            APPLE_FENCE,            NULL )\
-    USE_GL_FUNC(PGLFNTESTFENCEAPPLEPROC,                            glTestFenceAPPLE,                           APPLE_FENCE,            NULL )\
-    USE_GL_FUNC(PGLFNFINISHFENCEAPPLEPROC,                          glFinishFenceAPPLE,                         APPLE_FENCE,            NULL )\
-    USE_GL_FUNC(PGLFNISFENCEAPPLEPROC,                              glIsFenceAPPLE,                             APPLE_FENCE,            NULL )\
-    USE_GL_FUNC(PGLFNTESTOBJECTAPPLEPROC,                           glTestObjectAPPLE,                          APPLE_FENCE,            NULL )\
-    USE_GL_FUNC(PGLFNFINISHOBJECTAPPLEPROC,                         glFinishObjectAPPLE,                        APPLE_FENCE,            NULL )\
-    /* GLX_SGI_video_sync */ \
-    USE_GL_FUNC(PGLXFNGETVIDEOSYNCSGIPROC,                          glXGetVideoSyncSGI,                         SGI_VIDEO_SYNC,         NULL )\
-    USE_GL_FUNC(PGLXFNWAITVIDEOSYNCSGIPROC,                         glXWaitVideoSyncSGI,                        SGI_VIDEO_SYNC,         NULL )\
-    /* GL_APPLE_flush_render */ \
-    USE_GL_FUNC(PGLFNFLUSHRENDERAPPLEPROC,                          glFlushRenderAPPLE,                         APPLE_FLUSH_RENDER,     NULL )\
-    USE_GL_FUNC(PGLFNFINISHRENDERAPPLEPROC,                         glFinishRenderAPPLE,                        APPLE_FLUSH_RENDER,     NULL )\
-    /* GL_EXT_gpu_program_parameters */ \
-    USE_GL_FUNC(PGLFNPROGRAMENVPARAMETERS4FVEXTPROC,                glProgramEnvParameters4fvEXT,            EXT_GPU_PROGRAM_PARAMETERS,NULL )\
-    USE_GL_FUNC(PGLFNPROGRAMLOCALPARAMETERS4FVEXTPROC,              glProgramLocalParameters4fvEXT,          EXT_GPU_PROGRAM_PARAMETERS,NULL )\
-    /* GL_ATI_fragment_shader */ \
-    USE_GL_FUNC(PGLFNGENFRAGMENTSHADERSATI,                         glGenFragmentShadersATI,                    ATI_FRAGMENT_SHADER,    NULL )\
-    USE_GL_FUNC(PGLFNBINDFRAGMENTSHADERATI,                         glBindFragmentShaderATI,                    ATI_FRAGMENT_SHADER,    NULL )\
-    USE_GL_FUNC(PGLFNDELETEFRAGMENTSHADERATI,                       glDeleteFragmentShaderATI,                  ATI_FRAGMENT_SHADER,    NULL )\
-    USE_GL_FUNC(PGLFNBEGINFRAGMENTSHADERATI,                        glBeginFragmentShaderATI,                   ATI_FRAGMENT_SHADER,    NULL )\
-    USE_GL_FUNC(PGLFNENDFRAGMENTSHADERATI,                          glEndFragmentShaderATI,                     ATI_FRAGMENT_SHADER,    NULL )\
-    USE_GL_FUNC(PGLFNPASSTEXCOORDATI,                               glPassTexCoordATI,                          ATI_FRAGMENT_SHADER,    NULL )\
-    USE_GL_FUNC(PGLFNSAMPLEMAPATI,                                  glSampleMapATI,                             ATI_FRAGMENT_SHADER,    NULL )\
-    USE_GL_FUNC(PGLFNCOLORFRAGMENTOP1ATI,                           glColorFragmentOp1ATI,                      ATI_FRAGMENT_SHADER,    NULL )\
-    USE_GL_FUNC(PGLFNCOLORFRAGMENTOP2ATI,                           glColorFragmentOp2ATI,                      ATI_FRAGMENT_SHADER,    NULL )\
-    USE_GL_FUNC(PGLFNCOLORFRAGMENTOP3ATI,                           glColorFragmentOp3ATI,                      ATI_FRAGMENT_SHADER,    NULL )\
-    USE_GL_FUNC(PGLFNALPHAFRAGMENTOP1ATI,                           glAlphaFragmentOp1ATI,                      ATI_FRAGMENT_SHADER,    NULL )\
-    USE_GL_FUNC(PGLFNALPHAFRAGMENTOP2ATI,                           glAlphaFragmentOp2ATI,                      ATI_FRAGMENT_SHADER,    NULL )\
-    USE_GL_FUNC(PGLFNALPHAFRAGMENTOP3ATI,                           glAlphaFragmentOp3ATI,                      ATI_FRAGMENT_SHADER,    NULL )\
-    USE_GL_FUNC(PGLFNSETFRAGMENTSHADERCONSTANTATI,                  glSetFragmentShaderConstantATI,             ATI_FRAGMENT_SHADER,    NULL )\
-    /* GL_APPLE_flush_buffer_range */ \
-    USE_GL_FUNC(PGLFNBUFFERPARAMETERIAPPLE,                         glBufferParameteriAPPLE,                    APPLE_FLUSH_BUFFER_RANGE,NULL)\
-    USE_GL_FUNC(PGLFNFLUSHMAPPEDBUFFERRANGEAPPLE,                   glFlushMappedBufferRangeAPPLE,              APPLE_FLUSH_BUFFER_RANGE,NULL)
-
-
-/****************************************************
- * OpenGL WGL defines and functions pointer
- ****************************************************/
+#define GLX_SGIS_generate_mipmap 1
+#define GL_GENERATE_MIPMAP_SGIS                             0x8191
+#define GL_GENERATE_MIPMAP_HINT_SGIS                        0x8192
+#endif
+
+/* GLX_SGI_video_sync */
+typedef int (WINE_GLAPI *PGLXFNGETVIDEOSYNCSGIPROC)(unsigned int *);
+typedef int (WINE_GLAPI *PGLXFNWAITVIDEOSYNCSGIPROC)(int, int, unsigned int *);
 
 /* WGL_ARB_extensions_string */
-typedef const char * (WINAPI * WINED3D_PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc);
+typedef const char *(WINAPI *WINED3D_PFNWGLGETEXTENSIONSSTRINGARBPROC)(HDC hdc);
+
 /* WGL_ARB_multisample */
 #ifndef WGL_ARB_multisample
-#define WGL_SAMPLE_BUFFERS_ARB         0x2041
-#define WGL_SAMPLES_ARB                0x2042
-#endif
+#define WGL_ARB_multisample 1
+#define WGL_SAMPLE_BUFFERS_ARB                              0x2041
+#define WGL_SAMPLES_ARB                                     0x2042
+#endif
+
 /* WGL_ARB_pixel_format */
 #ifndef WGL_ARB_pixel_format
 #define WGL_ARB_pixel_format 1
-#define WGL_NUMBER_PIXEL_FORMATS_ARB   0x2000
-#define WGL_DRAW_TO_WINDOW_ARB         0x2001
-#define WGL_DRAW_TO_BITMAP_ARB         0x2002
-#define WGL_ACCELERATION_ARB           0x2003
-#define WGL_NEED_PALETTE_ARB           0x2004
-#define WGL_NEED_SYSTEM_PALETTE_ARB    0x2005
-#define WGL_SWAP_LAYER_BUFFERS_ARB     0x2006
-#define WGL_SWAP_METHOD_ARB            0x2007
-#define WGL_NUMBER_OVERLAYS_ARB        0x2008
-#define WGL_NUMBER_UNDERLAYS_ARB       0x2009
-#define WGL_TRANSPARENT_ARB            0x200A
-#define WGL_TRANSPARENT_RED_VALUE_ARB  0x2037
-#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038
-#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039
-#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A
-#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B
-#define WGL_SHARE_DEPTH_ARB            0x200C
-#define WGL_SHARE_STENCIL_ARB          0x200D
-#define WGL_SHARE_ACCUM_ARB            0x200E
-#define WGL_SUPPORT_GDI_ARB            0x200F
-#define WGL_SUPPORT_OPENGL_ARB         0x2010
-#define WGL_DOUBLE_BUFFER_ARB          0x2011
-#define WGL_STEREO_ARB                 0x2012
-#define WGL_PIXEL_TYPE_ARB             0x2013
-#define WGL_COLOR_BITS_ARB             0x2014
-#define WGL_RED_BITS_ARB               0x2015
-#define WGL_RED_SHIFT_ARB              0x2016
-#define WGL_GREEN_BITS_ARB             0x2017
-#define WGL_GREEN_SHIFT_ARB            0x2018
-#define WGL_BLUE_BITS_ARB              0x2019
-#define WGL_BLUE_SHIFT_ARB             0x201A
-#define WGL_ALPHA_BITS_ARB             0x201B
-#define WGL_ALPHA_SHIFT_ARB            0x201C
-#define WGL_ACCUM_BITS_ARB             0x201D
-#define WGL_ACCUM_RED_BITS_ARB         0x201E
-#define WGL_ACCUM_GREEN_BITS_ARB       0x201F
-#define WGL_ACCUM_BLUE_BITS_ARB        0x2020
-#define WGL_ACCUM_ALPHA_BITS_ARB       0x2021
-#define WGL_DEPTH_BITS_ARB             0x2022
-#define WGL_STENCIL_BITS_ARB           0x2023
-#define WGL_AUX_BUFFERS_ARB            0x2024
-#define WGL_NO_ACCELERATION_ARB        0x2025
-#define WGL_GENERIC_ACCELERATION_ARB   0x2026
-#define WGL_FULL_ACCELERATION_ARB      0x2027
-#define WGL_SWAP_EXCHANGE_ARB          0x2028
-#define WGL_SWAP_COPY_ARB              0x2029
-#define WGL_SWAP_UNDEFINED_ARB         0x202A
-#define WGL_TYPE_RGBA_ARB              0x202B
-#define WGL_TYPE_COLORINDEX_ARB        0x202C
-#endif
-typedef BOOL (WINAPI * WINED3D_PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues);
-typedef BOOL (WINAPI * WINED3D_PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues);
-typedef BOOL (WINAPI * WINED3D_PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
-/* WGL_ARB_make_current_read */
-typedef BOOL (WINAPI * WINED3D_PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
-typedef HDC (WINAPI * WINED3D_PFNWGLGETCURRENTREADDCARBPROC) (void);
-/* WGL_ARB_pbuffer */
-#ifndef WGL_ARB_pbuffer
-#define WGL_ARB_pbuffer 1
-#define WGL_DRAW_TO_PBUFFER_ARB        0x202D
-#define WGL_MAX_PBUFFER_PIXELS_ARB     0x202E
-#define WGL_MAX_PBUFFER_WIDTH_ARB      0x202F
-#define WGL_MAX_PBUFFER_HEIGHT_ARB     0x2030
-#define WGL_PBUFFER_LARGEST_ARB        0x2033
-#define WGL_PBUFFER_WIDTH_ARB          0x2034
-#define WGL_PBUFFER_HEIGHT_ARB         0x2035
-#define WGL_PBUFFER_LOST_ARB           0x2036
-#endif
-DECLARE_HANDLE(HPBUFFERARB);
-typedef HPBUFFERARB (WINAPI * WINED3D_PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
-typedef HDC (WINAPI * WINED3D_PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer);
-typedef int (WINAPI * WINED3D_PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC);
-typedef BOOL (WINAPI * WINED3D_PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer);
-typedef BOOL (WINAPI * WINED3D_PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue);
+#define WGL_NUMBER_PIXEL_FORMATS_ARB                        0x2000
+#define WGL_DRAW_TO_WINDOW_ARB                              0x2001
+#define WGL_DRAW_TO_BITMAP_ARB                              0x2002
+#define WGL_ACCELERATION_ARB                                0x2003
+#define WGL_NEED_PALETTE_ARB                                0x2004
+#define WGL_NEED_SYSTEM_PALETTE_ARB                         0x2005
+#define WGL_SWAP_LAYER_BUFFERS_ARB                          0x2006
+#define WGL_SWAP_METHOD_ARB                                 0x2007
+#define WGL_NUMBER_OVERLAYS_ARB                             0x2008
+#define WGL_NUMBER_UNDERLAYS_ARB                            0x2009
+#define WGL_TRANSPARENT_ARB                                 0x200a
+#define WGL_TRANSPARENT_RED_VALUE_ARB                       0x2037
+#define WGL_TRANSPARENT_GREEN_VALUE_ARB                     0x2038
+#define WGL_TRANSPARENT_BLUE_VALUE_ARB                      0x2039
+#define WGL_TRANSPARENT_ALPHA_VALUE_ARB                     0x203a
+#define WGL_TRANSPARENT_INDEX_VALUE_ARB                     0x203b
+#define WGL_SHARE_DEPTH_ARB                                 0x200c
+#define WGL_SHARE_STENCIL_ARB                               0x200d
+#define WGL_SHARE_ACCUM_ARB                                 0x200e
+#define WGL_SUPPORT_GDI_ARB                                 0x200f
+#define WGL_SUPPORT_OPENGL_ARB                              0x2010
+#define WGL_DOUBLE_BUFFER_ARB                               0x2011
+#define WGL_STEREO_ARB                                      0x2012
+#define WGL_PIXEL_TYPE_ARB                                  0x2013
+#define WGL_COLOR_BITS_ARB                                  0x2014
+#define WGL_RED_BITS_ARB                                    0x2015
+#define WGL_RED_SHIFT_ARB                                   0x2016
+#define WGL_GREEN_BITS_ARB                                  0x2017
+#define WGL_GREEN_SHIFT_ARB                                 0x2018
+#define WGL_BLUE_BITS_ARB                                   0x2019
+#define WGL_BLUE_SHIFT_ARB                                  0x201a
+#define WGL_ALPHA_BITS_ARB                                  0x201b
+#define WGL_ALPHA_SHIFT_ARB                                 0x201c
+#define WGL_ACCUM_BITS_ARB                                  0x201d
+#define WGL_ACCUM_RED_BITS_ARB                              0x201e
+#define WGL_ACCUM_GREEN_BITS_ARB                            0x201f
+#define WGL_ACCUM_BLUE_BITS_ARB                             0x2020
+#define WGL_ACCUM_ALPHA_BITS_ARB                            0x2021
+#define WGL_DEPTH_BITS_ARB                                  0x2022
+#define WGL_STENCIL_BITS_ARB                                0x2023
+#define WGL_AUX_BUFFERS_ARB                                 0x2024
+#define WGL_NO_ACCELERATION_ARB                             0x2025
+#define WGL_GENERIC_ACCELERATION_ARB                        0x2026
+#define WGL_FULL_ACCELERATION_ARB                           0x2027
+#define WGL_SWAP_EXCHANGE_ARB                               0x2028
+#define WGL_SWAP_COPY_ARB                                   0x2029
+#define WGL_SWAP_UNDEFINED_ARB                              0x202a
+#define WGL_TYPE_RGBA_ARB                                   0x202b
+#define WGL_TYPE_COLORINDEX_ARB                             0x202c
+#endif
+typedef BOOL (WINAPI *WINED3D_PFNWGLGETPIXELFORMATATTRIBIVARBPROC)(HDC hdc, int iPixelFormat,
+        int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues);
+typedef BOOL (WINAPI *WINED3D_PFNWGLGETPIXELFORMATATTRIBFVARBPROC)(HDC hdc, int iPixelFormat,
+        int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues);
+typedef BOOL (WINAPI *WINED3D_PFNWGLCHOOSEPIXELFORMATARBPROC)(HDC hdc, const int *piAttribIList,
+        const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
+
+/* WGL_ARB_pixel_format_float */
 #ifndef WGL_ARB_pixel_format_float
 #define WGL_ARB_pixel_format_float 1
-#define WGL_TYPE_RGBA_FLOAT_ARB        0x21A0
-#endif
+#define WGL_TYPE_RGBA_FLOAT_ARB                             0x21a0
+#endif
+
 /* WGL_WINE_pixel_format_passthrough */
-typedef BOOL (WINAPI * WINED3D_PFNWGLSETPIXELFORMATWINE) (HDC hdc, int iPixelFormat, const PIXELFORMATDESCRIPTOR* ppfd);
+typedef BOOL (WINAPI *WINED3D_PFNWGLSETPIXELFORMATWINE)(HDC hdc, int iPixelFormat,
+        const PIXELFORMATDESCRIPTOR *ppfd);
+
+#define GL_EXT_FUNCS_GEN \
+    /* GL_APPLE_fence */ \
+    USE_GL_FUNC(PGLFNGENFENCESAPPLEPROC, \
+            glGenFencesAPPLE,                           APPLE_FENCE,                    NULL) \
+    USE_GL_FUNC(PGLFNDELETEFENCESAPPLEPROC, \
+            glDeleteFencesAPPLE,                        APPLE_FENCE,                    NULL) \
+    USE_GL_FUNC(PGLFNSETFENCEAPPLEPROC, \
+            glSetFenceAPPLE,                            APPLE_FENCE,                    NULL) \
+    USE_GL_FUNC(PGLFNTESTFENCEAPPLEPROC, \
+            glTestFenceAPPLE,                           APPLE_FENCE,                    NULL) \
+    USE_GL_FUNC(PGLFNFINISHFENCEAPPLEPROC, \
+            glFinishFenceAPPLE,                         APPLE_FENCE,                    NULL) \
+    USE_GL_FUNC(PGLFNISFENCEAPPLEPROC, \
+            glIsFenceAPPLE,                             APPLE_FENCE,                    NULL) \
+    USE_GL_FUNC(PGLFNTESTOBJECTAPPLEPROC, \
+            glTestObjectAPPLE,                          APPLE_FENCE,                    NULL) \
+    USE_GL_FUNC(PGLFNFINISHOBJECTAPPLEPROC, \
+            glFinishObjectAPPLE,                        APPLE_FENCE,                    NULL) \
+    /* GL_APPLE_flush_buffer_range */ \
+    USE_GL_FUNC(PGLFNBUFFERPARAMETERIAPPLE, \
+            glBufferParameteriAPPLE,                    APPLE_FLUSH_BUFFER_RANGE,       NULL) \
+    USE_GL_FUNC(PGLFNFLUSHMAPPEDBUFFERRANGEAPPLE, \
+            glFlushMappedBufferRangeAPPLE,              APPLE_FLUSH_BUFFER_RANGE,       NULL) \
+    /* GL_APPLE_flush_render */ \
+    USE_GL_FUNC(PGLFNFLUSHRENDERAPPLEPROC, \
+            glFlushRenderAPPLE,                         APPLE_FLUSH_RENDER,             NULL) \
+    USE_GL_FUNC(PGLFNFINISHRENDERAPPLEPROC, \
+            glFinishRenderAPPLE,                        APPLE_FLUSH_RENDER,             NULL) \
+    /* GL_ARB_color_buffer_float */ \
+    USE_GL_FUNC(PGLFNCLAMPCOLORARBPROC, \
+            glClampColorARB,                            ARB_COLOR_BUFFER_FLOAT,         NULL) \
+    /* GL_ARB_draw_buffers */ \
+    USE_GL_FUNC(PGLFNDRAWBUFFERSARBPROC, \
+            glDrawBuffersARB,                           ARB_DRAW_BUFFERS,               NULL) \
+    /* GL_ARB_framebuffer_object */ \
+    USE_GL_FUNC(PGLFNGLISRENDERBUFFERPROC, \
+            glIsRenderbuffer,                           ARB_FRAMEBUFFER_OBJECT,         NULL) \
+    USE_GL_FUNC(PGLFNGLBINDRENDERBUFFERPROC, \
+            glBindRenderbuffer,                         ARB_FRAMEBUFFER_OBJECT,         NULL) \
+    USE_GL_FUNC(PGLFNGLDELETERENDERBUFFERSPROC, \
+            glDeleteRenderbuffers,                      ARB_FRAMEBUFFER_OBJECT,         NULL) \
+    USE_GL_FUNC(PGLFNGLGENRENDERBUFFERSPROC, \
+            glGenRenderbuffers,                         ARB_FRAMEBUFFER_OBJECT,         NULL) \
+    USE_GL_FUNC(PGLFNGLRENDERBUFFERSTORAGEPROC, \
+            glRenderbufferStorage,                      ARB_FRAMEBUFFER_OBJECT,         NULL) \
+    USE_GL_FUNC(PGLFNRENDERBUFFERSTORAGEMULTISAMPLEPROC, \
+            glRenderbufferStorageMultisample,           ARB_FRAMEBUFFER_OBJECT,         NULL) \
+    USE_GL_FUNC(PGLFNGLGETRENDERBUFFERPARAMETERIVPROC, \
+            glGetRenderbufferParameteriv,               ARB_FRAMEBUFFER_OBJECT,         NULL) \
+    USE_GL_FUNC(PGLFNGLISFRAMEBUFFERPROC, \
+            glIsFramebuffer,                            ARB_FRAMEBUFFER_OBJECT,         NULL) \
+    USE_GL_FUNC(PGLFNGLBINDFRAMEBUFFERPROC, \
+            glBindFramebuffer,                          ARB_FRAMEBUFFER_OBJECT,         NULL) \
+    USE_GL_FUNC(PGLFNGLDELETEFRAMEBUFFERSPROC, \
+            glDeleteFramebuffers,                       ARB_FRAMEBUFFER_OBJECT,         NULL) \
+    USE_GL_FUNC(PGLFNGLGENFRAMEBUFFERSPROC, \
+            glGenFramebuffers,                          ARB_FRAMEBUFFER_OBJECT,         NULL) \
+    USE_GL_FUNC(PGLFNGLCHECKFRAMEBUFFERSTATUSPROC, \
+            glCheckFramebufferStatus,                   ARB_FRAMEBUFFER_OBJECT,         NULL) \
+    USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE1DPROC, \
+            glFramebufferTexture1D,                     ARB_FRAMEBUFFER_OBJECT,         NULL) \
+    USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE2DPROC, \
+            glFramebufferTexture2D,                     ARB_FRAMEBUFFER_OBJECT,         NULL) \
+    USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE3DPROC, \
+            glFramebufferTexture3D,                     ARB_FRAMEBUFFER_OBJECT,         NULL) \
+    USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURELAYERPROC,     \
+            glFramebufferTextureLayer,                  ARB_FRAMEBUFFER_OBJECT,         NULL) \
+    USE_GL_FUNC(PGLFNGLFRAMEBUFFERRENDERBUFFERPROC, \
+            glFramebufferRenderbuffer,                  ARB_FRAMEBUFFER_OBJECT,         NULL) \
+    USE_GL_FUNC(PGLFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC, \
+            glGetFramebufferAttachmentParameteriv,      ARB_FRAMEBUFFER_OBJECT,         NULL) \
+    USE_GL_FUNC(PGLFNGLBLITFRAMEBUFFERPROC, \
+            glBlitFramebuffer,                          ARB_FRAMEBUFFER_OBJECT,         NULL) \
+    USE_GL_FUNC(PGLFNGLGENERATEMIPMAPPROC, \
+            glGenerateMipmap,                           ARB_FRAMEBUFFER_OBJECT,         NULL) \
+    /* GL_ARB_geometry_shader4 */ \
+    USE_GL_FUNC(PGLFNPROGRAMPARAMETERIARBPROC, \
+            glProgramParameteriARB,                     ARB_GEOMETRY_SHADER4,           NULL) \
+    USE_GL_FUNC(PGLFNFRAMEBUFFERTEXTUREARBPROC, \
+            glFramebufferTextureARB,                    ARB_GEOMETRY_SHADER4,           NULL) \
+    USE_GL_FUNC(PGLFNFRAMEBUFFERTEXTURELAYERARBPROC, \
+            glFramebufferTextureLayerARB,               ARB_GEOMETRY_SHADER4,           NULL) \
+    USE_GL_FUNC(PGLFNFRAMEBUFFERTEXTUREFACEARBPROC, \
+            glFramebufferTextureFaceARB,                ARB_GEOMETRY_SHADER4,           NULL) \
+    /* GL_ARB_imaging, GL_EXT_blend_minmax */ \
+    USE_GL_FUNC(PGLFNBLENDCOLORPROC, \
+            glBlendColorEXT,                            EXT_BLEND_COLOR,                NULL) \
+    USE_GL_FUNC(PGLFNBLENDEQUATIONPROC, \
+            glBlendEquationEXT,                         EXT_BLEND_MINMAX,               NULL) \
+    /* GL_ARB_map_buffer_range */ \
+    USE_GL_FUNC(PGLFNMAPBUFFERRANGEPROC, \
+            glMapBufferRange,                           ARB_MAP_BUFFER_RANGE,           NULL) \
+    USE_GL_FUNC(PGLFNFLUSHMAPPEDBUFFERRANGEPROC, \
+            glFlushMappedBufferRange,                   ARB_MAP_BUFFER_RANGE,           NULL) \
+    /* GL_ARB_multisample */ \
+    USE_GL_FUNC(WINED3D_PFNGLSAMPLECOVERAGEARBPROC, \
+            glSampleCoverageARB,                        ARB_MULTISAMPLE,                NULL) \
+    /* GL_ARB_multitexture */ \
+    USE_GL_FUNC(WINED3D_PFNGLACTIVETEXTUREARBPROC, \
+            glActiveTextureARB,                         ARB_MULTITEXTURE,               NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLCLIENTACTIVETEXTUREARBPROC, \
+            glClientActiveTextureARB,                   ARB_MULTITEXTURE,               NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD1FARBPROC, \
+            glMultiTexCoord1fARB,                       ARB_MULTITEXTURE,               NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD1FVARBPROC, \
+            glMultiTexCoord1fvARB,                      ARB_MULTITEXTURE,               NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD2FARBPROC, \
+            glMultiTexCoord2fARB,                       ARB_MULTITEXTURE,               NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD2FVARBPROC, \
+            glMultiTexCoord2fvARB,                      ARB_MULTITEXTURE,               NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD3FARBPROC, \
+            glMultiTexCoord3fARB,                       ARB_MULTITEXTURE,               NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD3FVARBPROC, \
+            glMultiTexCoord3fvARB,                      ARB_MULTITEXTURE,               NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD4FARBPROC, \
+            glMultiTexCoord4fARB,                       ARB_MULTITEXTURE,               NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD4FVARBPROC, \
+            glMultiTexCoord4fvARB,                      ARB_MULTITEXTURE,               NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD2SVARBPROC, \
+            glMultiTexCoord2svARB,                      ARB_MULTITEXTURE,               NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD4SVARBPROC, \
+            glMultiTexCoord4svARB,                      ARB_MULTITEXTURE,               NULL) \
+    /* GL_ARB_occlusion_query */ \
+    USE_GL_FUNC(PGLFNGENQUERIESARBPROC, \
+            glGenQueriesARB,                            ARB_OCCLUSION_QUERY,            NULL) \
+    USE_GL_FUNC(PGLFNDELETEQUERIESARBPROC, \
+            glDeleteQueriesARB,                         ARB_OCCLUSION_QUERY,            NULL) \
+    USE_GL_FUNC(PGLFNBEGINQUERYARBPROC, \
+            glBeginQueryARB,                            ARB_OCCLUSION_QUERY,            NULL) \
+    USE_GL_FUNC(PGLFNENDQUERYARBPROC, \
+            glEndQueryARB,                              ARB_OCCLUSION_QUERY,            NULL) \
+    USE_GL_FUNC(PGLFNGETQUERYOBJECTIVARBPROC, \
+            glGetQueryObjectivARB,                      ARB_OCCLUSION_QUERY,            NULL) \
+    USE_GL_FUNC(PGLFNGETQUERYOBJECTUIVARBPROC, \
+            glGetQueryObjectuivARB,                     ARB_OCCLUSION_QUERY,            NULL) \
+    /* GL_ARB_point_parameters */ \
+    USE_GL_FUNC(PGLFNGLPOINTPARAMETERFARBPROC, \
+            glPointParameterfARB,                       ARB_POINT_PARAMETERS,           NULL) \
+    USE_GL_FUNC(PGLFNGLPOINTPARAMETERFVARBPROC, \
+            glPointParameterfvARB,                      ARB_POINT_PARAMETERS,           NULL) \
+    /* GL_ARB_provoking_vertex */ \
+    USE_GL_FUNC(PGLFNGLPROVOKINGVERTEXPROC, \
+            glProvokingVertex,                          ARB_PROVOKING_VERTEX,           NULL) \
+    /* GL_ARB_shader_objects */ \
+    USE_GL_FUNC(WINED3D_PFNGLGETOBJECTPARAMETERIVARBPROC, \
+            glGetObjectParameterivARB,                  ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLGETOBJECTPARAMETERFVARBPROC, \
+            glGetObjectParameterfvARB,                  ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLGETUNIFORMLOCATIONARBPROC, \
+            glGetUniformLocationARB,                    ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLGETACTIVEUNIFORMARBPROC, \
+            glGetActiveUniformARB,                      ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORM1IARBPROC, \
+            glUniform1iARB,                             ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORM2IARBPROC, \
+            glUniform2iARB,                             ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORM3IARBPROC, \
+            glUniform3iARB,                             ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORM4IARBPROC, \
+            glUniform4iARB,                             ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORM1FARBPROC, \
+            glUniform1fARB,                             ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORM2FARBPROC, \
+            glUniform2fARB,                             ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORM3FARBPROC, \
+            glUniform3fARB,                             ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORM4FARBPROC, \
+            glUniform4fARB,                             ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORM1FVARBPROC, \
+            glUniform1fvARB,                            ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORM2FVARBPROC, \
+            glUniform2fvARB,                            ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORM3FVARBPROC, \
+            glUniform3fvARB,                            ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORM4FVARBPROC, \
+            glUniform4fvARB,                            ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORM1IVARBPROC, \
+            glUniform1ivARB,                            ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORM2IVARBPROC, \
+            glUniform2ivARB,                            ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORM3IVARBPROC, \
+            glUniform3ivARB,                            ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORM4IVARBPROC, \
+            glUniform4ivARB,                            ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORMMATRIX2FVARBPROC, \
+            glUniformMatrix2fvARB,                      ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORMMATRIX3FVARBPROC, \
+            glUniformMatrix3fvARB,                      ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORMMATRIX4FVARBPROC, \
+            glUniformMatrix4fvARB,                      ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLGETUNIFORMFVARBPROC, \
+            glGetUniformfvARB,                          ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLGETUNIFORMIVARBPROC, \
+            glGetUniformivARB,                          ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLGETINFOLOGARBPROC, \
+            glGetInfoLogARB,                            ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLUSEPROGRAMOBJECTARBPROC, \
+            glUseProgramObjectARB,                      ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLCREATESHADEROBJECTARBPROC, \
+            glCreateShaderObjectARB,                    ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLSHADERSOURCEARBPROC, \
+            glShaderSourceARB,                          ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLCOMPILESHADERARBPROC, \
+            glCompileShaderARB,                         ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLCREATEPROGRAMOBJECTARBPROC, \
+            glCreateProgramObjectARB,                   ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLATTACHOBJECTARBPROC, \
+            glAttachObjectARB,                          ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLLINKPROGRAMARBPROC, \
+            glLinkProgramARB,                           ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLDETACHOBJECTARBPROC, \
+            glDetachObjectARB,                          ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLDELETEOBJECTARBPROC, \
+            glDeleteObjectARB,                          ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLVALIDATEPROGRAMARBPROC, \
+            glValidateProgramARB,                       ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLGETATTACHEDOBJECTSARBPROC, \
+            glGetAttachedObjectsARB,                    ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLGETHANDLEARBPROC, \
+            glGetHandleARB,                             ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLGETSHADERSOURCEARBPROC, \
+            glGetShaderSourceARB,                       ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLBINDATTRIBLOCATIONARBPROC, \
+            glBindAttribLocationARB,                    ARB_SHADER_OBJECTS,             NULL) \
+    USE_GL_FUNC(WINED3D_PFNGLGETATTRIBLOCATIONARBPROC, \
+            glGetAttribLocationARB,                     ARB_SHADER_OBJECTS,             NULL) \
+    /* GL_ARB_sync */ \
+    USE_GL_FUNC(PGLFNFENCESYNCPROC, \
+            glFenceSync,                                ARB_SYNC,                       NULL) \
+    USE_GL_FUNC(PGLFNISSYNCPROC, \
+            glIsSync,                                   ARB_SYNC,                       NULL) \
+    USE_GL_FUNC(PGLFNDELETESYNCPROC, \
+            glDeleteSync,                               ARB_SYNC,                       NULL) \
+    USE_GL_FUNC(PGLFNCLIENTWAITSYNCPROC, \
+            glClientWaitSync,                           ARB_SYNC,                       NULL) \
+    USE_GL_FUNC(PGLFNWAITSYNCPROC, \
+            glWaitSync,                                 ARB_SYNC,                       NULL) \
+    USE_GL_FUNC(PGLFNGETINTEGER64VPROC, \
+            glGetInteger64v,                            ARB_SYNC,                       NULL) \
+    USE_GL_FUNC(PGLFNGETSYNCIVPROC, \
+            glGetSynciv,                                ARB_SYNC,                       NULL) \
+    /* GL_ARB_texture_compression */ \
+    USE_GL_FUNC(PGLFNCOMPRESSEDTEXIMAGE2DPROC, \
+            glCompressedTexImage2DARB,                  ARB_TEXTURE_COMPRESSION,        NULL) \
+    USE_GL_FUNC(PGLFNCOMPRESSEDTEXIMAGE3DPROC, \
+            glCompressedTexImage3DARB,                  ARB_TEXTURE_COMPRESSION,        NULL) \
+    USE_GL_FUNC(PGLFNCOMPRESSEDTEXSUBIMAGE2DPROC, \
+            glCompressedTexSubImage2DARB,               ARB_TEXTURE_COMPRESSION,        NULL) \
+    USE_GL_FUNC(PGLFNCOMPRESSEDTEXSUBIMAGE3DPROC, \
+            glCompressedTexSubImage3DARB,               ARB_TEXTURE_COMPRESSION,        NULL) \
+    USE_GL_FUNC(PGLFNGETCOMPRESSEDTEXIMAGEPROC, \
+            glGetCompressedTexImageARB,                 ARB_TEXTURE_COMPRESSION,        NULL) \
+    /* GL_ARB_vertex_blend */ \
+    USE_GL_FUNC(PGLFNGLWEIGHTPOINTERARB, \
+            glWeightPointerARB,                         ARB_VERTEX_BLEND,               NULL) \
+    USE_GL_FUNC(PGLFNGLWEIGHTBV, \
+            glWeightbvARB,                              ARB_VERTEX_BLEND,               NULL) \
+    USE_GL_FUNC(PGLFNGLWEIGHTSV, \
+            glWeightsvARB,                              ARB_VERTEX_BLEND,               NULL) \
+    USE_GL_FUNC(PGLFNGLWEIGHTIV, \
+            glWeightivARB,                              ARB_VERTEX_BLEND,               NULL) \
+    USE_GL_FUNC(PGLFNGLWEIGHTFV, \
+            glWeightfvARB,                              ARB_VERTEX_BLEND,               NULL) \
+    USE_GL_FUNC(PGLFNGLWEIGHTDV, \
+            glWeightdvARB,                              ARB_VERTEX_BLEND,               NULL) \
+    USE_GL_FUNC(PGLFNGLWEIGHTUBV, \
+            glWeightubvARB,                             ARB_VERTEX_BLEND,               NULL) \
+    USE_GL_FUNC(PGLFNGLWEIGHTUSV, \
+            glWeightusvARB,                             ARB_VERTEX_BLEND,               NULL) \
+    USE_GL_FUNC(PGLFNGLWEIGHTUIV, \
+            glWeightuivARB,                             ARB_VERTEX_BLEND,               NULL) \
+    USE_GL_FUNC(PGLFNGLVERTEXBLENDARB, \
+            glVertexBlendARB,                           ARB_VERTEX_BLEND,               NULL) \
+    /* GL_ARB_vertex_buffer_object */ \
+    USE_GL_FUNC(PGLFNBINDBUFFERARBPROC, \
+            glBindBufferARB,                            ARB_VERTEX_BUFFER_OBJECT,       NULL) \
+    USE_GL_FUNC(PGLFNDELETEBUFFERSARBPROC, \
+            glDeleteBuffersARB,                         ARB_VERTEX_BUFFER_OBJECT,       NULL) \
+    USE_GL_FUNC(PGLFNGENBUFFERSARBPROC, \
+            glGenBuffersARB,                            ARB_VERTEX_BUFFER_OBJECT,       NULL) \
+    USE_GL_FUNC(PGLFNISBUFFERARBPROC, \
+            glIsBufferARB,                              ARB_VERTEX_BUFFER_OBJECT,       NULL) \
+    USE_GL_FUNC(PGLFNBUFFERDATAARBPROC, \
+            glBufferDataARB,                            ARB_VERTEX_BUFFER_OBJECT,       NULL) \
+    USE_GL_FUNC(PGLFNBUFFERSUBDATAARBPROC, \
+            glBufferSubDataARB,                         ARB_VERTEX_BUFFER_OBJECT,       NULL) \
+    USE_GL_FUNC(PGLFNGETBUFFERSUBDATAARBPROC, \
+            glGetBufferSubDataARB,                      ARB_VERTEX_BUFFER_OBJECT,       NULL) \
+    USE_GL_FUNC(PGLFNMAPBUFFERARBPROC, \
+            glMapBufferARB,                             ARB_VERTEX_BUFFER_OBJECT,       NULL) \
+    USE_GL_FUNC(PGLFNUNMAPBUFFERARBPROC, \
+            glUnmapBufferARB,                           ARB_VERTEX_BUFFER_OBJECT,       NULL) \
+    USE_GL_FUNC(PGLFNGETBUFFERPARAMETERIVARBPROC, \
+            glGetBufferParameterivARB,                  ARB_VERTEX_BUFFER_OBJECT,       NULL) \
+    USE_GL_FUNC(PGLFNGETBUFFERPOINTERVARBPROC, \
+            glGetBufferPointervARB,                     ARB_VERTEX_BUFFER_OBJECT,       NULL) \
+    /* GL_ARB_vertex_program */ \
+    USE_GL_FUNC(PGLFNGENPROGRAMSARBPROC, \
+            glGenProgramsARB,                           ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNBINDPROGRAMARBPROC, \
+            glBindProgramARB,                           ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNPROGRAMSTRINGARBPROC, \
+            glProgramStringARB,                         ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNDELETEPROGRAMSARBPROC, \
+            glDeleteProgramsARB,                        ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNPROGRAMENVPARAMETER4FVARBPROC, \
+            glProgramEnvParameter4fvARB,                ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNPROGRAMLOCALPARAMETER4FVARBPROC, \
+            glProgramLocalParameter4fvARB,              ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIBPOINTERARBPROC, \
+            glVertexAttribPointerARB,                   ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNENABLEVERTEXATTRIBARRAYARBPROC, \
+            glEnableVertexAttribArrayARB,               ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNDISABLEVERTEXATTRIBARRAYARBPROC, \
+            glDisableVertexAttribArrayARB,              ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB1DARBPROC, \
+            glVertexAttrib1dARB,                        ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB1DVARBPROC, \
+            glVertexAttrib1dvARB,                       ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB1FARBPROC, \
+            glVertexAttrib1fARB,                        ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB1FVARBPROC, \
+            glVertexAttrib1fvARB,                       ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB1SARBPROC, \
+            glVertexAttrib1sARB,                        ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB1SVARBPROC, \
+            glVertexAttrib1svARB,                       ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB2DARBPROC, \
+            glVertexAttrib2dARB,                        ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB2DVARBPROC, \
+            glVertexAttrib2dvARB,                       ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB2FARBPROC, \
+            glVertexAttrib2fARB,                        ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB2FVARBPROC, \
+            glVertexAttrib2fvARB,                       ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB2SARBPROC, \
+            glVertexAttrib2sARB,                        ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB2SVARBPROC, \
+            glVertexAttrib2svARB,                       ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB3DARBPROC, \
+            glVertexAttrib3dARB,                        ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB3DVARBPROC, \
+            glVertexAttrib3dvARB,                       ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB3FARBPROC, \
+            glVertexAttrib3fARB,                        ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB3FVARBPROC, \
+            glVertexAttrib3fvARB,                       ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB3SARBPROC, \
+            glVertexAttrib3sARB,                        ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB3SVARBPROC, \
+            glVertexAttrib3svARB,                       ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4NBVARBPROC, \
+            glVertexAttrib4NbvARB,                      ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4NIVARBPROC, \
+            glVertexAttrib4NivARB,                      ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4NSVARBPROC, \
+            glVertexAttrib4NsvARB,                      ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4NUBARBPROC, \
+            glVertexAttrib4NubARB,                      ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4NUBVARBPROC, \
+            glVertexAttrib4NubvARB,                     ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4NUIVARBPROC, \
+            glVertexAttrib4NuivARB,                     ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4NUSVARBPROC, \
+            glVertexAttrib4NusvARB,                     ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4BVARBPROC, \
+            glVertexAttrib4bvARB,                       ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4DARBPROC, \
+            glVertexAttrib4dARB,                        ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4DVARBPROC, \
+            glVertexAttrib4dvARB,                       ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4FARBPROC, \
+            glVertexAttrib4fARB,                        ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4FVARBPROC, \
+            glVertexAttrib4fvARB,                       ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4IVARBPROC, \
+            glVertexAttrib4ivARB,                       ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4SARBPROC, \
+            glVertexAttrib4sARB,                        ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4SVARBPROC, \
+            glVertexAttrib4svARB,                       ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4UBVARBPROC, \
+            glVertexAttrib4ubvARB,                      ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4UIVARBPROC, \
+            glVertexAttrib4uivARB,                      ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4USVARBPROC, \
+            glVertexAttrib4usvARB,                      ARB_VERTEX_PROGRAM,             NULL) \
+    USE_GL_FUNC(PGLFNGETPROGRAMIVARBPROC, \
+            glGetProgramivARB,                          ARB_VERTEX_PROGRAM,             NULL) \
+    /* GL_ATI_fragment_shader */ \
+    USE_GL_FUNC(PGLFNGENFRAGMENTSHADERSATI, \
+            glGenFragmentShadersATI,                    ATI_FRAGMENT_SHADER,            NULL) \
+    USE_GL_FUNC(PGLFNBINDFRAGMENTSHADERATI, \
+            glBindFragmentShaderATI,                    ATI_FRAGMENT_SHADER,            NULL) \
+    USE_GL_FUNC(PGLFNDELETEFRAGMENTSHADERATI, \
+            glDeleteFragmentShaderATI,                  ATI_FRAGMENT_SHADER,            NULL) \
+    USE_GL_FUNC(PGLFNBEGINFRAGMENTSHADERATI, \
+            glBeginFragmentShaderATI,                   ATI_FRAGMENT_SHADER,            NULL) \
+    USE_GL_FUNC(PGLFNENDFRAGMENTSHADERATI, \
+            glEndFragmentShaderATI,                     ATI_FRAGMENT_SHADER,            NULL) \
+    USE_GL_FUNC(PGLFNPASSTEXCOORDATI, \
+            glPassTexCoordATI,                          ATI_FRAGMENT_SHADER,            NULL) \
+    USE_GL_FUNC(PGLFNSAMPLEMAPATI, \
+            glSampleMapATI,                             ATI_FRAGMENT_SHADER,            NULL) \
+    USE_GL_FUNC(PGLFNCOLORFRAGMENTOP1ATI, \
+            glColorFragmentOp1ATI,                      ATI_FRAGMENT_SHADER,            NULL) \
+    USE_GL_FUNC(PGLFNCOLORFRAGMENTOP2ATI, \
+            glColorFragmentOp2ATI,                      ATI_FRAGMENT_SHADER,            NULL) \
+    USE_GL_FUNC(PGLFNCOLORFRAGMENTOP3ATI, \
+            glColorFragmentOp3ATI,                      ATI_FRAGMENT_SHADER,            NULL) \
+    USE_GL_FUNC(PGLFNALPHAFRAGMENTOP1ATI, \
+            glAlphaFragmentOp1ATI,                      ATI_FRAGMENT_SHADER,            NULL) \
+    USE_GL_FUNC(PGLFNALPHAFRAGMENTOP2ATI, \
+            glAlphaFragmentOp2ATI,                      ATI_FRAGMENT_SHADER,            NULL) \
+    USE_GL_FUNC(PGLFNALPHAFRAGMENTOP3ATI, \
+            glAlphaFragmentOp3ATI,                      ATI_FRAGMENT_SHADER,            NULL) \
+    USE_GL_FUNC(PGLFNSETFRAGMENTSHADERCONSTANTATI, \
+            glSetFragmentShaderConstantATI,             ATI_FRAGMENT_SHADER,            NULL) \
+    /* GL_ATI_separate_stencil */ \
+    USE_GL_FUNC(PGLFNSTENCILOPSEPARATEATIPROC, \
+            glStencilOpSeparateATI,                     ATI_SEPARATE_STENCIL,           NULL) \
+    USE_GL_FUNC(PGLFNSTENCILFUNCSEPARATEATIPROC, \
+            glStencilFuncSeparateATI,                   ATI_SEPARATE_STENCIL,           NULL) \
+    /* GL_EXT_blend_equation_separate */ \
+    USE_GL_FUNC(PGLFNBLENDFUNCSEPARATEEXTPROC, \
+            glBlendFuncSeparateEXT,                     EXT_BLEND_FUNC_SEPARATE,        NULL) \
+    /* GL_EXT_blend_func_separate */ \
+    USE_GL_FUNC(PGLFNBLENDEQUATIONSEPARATEEXTPROC, \
+            glBlendEquationSeparateEXT,                 EXT_BLEND_EQUATION_SEPARATE,    NULL) \
+    /* GL_EXT_draw_buffers2 */ \
+    USE_GL_FUNC(PGLFNCOLORMASKINDEXEDEXTPROC, \
+            glColorMaskIndexedEXT,                      EXT_DRAW_BUFFERS2,              NULL) \
+    USE_GL_FUNC(PGLFNGETBOOLEANINDEXEDVEXTPROC, \
+            glGetBooleanIndexedvEXT,                    EXT_DRAW_BUFFERS2,              NULL) \
+    USE_GL_FUNC(PGLFNGETINTEGERINDEXEDVEXTPROC, \
+            glGetIntegerIndexedvEXT,                    EXT_DRAW_BUFFERS2,              NULL) \
+    USE_GL_FUNC(PGLFNENABLEINDEXEDEXTPROC, \
+            glEnableIndexedEXT,                         EXT_DRAW_BUFFERS2,              NULL) \
+    USE_GL_FUNC(PGLFNDISABLEINDEXEDEXTPROC, \
+            glDisableIndexedEXT,                        EXT_DRAW_BUFFERS2,              NULL) \
+    USE_GL_FUNC(PGLFNISENABLEDINDEXEDEXTPROC, \
+            glIsEnabledIndexedEXT,                      EXT_DRAW_BUFFERS2,              NULL) \
+    /* GL_EXT_fog_coord */ \
+    USE_GL_FUNC(PGLFNGLFOGCOORDFEXTPROC, \
+            glFogCoordfEXT,                             EXT_FOG_COORD,                  NULL) \
+    USE_GL_FUNC(PGLFNGLFOGCOORDFVEXTPROC, \
+            glFogCoordfvEXT,                            EXT_FOG_COORD,                  NULL) \
+    USE_GL_FUNC(PGLFNGLFOGCOORDDEXTPROC, \
+            glFogCoorddEXT,                             EXT_FOG_COORD,                  NULL) \
+    USE_GL_FUNC(PGLFNGLFOGCOORDDVEXTPROC, \
+            glFogCoorddvEXT,                            EXT_FOG_COORD,                  NULL) \
+    USE_GL_FUNC(PGLFNGLFOGCOORDPOINTEREXTPROC, \
+            glFogCoordPointerEXT,                       EXT_FOG_COORD,                  NULL) \
+    /* GL_EXT_framebuffer_blit */ \
+    USE_GL_FUNC(PGLFNGLBLITFRAMEBUFFEREXTPROC, \
+            glBlitFramebufferEXT,                       EXT_FRAMEBUFFER_BLIT,           NULL) \
+    /* GL_EXT_framebuffer_multisample */ \
+    USE_GL_FUNC(PGLFNRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC, \
+            glRenderbufferStorageMultisampleEXT,        EXT_FRAMEBUFFER_MULTISAMPLE,    NULL) \
+    /* GL_EXT_framebuffer_object */ \
+    USE_GL_FUNC(PGLFNGLISRENDERBUFFEREXTPROC, \
+            glIsRenderbufferEXT,                        EXT_FRAMEBUFFER_OBJECT,         NULL) \
+    USE_GL_FUNC(PGLFNGLBINDRENDERBUFFEREXTPROC, \
+            glBindRenderbufferEXT,                      EXT_FRAMEBUFFER_OBJECT,         NULL) \
+    USE_GL_FUNC(PGLFNGLDELETERENDERBUFFERSEXTPROC, \
+            glDeleteRenderbuffersEXT,                   EXT_FRAMEBUFFER_OBJECT,         NULL) \
+    USE_GL_FUNC(PGLFNGLGENRENDERBUFFERSEXTPROC, \
+            glGenRenderbuffersEXT,                      EXT_FRAMEBUFFER_OBJECT,         NULL) \
+    USE_GL_FUNC(PGLFNGLRENDERBUFFERSTORAGEEXTPROC, \
+            glRenderbufferStorageEXT,                   EXT_FRAMEBUFFER_OBJECT,         NULL) \
+    USE_GL_FUNC(PGLFNGLISFRAMEBUFFEREXTPROC, \
+            glIsFramebufferEXT,                         EXT_FRAMEBUFFER_OBJECT,         NULL) \
+    USE_GL_FUNC(PGLFNGLBINDFRAMEBUFFEREXTPROC, \
+            glBindFramebufferEXT,                       EXT_FRAMEBUFFER_OBJECT,         NULL) \
+    USE_GL_FUNC(PGLFNGLDELETEFRAMEBUFFERSEXTPROC, \
+            glDeleteFramebuffersEXT,                    EXT_FRAMEBUFFER_OBJECT,         NULL) \
+    USE_GL_FUNC(PGLFNGLGENFRAMEBUFFERSEXTPROC, \
+            glGenFramebuffersEXT,                       EXT_FRAMEBUFFER_OBJECT,         NULL) \
+    USE_GL_FUNC(PGLFNGLCHECKFRAMEBUFFERSTATUSEXTPROC, \
+            glCheckFramebufferStatusEXT,                EXT_FRAMEBUFFER_OBJECT,         NULL) \
+    USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE1DEXTPROC, \
+            glFramebufferTexture1DEXT,                  EXT_FRAMEBUFFER_OBJECT,         NULL) \
+    USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE2DEXTPROC, \
+            glFramebufferTexture2DEXT,                  EXT_FRAMEBUFFER_OBJECT,         NULL) \
+    USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE3DEXTPROC, \
+            glFramebufferTexture3DEXT,                  EXT_FRAMEBUFFER_OBJECT,         NULL) \
+    USE_GL_FUNC(PGLFNGLFRAMEBUFFERRENDERBUFFEREXTPROC, \
+            glFramebufferRenderbufferEXT,               EXT_FRAMEBUFFER_OBJECT,         NULL) \
+    USE_GL_FUNC(PGLFNGLGENERATEMIPMAPEXTPROC, \
+            glGenerateMipmapEXT,                        EXT_FRAMEBUFFER_OBJECT,         NULL) \
+    USE_GL_FUNC(PGLFNGLGETRENDERBUFFERPARAMETERIVEXTPROC, \
+            glGetRenderbufferParameterivEXT,            EXT_FRAMEBUFFER_OBJECT,         NULL) \
+    USE_GL_FUNC(PGLFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC, \
+            glGetFramebufferAttachmentParameterivEXT,   EXT_FRAMEBUFFER_OBJECT,         NULL) \
+    /* GL_EXT_gpu_program_parameters */ \
+    USE_GL_FUNC(PGLFNPROGRAMENVPARAMETERS4FVEXTPROC, \
+            glProgramEnvParameters4fvEXT,               EXT_GPU_PROGRAM_PARAMETERS,     NULL) \
+    USE_GL_FUNC(PGLFNPROGRAMLOCALPARAMETERS4FVEXTPROC, \
+            glProgramLocalParameters4fvEXT,             EXT_GPU_PROGRAM_PARAMETERS,     NULL) \
+    /* GL_EXT_gpu_shader4 */\
+    USE_GL_FUNC(PGLFNVERTEXATTRIBI1IEXTPROC, \
+            glVertexAttribI1iEXT,                       EXT_GPU_SHADER4,                NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIBI2IEXTPROC, \
+            glVertexAttribI2iEXT,                       EXT_GPU_SHADER4,                NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIBI3IEXTPROC, \
+            glVertexAttribI3iEXT,                       EXT_GPU_SHADER4,                NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIBI4IEXTPROC, \
+            glVertexAttribI4iEXT,                       EXT_GPU_SHADER4,                NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIBI1UIEXTPROC, \
+            glVertexAttribI1uiEXT,                      EXT_GPU_SHADER4,                NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIBI2UIEXTPROC, \
+            glVertexAttribI2uiEXT,                      EXT_GPU_SHADER4,                NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIBI3UIEXTPROC, \
+            glVertexAttribI3uiEXT,                      EXT_GPU_SHADER4,                NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIBI4UIEXTPROC, \
+            glVertexAttribI4uiEXT,                      EXT_GPU_SHADER4,                NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIBI1IVEXTPROC, \
+            glVertexAttribI1ivEXT,                      EXT_GPU_SHADER4,                NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIBI2IVEXTPROC, \
+            glVertexAttribI2ivEXT,                      EXT_GPU_SHADER4,                NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIBI3IVEXTPROC, \
+            glVertexAttribI3ivEXT,                      EXT_GPU_SHADER4,                NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIBI4IVEXTPROC, \
+            glVertexAttribI4ivEXT,                      EXT_GPU_SHADER4,                NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIBI1UIVEXTPROC, \
+            glVertexAttribI1uivEXT,                     EXT_GPU_SHADER4,                NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIBI2UIVEXTPROC, \
+            glVertexAttribI2uivEXT,                     EXT_GPU_SHADER4,                NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIBI3UIVEXTPROC, \
+            glVertexAttribI3uivEXT,                     EXT_GPU_SHADER4,                NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIBI4UIVEXTPROC, \
+            glVertexAttribI4uivEXT,                     EXT_GPU_SHADER4,                NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIBI4BVEXTPROC, \
+            glVertexAttribI4bvEXT,                      EXT_GPU_SHADER4,                NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIBI4SVEXTPROC, \
+            glVertexAttribI4svEXT,                      EXT_GPU_SHADER4,                NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIBI4UBVEXTPROC, \
+            glVertexAttribI4ubvEXT,                     EXT_GPU_SHADER4,                NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIBI4USVEXTPROC, \
+            glVertexAttribI4usvEXT,                     EXT_GPU_SHADER4,                NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIBIPOINTEREXTPROC, \
+            glVertexAttribIPointerEXT,                  EXT_GPU_SHADER4,                NULL) \
+    USE_GL_FUNC(PGLFNGETVERTEXATTRIBIIVEXTPROC, \
+            glVertexAttribIivEXT,                       EXT_GPU_SHADER4,                NULL) \
+    USE_GL_FUNC(PGLFNGETVERTEXATTRIBIUIVEXTPROC, \
+            glVertexAttribIuivEXT,                      EXT_GPU_SHADER4,                NULL) \
+    USE_GL_FUNC(PGLFNUNIFORM1UIEXTPROC, \
+            glUniform1uiEXT,                            EXT_GPU_SHADER4,                NULL) \
+    USE_GL_FUNC(PGLFNUNIFORM2UIEXTPROC, \
+            glUniform2uiEXT,                            EXT_GPU_SHADER4,                NULL) \
+    USE_GL_FUNC(PGLFNUNIFORM3UIEXTPROC, \
+            glUniform3uiEXT,                            EXT_GPU_SHADER4,                NULL) \
+    USE_GL_FUNC(PGLFNUNIFORM4UIEXTPROC, \
+            glUniform4uiEXT,                            EXT_GPU_SHADER4,                NULL) \
+    USE_GL_FUNC(PGLFNUNIFORM1UIVEXTPROC, \
+            glUniform1uivEXT,                           EXT_GPU_SHADER4,                NULL) \
+    USE_GL_FUNC(PGLFNUNIFORM2UIVEXTPROC, \
+            glUniform2uivEXT,                           EXT_GPU_SHADER4,                NULL) \
+    USE_GL_FUNC(PGLFNUNIFORM3UIVEXTPROC, \
+            glUniform3uivEXT,                           EXT_GPU_SHADER4,                NULL) \
+    USE_GL_FUNC(PGLFNUNIFORM4UIVEXTPROC, \
+            glUniform4uivEXT,                           EXT_GPU_SHADER4,                NULL) \
+    USE_GL_FUNC(PGLFNGETUNIFORMUIVEXTPROC, \
+            glGetUniformuivEXT,                         EXT_GPU_SHADER4,                NULL) \
+    USE_GL_FUNC(PGLFNBINDFRAGDATALOCATIONEXTPROC, \
+            glBindFragDataLocationEXT,                  EXT_GPU_SHADER4,                NULL) \
+    USE_GL_FUNC(PGLFNGETFRAGDATALOCATIONEXTPROC, \
+            glGetFragDataLocationEXT,                   EXT_GPU_SHADER4,                NULL) \
+    /* GL_EXT_paletted_texture */ \
+    USE_GL_FUNC(PGLFNGLCOLORTABLEEXTPROC, \
+            glColorTableEXT,                            EXT_PALETTED_TEXTURE,           NULL) \
+    /* GL_EXT_point_parameters */ \
+    USE_GL_FUNC(PGLFNGLPOINTPARAMETERFEXTPROC, \
+            glPointParameterfEXT,                       EXT_POINT_PARAMETERS,           NULL) \
+    USE_GL_FUNC(PGLFNGLPOINTPARAMETERFVEXTPROC, \
+            glPointParameterfvEXT,                      EXT_POINT_PARAMETERS,           NULL) \
+    /* GL_EXT_provoking_vertex */ \
+    USE_GL_FUNC(PGLFNGLPROVOKINGVERTEXEXTPROC, \
+            glProvokingVertexEXT,                       EXT_PROVOKING_VERTEX,           NULL) \
+    /* GL_EXT_secondary_color */ \
+    USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3UBEXTPROC, \
+            glSecondaryColor3ubEXT,                     EXT_SECONDARY_COLOR,            NULL) \
+    USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3UBVEXTPROC, \
+            glSecondaryColor3ubvEXT,                    EXT_SECONDARY_COLOR,            NULL) \
+    USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3FEXTPROC, \
+            glSecondaryColor3fEXT,                      EXT_SECONDARY_COLOR,            NULL) \
+    USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3FVEXTPROC, \
+            glSecondaryColor3fvEXT,                     EXT_SECONDARY_COLOR,            NULL) \
+    USE_GL_FUNC(PGLFNGLSECONDARYCOLORPOINTEREXTPROC, \
+            glSecondaryColorPointerEXT,                 EXT_SECONDARY_COLOR,            NULL) \
+    /* GL_EXT_stencil_two_side */ \
+    USE_GL_FUNC(PGLFNACTIVESTENCILFACEEXTPROC, \
+            glActiveStencilFaceEXT,                     EXT_STENCIL_TWO_SIDE,           NULL) \
+    /* GL_EXT_texture3D */ \
+    USE_GL_FUNC(PGLFNGLTEXIMAGE3DEXTPROC, \
+            glTexImage3DEXT,                            EXT_TEXTURE3D,                  glTexImage3D) \
+    USE_GL_FUNC(PGLFNGLTEXSUBIMAGE3DEXTPROC, \
+            glTexSubImage3DEXT,                         EXT_TEXTURE3D,                  glTexSubImage3D) \
+    /* GL_NV_fence */ \
+    USE_GL_FUNC(PGLFNGENFENCESNVPROC, \
+            glGenFencesNV,                              NV_FENCE,                       NULL) \
+    USE_GL_FUNC(PGLFNDELETEFENCESNVPROC, \
+            glDeleteFencesNV,                           NV_FENCE,                       NULL) \
+    USE_GL_FUNC(PGLFNSETFENCENVPROC,    \
+            glSetFenceNV,                               NV_FENCE,                       NULL) \
+    USE_GL_FUNC(PGLFNTESTFENCENVPROC, \
+            glTestFenceNV,                              NV_FENCE,                       NULL) \
+    USE_GL_FUNC(PGLFNFINISHFENCENVPROC, \
+            glFinishFenceNV,                            NV_FENCE,                       NULL) \
+    USE_GL_FUNC(PGLFNISFENCENVPROC, \
+            glIsFenceNV,                                NV_FENCE,                       NULL) \
+    USE_GL_FUNC(PGLFNGETFENCEIVNVPROC, \
+            glGetFenceivNV,                             NV_FENCE,                       NULL) \
+    /* GL_NV_half_float */ \
+    USE_GL_FUNC(PGLFNVERTEX2HNVPROC, \
+            glVertex2hNV,                               NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNVERTEX2HVNVPROC, \
+            glVertex2hvNV,                              NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNVERTEX3HNVPROC, \
+            glVertex3hNV,                               NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNVERTEX3HVNVPROC, \
+            glVertex3hvNV,                              NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNVERTEX4HNVPROC, \
+            glVertex4hNV,                               NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNVERTEX4HVNVPROC, \
+            glVertex4hvNV,                              NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNNORMAL3HNVPROC, \
+            glNormal3hNV,                               NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNNORMAL3HVNVPROC, \
+            glNormal3hvNV,                              NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNCOLOR3HNVPROC, \
+            glColor3hNV,                                NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNCOLOR3HVNVPROC, \
+            glColor3hvNV,                               NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNCOLOR4HNVPROC, \
+            glColor4hNV,                                NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNCOLOR4HVNVPROC, \
+            glColor4hvNV,                               NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNTEXCOORD1HNVPROC, \
+            glTexCoord1hNV,                             NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNTEXCOORD1HVNVPROC, \
+            glTexCoord1hvNV,                            NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNTEXCOORD2HNVPROC, \
+            glTexCoord2hNV,                             NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNTEXCOORD2HVNVPROC, \
+            glTexCoord2hvNV,                            NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNTEXCOORD3HNVPROC, \
+            glTexCoord3hNV,                             NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNTEXCOORD3HVNVPROC, \
+            glTexCoord3hvNV,                            NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNTEXCOORD4HNVPROC, \
+            glTexCoord4hNV,                             NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNTEXCOORD4HVNVPROC, \
+            glTexCoord4hvNV,                            NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNMULTITEXCOORD1HNVPROC, \
+            glMultiTexCoord1hNV,                        NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNMULTITEXCOORD1HVNVPROC, \
+            glMultiTexCoord1hvNV,                       NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNMULTITEXCOORD2HNVPROC, \
+            glMultiTexCoord2hNV,                        NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNMULTITEXCOORD2HVNVPROC, \
+            glMultiTexCoord2hvNV,                       NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNMULTITEXCOORD3HNVPROC, \
+            glMultiTexCoord3hNV,                        NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNMULTITEXCOORD3HVNVPROC, \
+            glMultiTexCoord3hvNV,                       NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNMULTITEXCOORD4HNVPROC, \
+            glMultiTexCoord4hNV,                        NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNMULTITEXCOORD4HVNVPROC, \
+            glMultiTexCoord4hvNV,                       NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNFOGCOORDHNVPROC, \
+            glFogCoordhNV,                              NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNFOGCOORDHVNVPROC, \
+            glFogCoordhvNV,                             NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNSECONDARYCOLOR3HNVPROC, \
+            glSecondaryColor3hNV,                       NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNSECONDARYCOLOR3HVNVPROC, \
+            glSecondaryColor3hvNV,                      NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNVERTEXWEIGHTHNVPROC, \
+            glVertexWeighthNV,                          NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNVERTEXWEIGHTHVNVPROC, \
+            glVertexWeighthvNV,                         NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB1HNVPROC, \
+            glVertexAttrib1hNV,                         NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB1HVNVPROC, \
+            glVertexAttrib1hvNV,                        NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB2HNVPROC, \
+            glVertexAttrib2hNV,                         NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB2HVNVPROC, \
+            glVertexAttrib2hvNV,                        NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB3HNVPROC, \
+            glVertexAttrib3hNV,                         NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB3HVNVPROC, \
+            glVertexAttrib3hvNV,                        NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4HNVPROC, \
+            glVertexAttrib4hNV,                         NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4HVNVPROC, \
+            glVertexAttrib4hvNV,                        NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIBS1HVNVPROC, \
+            glVertexAttribs1hvNV,                       NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIBS2HVNVPROC, \
+            glVertexAttribs2hvNV,                       NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIBS3HVNVPROC, \
+            glVertexAttribs3hvNV,                       NV_HALF_FLOAT,                  NULL) \
+    USE_GL_FUNC(PGLFNVERTEXATTRIBS4HVNVPROC, \
+            glVertexAttribs4hvNV,                       NV_HALF_FLOAT,                  NULL) \
+    /* GL_NV_register_combiners */ \
+    USE_GL_FUNC(PGLFNCOMBINERINPUTNVPROC, \
+            glCombinerInputNV,                          NV_REGISTER_COMBINERS,          NULL) \
+    USE_GL_FUNC(PGLFNCOMBINEROUTPUTNVPROC, \
+            glCombinerOutputNV,                         NV_REGISTER_COMBINERS,          NULL) \
+    USE_GL_FUNC(PGLFNCOMBINERPARAMETERFNVPROC, \
+            glCombinerParameterfNV,                     NV_REGISTER_COMBINERS,          NULL) \
+    USE_GL_FUNC(PGLFNCOMBINERPARAMETERFVNVPROC, \
+            glCombinerParameterfvNV,                    NV_REGISTER_COMBINERS,          NULL) \
+    USE_GL_FUNC(PGLFNCOMBINERPARAMETERINVPROC, \
+            glCombinerParameteriNV,                     NV_REGISTER_COMBINERS,          NULL) \
+    USE_GL_FUNC(PGLFNCOMBINERPARAMETERIVNVPROC, \
+            glCombinerParameterivNV,                    NV_REGISTER_COMBINERS,          NULL) \
+    USE_GL_FUNC(PGLFNFINALCOMBINERINPUTNVPROC, \
+            glFinalCombinerInputNV,                     NV_REGISTER_COMBINERS,          NULL) \
+    /* GLX_SGI_video_sync */ \
+    USE_GL_FUNC(PGLXFNGETVIDEOSYNCSGIPROC, \
+            glXGetVideoSyncSGI,                         SGI_VIDEO_SYNC,                 NULL) \
+    USE_GL_FUNC(PGLXFNWAITVIDEOSYNCSGIPROC, \
+            glXWaitVideoSyncSGI,                        SGI_VIDEO_SYNC,                 NULL)
 
 #define WGL_EXT_FUNCS_GEN \
-    USE_GL_FUNC(WINED3D_PFNWGLGETEXTENSIONSSTRINGARBPROC, wglGetExtensionsStringARB, 0, NULL) \
-    USE_GL_FUNC(WINED3D_PFNWGLGETPIXELFORMATATTRIBIVARBPROC, wglGetPixelFormatAttribivARB, 0, NULL) \
-    USE_GL_FUNC(WINED3D_PFNWGLGETPIXELFORMATATTRIBFVARBPROC, wglGetPixelFormatAttribfvARB, 0, NULL) \
-    USE_GL_FUNC(WINED3D_PFNWGLCHOOSEPIXELFORMATARBPROC, wglChoosePixelFormatARB, 0, NULL) \
-    USE_GL_FUNC(WINED3D_PFNWGLMAKECONTEXTCURRENTARBPROC, wglMakeContextCurrentARB, 0, NULL) \
-    USE_GL_FUNC(WINED3D_PFNWGLGETCURRENTREADDCARBPROC, wglGetCurrentReadDCARB, 0, NULL) \
-    USE_GL_FUNC(WINED3D_PFNWGLCREATEPBUFFERARBPROC, wglCreatePbufferARB, 0, NULL) \
-    USE_GL_FUNC(WINED3D_PFNWGLGETPBUFFERDCARBPROC, wglGetPbufferDCARB, 0, NULL) \
-    USE_GL_FUNC(WINED3D_PFNWGLRELEASEPBUFFERDCARBPROC, wglReleasePbufferDCARB, 0, NULL) \
-    USE_GL_FUNC(WINED3D_PFNWGLDESTROYPBUFFERARBPROC, wglDestroyPbufferARB, 0, NULL) \
-    USE_GL_FUNC(WINED3D_PFNWGLQUERYPBUFFERARBPROC, wglQueryPbufferARB, 0, NULL) \
-    USE_GL_FUNC(WINED3D_PFNWGLSETPIXELFORMATWINE, wglSetPixelFormatWINE, 0, NULL)
-
-
-/****************************************************
- * Structures
- ****************************************************/
-
-struct wined3d_fbo_ops
-{
-    PGLFNGLISRENDERBUFFERPROC                       glIsRenderbuffer;
-    PGLFNGLBINDRENDERBUFFERPROC                     glBindRenderbuffer;
-    PGLFNGLDELETERENDERBUFFERSPROC                  glDeleteRenderbuffers;
-    PGLFNGLGENRENDERBUFFERSPROC                     glGenRenderbuffers;
-    PGLFNGLRENDERBUFFERSTORAGEPROC                  glRenderbufferStorage;
-    PGLFNRENDERBUFFERSTORAGEMULTISAMPLEPROC         glRenderbufferStorageMultisample;
-    PGLFNGLGETRENDERBUFFERPARAMETERIVPROC           glGetRenderbufferParameteriv;
-    PGLFNGLISFRAMEBUFFERPROC                        glIsFramebuffer;
-    PGLFNGLBINDFRAMEBUFFERPROC                      glBindFramebuffer;
-    PGLFNGLDELETEFRAMEBUFFERSPROC                   glDeleteFramebuffers;
-    PGLFNGLGENFRAMEBUFFERSPROC                      glGenFramebuffers;
-    PGLFNGLCHECKFRAMEBUFFERSTATUSPROC               glCheckFramebufferStatus;
-    PGLFNGLFRAMEBUFFERTEXTURE1DPROC                 glFramebufferTexture1D;
-    PGLFNGLFRAMEBUFFERTEXTURE2DPROC                 glFramebufferTexture2D;
-    PGLFNGLFRAMEBUFFERTEXTURE3DPROC                 glFramebufferTexture3D;
-    PGLFNGLFRAMEBUFFERRENDERBUFFERPROC              glFramebufferRenderbuffer;
-    PGLFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC  glGetFramebufferAttachmentParameteriv;
-    PGLFNGLBLITFRAMEBUFFERPROC                      glBlitFramebuffer;
-    PGLFNGLGENERATEMIPMAPPROC                       glGenerateMipmap;
-};
-
-struct wined3d_gl_limits
-{
-    UINT buffers;
-    UINT lights;
-    UINT textures;
-    UINT texture_stages;
-    UINT fragment_samplers;
-    UINT vertex_samplers;
-    UINT combined_samplers;
-    UINT sampler_stages;
-    UINT clipplanes;
-    UINT texture_size;
-    UINT texture3d_size;
-    float pointsize_max;
-    float pointsize_min;
-    UINT point_sprite_units;
-    UINT blends;
-    UINT anisotropy;
-    float shininess;
-
-    UINT glsl_varyings;
-    UINT glsl_vs_float_constants;
-    UINT glsl_ps_float_constants;
-
-    UINT arb_vs_float_constants;
-    UINT arb_vs_native_constants;
-    UINT arb_vs_instructions;
-    UINT arb_vs_temps;
-    UINT arb_ps_float_constants;
-    UINT arb_ps_local_constants;
-    UINT arb_ps_native_constants;
-    UINT arb_ps_instructions;
-    UINT arb_ps_temps;
-};
-
-#define USE_GL_FUNC(type, pfn, ext, replace) type pfn;
-
-struct wined3d_gl_info
-{
-    UINT vidmem;
-    struct wined3d_gl_limits limits;
-    DWORD reserved_glsl_constants;
-    DWORD quirks;
-    BOOL supported[WINED3D_GL_EXT_COUNT];
-    GLint wrap_lookup[WINED3DTADDRESS_MIRRORONCE - WINED3DTADDRESS_WRAP + 1];
-
-    struct wined3d_fbo_ops fbo_ops;
-    /* GL function pointers */
-    GL_EXT_FUNCS_GEN
-    /* WGL function pointers */
-    WGL_EXT_FUNCS_GEN
-
-    struct GlPixelFormatDesc *gl_formats;
-};
-
-#undef USE_GL_FUNC
+    USE_GL_FUNC(WINED3D_PFNWGLGETEXTENSIONSSTRINGARBPROC,       wglGetExtensionsStringARB,      0, NULL) \
+    USE_GL_FUNC(WINED3D_PFNWGLGETPIXELFORMATATTRIBIVARBPROC,    wglGetPixelFormatAttribivARB,   0, NULL) \
+    USE_GL_FUNC(WINED3D_PFNWGLGETPIXELFORMATATTRIBFVARBPROC,    wglGetPixelFormatAttribfvARB,   0, NULL) \
+    USE_GL_FUNC(WINED3D_PFNWGLCHOOSEPIXELFORMATARBPROC,         wglChoosePixelFormatARB,        0, NULL) \
+    USE_GL_FUNC(WINED3D_PFNWGLSETPIXELFORMATWINE,               wglSetPixelFormatWINE,          0, NULL)
 
 #endif /* __WINE_WINED3D_GL */
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/wined3d_main.c
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/wined3d_main.c	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/wined3d_main.c	(revision 28475)
@@ -82,28 +82,29 @@
     0,              /* The default of memory is set in FillGLCaps */
     NULL,           /* No wine logo by default */
-    FALSE           /* Disable multisampling for now due to Nvidia driver bugs which happens for some users */
+    FALSE,          /* Disable multisampling for now due to Nvidia driver bugs which happens for some users */
+    FALSE,          /* No strict draw ordering. */
 };
 
-IWineD3D* WINAPI WineDirect3DCreate(UINT dxVersion, IUnknown *parent) {
-    IWineD3DImpl* object;
-
-    object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IWineD3DImpl));
-    object->lpVtbl = &IWineD3D_Vtbl;
-    object->dxVersion = dxVersion;
-    object->ref = 1;
-    object->parent = parent;
-
-    if (!InitAdapters(object))
-    {
-        WARN("Failed to initialize direct3d adapters, Direct3D will not be available\n");
-        if (dxVersion > 7)
-        {
-            ERR("Direct3D%d is not available without opengl\n", dxVersion);
-            HeapFree(GetProcessHeap(), 0, object);
-            return NULL;
-        }
-    }
-
-    TRACE("Created WineD3D object @ %p for d3d%d support\n", object, dxVersion);
+IWineD3D * WINAPI WineDirect3DCreate(UINT version, IUnknown *parent)
+{
+    IWineD3DImpl *object;
+    HRESULT hr;
+
+    object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+    if (!object)
+    {
+        ERR("Failed to allocate wined3d object memory.\n");
+        return NULL;
+    }
+
+    hr = wined3d_init(object, version, parent);
+    if (FAILED(hr))
+    {
+        WARN("Failed to initialize wined3d object, hr %#x.\n", hr);
+        HeapFree(GetProcessHeap(), 0, object);
+        return NULL;
+    }
+
+    TRACE("Created wined3d object %p for d3d%d support.\n", object, version);
 
     return (IWineD3D *)object;
@@ -130,5 +131,5 @@
 }
 
-static BOOL wined3d_init(HINSTANCE hInstDLL)
+static BOOL wined3d_dll_init(HINSTANCE hInstDLL)
 {
     DWORD wined3d_context_tls_idx;
@@ -246,9 +247,4 @@
                 wined3d_settings.offscreen_rendering_mode = ORM_BACKBUFFER;
             }
-            else if (!strcmp(buffer,"pbuffer"))
-            {
-                TRACE("Using PBuffers for offscreen rendering\n");
-                wined3d_settings.offscreen_rendering_mode = ORM_PBUFFER;
-            }
             else if (!strcmp(buffer,"fbo"))
             {
@@ -333,4 +329,10 @@
                 wined3d_settings.allow_multisampling = TRUE;
             }
+        }
+        if (!get_config_key(hkey, appkey, "StrictDrawOrdering", buffer, size)
+                && !strcmp(buffer,"enabled"))
+        {
+            TRACE("Enforcing strict draw ordering.\n");
+            wined3d_settings.strict_draw_ordering = TRUE;
         }
     }
@@ -348,5 +350,5 @@
 }
 
-static BOOL wined3d_destroy(HINSTANCE hInstDLL)
+static BOOL wined3d_dll_destroy(HINSTANCE hInstDLL)
 {
     DWORD wined3d_context_tls_idx = context_get_tls_idx();
@@ -488,8 +490,8 @@
     {
         case DLL_PROCESS_ATTACH:
-            return wined3d_init(hInstDLL);
+            return wined3d_dll_init(hInstDLL);
 
         case DLL_PROCESS_DETACH:
-            return wined3d_destroy(hInstDLL);
+            return wined3d_dll_destroy(hInstDLL);
 
         case DLL_THREAD_DETACH:
Index: trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/wined3d_private.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/wined3d_private.h	(revision 28382)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/wined3d_private.h	(revision 28475)
@@ -60,4 +60,5 @@
 #define WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA     0x00000008
 #define WINED3D_QUIRK_NV_CLIP_BROKEN            0x00000010
+#define WINED3D_QUIRK_FBO_TEX_UPDATE            0x00000020
 
 /* Texture format fixups */
@@ -71,13 +72,15 @@
     CHANNEL_SOURCE_Z = 4,
     CHANNEL_SOURCE_W = 5,
-    CHANNEL_SOURCE_YUV0 = 6,
-    CHANNEL_SOURCE_YUV1 = 7,
-};
-
-enum yuv_fixup
-{
-    YUV_FIXUP_YUY2 = 0,
-    YUV_FIXUP_UYVY = 1,
-    YUV_FIXUP_YV12 = 2,
+    CHANNEL_SOURCE_COMPLEX0 = 6,
+    CHANNEL_SOURCE_COMPLEX1 = 7,
+};
+
+enum complex_fixup
+{
+    COMPLEX_FIXUP_NONE = 0,
+    COMPLEX_FIXUP_YUY2 = 1,
+    COMPLEX_FIXUP_UYVY = 2,
+    COMPLEX_FIXUP_YV12 = 3,
+    COMPLEX_FIXUP_P8   = 4,
 };
 
@@ -113,12 +116,12 @@
 }
 
-static inline struct color_fixup_desc create_yuv_fixup_desc(enum yuv_fixup yuv_fixup)
+static inline struct color_fixup_desc create_complex_fixup_desc(enum complex_fixup complex_fixup)
 {
     struct color_fixup_desc fixup =
     {
-        0, yuv_fixup & (1 << 0) ? CHANNEL_SOURCE_YUV1 : CHANNEL_SOURCE_YUV0,
-        0, yuv_fixup & (1 << 1) ? CHANNEL_SOURCE_YUV1 : CHANNEL_SOURCE_YUV0,
-        0, yuv_fixup & (1 << 2) ? CHANNEL_SOURCE_YUV1 : CHANNEL_SOURCE_YUV0,
-        0, yuv_fixup & (1 << 3) ? CHANNEL_SOURCE_YUV1 : CHANNEL_SOURCE_YUV0,
+        0, complex_fixup & (1 << 0) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0,
+        0, complex_fixup & (1 << 1) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0,
+        0, complex_fixup & (1 << 2) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0,
+        0, complex_fixup & (1 << 3) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0,
     };
     return fixup;
@@ -130,17 +133,17 @@
 }
 
-static inline BOOL is_yuv_fixup(struct color_fixup_desc fixup)
-{
-    return fixup.x_source == CHANNEL_SOURCE_YUV0 || fixup.x_source == CHANNEL_SOURCE_YUV1;
+static inline BOOL is_complex_fixup(struct color_fixup_desc fixup)
+{
+    return fixup.x_source == CHANNEL_SOURCE_COMPLEX0 || fixup.x_source == CHANNEL_SOURCE_COMPLEX1;
 }
 
-static inline enum yuv_fixup get_yuv_fixup(struct color_fixup_desc fixup)
-{
-    enum yuv_fixup yuv_fixup = 0;
-    if (fixup.x_source == CHANNEL_SOURCE_YUV1) yuv_fixup |= (1 << 0);
-    if (fixup.y_source == CHANNEL_SOURCE_YUV1) yuv_fixup |= (1 << 1);
-    if (fixup.z_source == CHANNEL_SOURCE_YUV1) yuv_fixup |= (1 << 2);
-    if (fixup.w_source == CHANNEL_SOURCE_YUV1) yuv_fixup |= (1 << 3);
-    return yuv_fixup;
+static inline enum complex_fixup get_complex_fixup(struct color_fixup_desc fixup)
+{
+    enum complex_fixup complex_fixup = 0;
+    if (fixup.x_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1 << 0);
+    if (fixup.y_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1 << 1);
+    if (fixup.z_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1 << 2);
+    if (fixup.w_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1 << 3);
+    return complex_fixup;
 }
 
@@ -250,6 +253,5 @@
 
 #define ORM_BACKBUFFER  0
-#define ORM_PBUFFER     1
-#define ORM_FBO         2
+#define ORM_FBO         1
 
 #define SHADER_ARB  1
@@ -283,4 +285,5 @@
   char *logo;
   int allow_multisampling;
+  BOOL strict_draw_ordering;
 } wined3d_settings_t;
 
@@ -566,4 +569,5 @@
 {
     IWineD3DBaseShader *shader;
+    const struct wined3d_gl_info *gl_info;
     const struct shader_reg_maps *reg_maps;
     struct wined3d_shader_buffer *buffer;
@@ -641,5 +645,5 @@
             struct wined3d_shader_src_param *dst_rel_addr);
     void (*shader_read_semantic)(const DWORD **ptr, struct wined3d_shader_semantic *semantic);
-    void (*shader_read_comment)(const DWORD **ptr, const char **comment);
+    void (*shader_read_comment)(const DWORD **ptr, const char **comment, UINT *comment_size);
     BOOL (*shader_is_end)(void *data, const DWORD **ptr);
 };
@@ -736,5 +740,5 @@
     void (*shader_free_private)(IWineD3DDevice *iface);
     BOOL (*shader_dirtifyable_constants)(IWineD3DDevice *iface);
-    void (*shader_get_caps)(WINED3DDEVTYPE devtype, const struct wined3d_gl_info *gl_info, struct shader_caps *caps);
+    void (*shader_get_caps)(const struct wined3d_gl_info *gl_info, struct shader_caps *caps);
     BOOL (*shader_color_fixup_supported)(struct color_fixup_desc fixup);
     void (*shader_add_instruction_modifiers)(const struct wined3d_shader_instruction *ins);
@@ -803,5 +807,5 @@
                                                                     \
     } else do {                                                     \
-        FIXME(">>>>>>>>>>>>>>>>> %s (%#x) from %s @ %s / %d\n",     \
+        ERR(">>>>>>>>>>>>>>>>> %s (%#x) from %s @ %s / %d\n",       \
             debug_glerror(err), err, A, __FILE__, __LINE__);        \
        err = glGetError();                                          \
@@ -844,11 +848,4 @@
  * Compilable extra diagnostics
  */
-
-/* Trace information per-vertex: (extremely high amount of trace) */
-#if 0 /* NOTE: Must be 0 in cvs */
-# define VTRACE(A) TRACE A
-#else
-# define VTRACE(A)
-#endif
 
 /* TODO: Confirm each of these works when wined3d move completed */
@@ -925,5 +922,5 @@
 struct wined3d_stream_info_element
 {
-    const struct GlPixelFormatDesc *format_desc;
+    const struct wined3d_format_desc *format_desc;
     GLsizei stride;
     const BYTE *data;
@@ -1010,6 +1007,8 @@
 
 #define STATE_MATERIAL (STATE_CLIPPLANE(MAX_CLIPPLANES))
+#define STATE_IS_MATERIAL(a) ((a) == STATE_MATERIAL)
 
 #define STATE_FRONTFACE (STATE_MATERIAL + 1)
+#define STATE_IS_FRONTFACE(a) ((a) == STATE_FRONTFACE)
 
 #define STATE_HIGHEST (STATE_FRONTFACE)
@@ -1030,10 +1029,31 @@
 };
 
+union wined3d_gl_query_object
+{
+    GLuint id;
+    GLsync sync;
+};
+
 struct wined3d_event_query
 {
     struct list entry;
-    GLuint id;
+    union wined3d_gl_query_object object;
     struct wined3d_context *context;
 };
+
+enum wined3d_event_query_result
+{
+    WINED3D_EVENT_QUERY_OK,
+    WINED3D_EVENT_QUERY_WAITING,
+    WINED3D_EVENT_QUERY_NOT_STARTED,
+    WINED3D_EVENT_QUERY_WRONG_THREAD,
+    WINED3D_EVENT_QUERY_ERROR
+};
+
+void wined3d_event_query_destroy(struct wined3d_event_query *query) DECLSPEC_HIDDEN;
+enum wined3d_event_query_result wined3d_event_query_test(struct wined3d_event_query *query, IWineD3DDeviceImpl *device) DECLSPEC_HIDDEN;
+enum wined3d_event_query_result wined3d_event_query_finish(struct wined3d_event_query *query, IWineD3DDeviceImpl *device) DECLSPEC_HIDDEN;
+void wined3d_event_query_issue(struct wined3d_event_query *query, IWineD3DDeviceImpl *device) DECLSPEC_HIDDEN;
+HRESULT wined3d_event_query_supported(const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
 
 struct wined3d_context
@@ -1050,5 +1070,5 @@
     DWORD isStateDirty[STATE_HIGHEST / (sizeof(DWORD) * CHAR_BIT) + 1]; /* Bitmap to find out quickly if a state is dirty */
 
-    IWineD3DSurface         *surface;
+    IWineD3DSwapChainImpl *swapchain;
     IWineD3DSurface *current_rt;
     DWORD                   tid;    /* Thread ID which owns this context at the moment */
@@ -1087,5 +1107,5 @@
     HWND                    win_handle;
     HDC                     hdc;
-    HPBUFFERARB             pbuffer;
+    int pixel_format;
     GLint                   aux_buffers;
 
@@ -1099,4 +1119,5 @@
     GLuint                  fbo_read_binding;
     GLuint                  fbo_draw_binding;
+    BOOL rebind_fbo;
 
     /* Queries */
@@ -1106,5 +1127,5 @@
     struct list occlusion_queries;
 
-    GLuint *free_event_queries;
+    union wined3d_gl_query_object *free_event_queries;
     UINT free_event_query_size;
     UINT free_event_query_count;
@@ -1144,5 +1165,5 @@
 {
     void (*enable_extension)(IWineD3DDevice *iface, BOOL enable);
-    void (*get_caps)(WINED3DDEVTYPE devtype, const struct wined3d_gl_info *gl_info, struct fragment_caps *caps);
+    void (*get_caps)(const struct wined3d_gl_info *gl_info, struct fragment_caps *caps);
     HRESULT (*alloc_private)(IWineD3DDevice *iface);
     void (*free_private)(IWineD3DDevice *iface);
@@ -1165,4 +1186,10 @@
         const struct fragment_pipeline *fragment, const struct StateEntryTemplate *misc) DECLSPEC_HIDDEN;
 
+enum blit_operation
+{
+    BLIT_OP_BLIT,
+    BLIT_OP_COLOR_FILL
+};
+
 /* Shaders for color conversions in blits */
 struct blit_shader
@@ -1170,12 +1197,20 @@
     HRESULT (*alloc_private)(IWineD3DDevice *iface);
     void (*free_private)(IWineD3DDevice *iface);
-    HRESULT (*set_shader)(IWineD3DDevice *iface, const struct GlPixelFormatDesc *format_desc,
-            GLenum textype, UINT width, UINT height);
+    HRESULT (*set_shader)(IWineD3DDevice *iface, IWineD3DSurfaceImpl *surface);
     void (*unset_shader)(IWineD3DDevice *iface);
-    BOOL (*color_fixup_supported)(struct color_fixup_desc fixup);
+    BOOL (*blit_supported)(const struct wined3d_gl_info *gl_info, enum blit_operation blit_op,
+                           const RECT *src_rect, DWORD src_usage, WINED3DPOOL src_pool, const struct wined3d_format_desc *src_format_desc,
+                           const RECT *dst_rect, DWORD dst_usage, WINED3DPOOL dst_pool, const struct wined3d_format_desc *dst_format_desc);
+    HRESULT (*color_fill)(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *dst_surface, const RECT *dst_rect, DWORD fill_color);
 };
 
 extern const struct blit_shader ffp_blit DECLSPEC_HIDDEN;
 extern const struct blit_shader arbfp_blit DECLSPEC_HIDDEN;
+extern const struct blit_shader cpu_blit DECLSPEC_HIDDEN;
+
+/* Temporary blit_shader helper functions */
+HRESULT arbfp_blit_surface(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *src_surface, const RECT *src_rect,
+                           IWineD3DSurfaceImpl *dst_surface, const RECT *dst_rect_in, enum blit_operation blit_op,
+                           DWORD Filter) DECLSPEC_HIDDEN;
 
 typedef enum ContextUsage {
@@ -1196,9 +1231,9 @@
 void context_bind_fbo(struct wined3d_context *context, GLenum target, GLuint *fbo) DECLSPEC_HIDDEN;
 void context_attach_depth_stencil_fbo(struct wined3d_context *context,
-        GLenum fbo_target, IWineD3DSurface *depth_stencil, BOOL use_render_buffer) DECLSPEC_HIDDEN;
+        GLenum fbo_target, IWineD3DSurfaceImpl *depth_stencil, BOOL use_render_buffer) DECLSPEC_HIDDEN;
 void context_attach_surface_fbo(const struct wined3d_context *context,
-        GLenum fbo_target, DWORD idx, IWineD3DSurface *surface) DECLSPEC_HIDDEN;
-struct wined3d_context *context_create(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *target, HWND win,
-        BOOL create_pbuffer, const WINED3DPRESENT_PARAMETERS *present_parameters) DECLSPEC_HIDDEN;
+        GLenum fbo_target, DWORD idx, IWineD3DSurfaceImpl *surface) DECLSPEC_HIDDEN;
+struct wined3d_context *context_create(IWineD3DSwapChainImpl *swapchain, IWineD3DSurfaceImpl *target,
+        const struct wined3d_format_desc *ds_format_desc) DECLSPEC_HIDDEN;
 void context_destroy(IWineD3DDeviceImpl *This, struct wined3d_context *context) DECLSPEC_HIDDEN;
 void context_free_event_query(struct wined3d_event_query *query) DECLSPEC_HIDDEN;
@@ -1210,7 +1245,5 @@
 void context_set_draw_buffer(struct wined3d_context *context, GLenum buffer) DECLSPEC_HIDDEN;
 void context_set_tls_idx(DWORD idx) DECLSPEC_HIDDEN;
-
-void delete_opengl_contexts(IWineD3DDevice *iface, IWineD3DSwapChain *swapchain) DECLSPEC_HIDDEN;
-HRESULT create_primary_opengl_context(IWineD3DDevice *iface, IWineD3DSwapChain *swapchain) DECLSPEC_HIDDEN;
+void context_surface_update(struct wined3d_context *context, IWineD3DSurfaceImpl *surface) DECLSPEC_HIDDEN;
 
 /* Macros for doing basic GPU detection based on opengl capabilities */
@@ -1219,4 +1252,5 @@
 #define WINE_D3D8_CAPABLE(gl_info) WINE_D3D7_CAPABLE(gl_info) && (gl_info->supported[ARB_MULTISAMPLE] && gl_info->supported[ARB_TEXTURE_BORDER_CLAMP])
 #define WINE_D3D9_CAPABLE(gl_info) WINE_D3D8_CAPABLE(gl_info) && (gl_info->supported[ARB_FRAGMENT_PROGRAM] && gl_info->supported[ARB_VERTEX_SHADER])
+#define WINE_D3D10_CAPABLE(gl_info) WINE_D3D9_CAPABLE(gl_info) && (gl_info->supported[EXT_GPU_SHADER4])
 
 /*****************************************************************************
@@ -1246,8 +1280,7 @@
     int iPixelFormat; /* WGL pixel format */
     int iPixelType; /* WGL pixel type e.g. WGL_TYPE_RGBA_ARB, WGL_TYPE_RGBA_FLOAT_ARB or WGL_TYPE_COLORINDEX_ARB */
-    int redSize, greenSize, blueSize, alphaSize;
+    int redSize, greenSize, blueSize, alphaSize, colorSize;
     int depthSize, stencilSize;
     BOOL windowDrawable;
-    BOOL pbufferDrawable;
     BOOL doubleBuffer;
     int auxBuffers;
@@ -1255,11 +1288,21 @@
 } WineD3D_PixelFormat;
 
+enum wined3d_gl_vendor
+{
+    GL_VENDOR_UNKNOWN,
+    GL_VENDOR_APPLE,
+    GL_VENDOR_FGLRX,
+    GL_VENDOR_INTEL,
+    GL_VENDOR_MESA,
+    GL_VENDOR_NVIDIA,
+};
+
+
 enum wined3d_pci_vendor
 {
-    VENDOR_WINE                     = 0x0000,
-    VENDOR_MESA                     = 0x0001,
-    VENDOR_ATI                      = 0x1002,
-    VENDOR_NVIDIA                   = 0x10de,
-    VENDOR_INTEL                    = 0x8086,
+    HW_VENDOR_SOFTWARE                 = 0x0000,
+    HW_VENDOR_ATI                      = 0x1002,
+    HW_VENDOR_NVIDIA                   = 0x10de,
+    HW_VENDOR_INTEL                    = 0x8086,
 };
 
@@ -1275,5 +1318,5 @@
     CARD_ATI_RADEON_X700            = 0x5e4c,
     CARD_ATI_RADEON_X1600           = 0x71c2,
-    CARD_ATI_RADEON_HD2300          = 0x7210,
+    CARD_ATI_RADEON_HD2350          = 0x94c7,
     CARD_ATI_RADEON_HD2600          = 0x9581,
     CARD_ATI_RADEON_HD2900          = 0x9400,
@@ -1345,4 +1388,84 @@
 };
 
+struct wined3d_fbo_ops
+{
+    PGLFNGLISRENDERBUFFERPROC                       glIsRenderbuffer;
+    PGLFNGLBINDRENDERBUFFERPROC                     glBindRenderbuffer;
+    PGLFNGLDELETERENDERBUFFERSPROC                  glDeleteRenderbuffers;
+    PGLFNGLGENRENDERBUFFERSPROC                     glGenRenderbuffers;
+    PGLFNGLRENDERBUFFERSTORAGEPROC                  glRenderbufferStorage;
+    PGLFNRENDERBUFFERSTORAGEMULTISAMPLEPROC         glRenderbufferStorageMultisample;
+    PGLFNGLGETRENDERBUFFERPARAMETERIVPROC           glGetRenderbufferParameteriv;
+    PGLFNGLISFRAMEBUFFERPROC                        glIsFramebuffer;
+    PGLFNGLBINDFRAMEBUFFERPROC                      glBindFramebuffer;
+    PGLFNGLDELETEFRAMEBUFFERSPROC                   glDeleteFramebuffers;
+    PGLFNGLGENFRAMEBUFFERSPROC                      glGenFramebuffers;
+    PGLFNGLCHECKFRAMEBUFFERSTATUSPROC               glCheckFramebufferStatus;
+    PGLFNGLFRAMEBUFFERTEXTURE1DPROC                 glFramebufferTexture1D;
+    PGLFNGLFRAMEBUFFERTEXTURE2DPROC                 glFramebufferTexture2D;
+    PGLFNGLFRAMEBUFFERTEXTURE3DPROC                 glFramebufferTexture3D;
+    PGLFNGLFRAMEBUFFERRENDERBUFFERPROC              glFramebufferRenderbuffer;
+    PGLFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC  glGetFramebufferAttachmentParameteriv;
+    PGLFNGLBLITFRAMEBUFFERPROC                      glBlitFramebuffer;
+    PGLFNGLGENERATEMIPMAPPROC                       glGenerateMipmap;
+};
+
+struct wined3d_gl_limits
+{
+    UINT buffers;
+    UINT lights;
+    UINT textures;
+    UINT texture_stages;
+    UINT fragment_samplers;
+    UINT vertex_samplers;
+    UINT combined_samplers;
+    UINT general_combiners;
+    UINT sampler_stages;
+    UINT clipplanes;
+    UINT texture_size;
+    UINT texture3d_size;
+    float pointsize_max;
+    float pointsize_min;
+    UINT point_sprite_units;
+    UINT blends;
+    UINT anisotropy;
+    float shininess;
+
+    UINT glsl_varyings;
+    UINT glsl_vs_float_constants;
+    UINT glsl_ps_float_constants;
+
+    UINT arb_vs_float_constants;
+    UINT arb_vs_native_constants;
+    UINT arb_vs_instructions;
+    UINT arb_vs_temps;
+    UINT arb_ps_float_constants;
+    UINT arb_ps_local_constants;
+    UINT arb_ps_native_constants;
+    UINT arb_ps_instructions;
+    UINT arb_ps_temps;
+};
+
+struct wined3d_gl_info
+{
+    DWORD glsl_version;
+    UINT vidmem;
+    struct wined3d_gl_limits limits;
+    DWORD reserved_glsl_constants;
+    DWORD quirks;
+    BOOL supported[WINED3D_GL_EXT_COUNT];
+    GLint wrap_lookup[WINED3DTADDRESS_MIRRORONCE - WINED3DTADDRESS_WRAP + 1];
+
+    struct wined3d_fbo_ops fbo_ops;
+#define USE_GL_FUNC(type, pfn, ext, replace) type pfn;
+    /* GL function pointers */
+    GL_EXT_FUNCS_GEN
+    /* WGL function pointers */
+    WGL_EXT_FUNCS_GEN
+#undef USE_GL_FUNC
+
+    struct wined3d_format_desc *gl_formats;
+};
+
 struct wined3d_driver_info
 {
@@ -1370,4 +1493,8 @@
     unsigned int            UsedTextureRam;
     LUID luid;
+
+    const struct fragment_pipeline *fragment_pipe;
+    const shader_backend_t *shader_backend;
+    const struct blit_shader *blitter;
 };
 
@@ -1470,12 +1597,7 @@
 } IWineD3DImpl;
 
-extern const IWineD3DVtbl IWineD3D_Vtbl DECLSPEC_HIDDEN;
-
+HRESULT wined3d_init(IWineD3DImpl *wined3d, UINT version, IUnknown *parent) DECLSPEC_HIDDEN;
 BOOL wined3d_register_window(HWND window, struct IWineD3DDeviceImpl *device) DECLSPEC_HIDDEN;
 void wined3d_unregister_window(HWND window) DECLSPEC_HIDDEN;
-BOOL InitAdapters(IWineD3DImpl *This) DECLSPEC_HIDDEN;
-
-/* A helper function that dumps a resource list */
-void dumpResources(struct list *list) DECLSPEC_HIDDEN;
 
 /*****************************************************************************
@@ -1520,5 +1642,5 @@
     const struct blit_shader *blitter;
 
-    unsigned int max_ffp_textures, max_ffp_texture_stages;
+    unsigned int max_ffp_textures;
     DWORD d3d_vshader_constantF, d3d_pshader_constantF; /* Advertised d3d caps, not GL ones */
     DWORD vs_clipping;
@@ -1570,5 +1692,4 @@
     PALETTEENTRY            **palettes;
     UINT                    currentPalette;
-    UINT                    paletteConversionShader;
 
     /* For rendering to a texture using glCopyTexImage */
@@ -1608,10 +1729,10 @@
     struct wined3d_stream_info strided_streams;
     const WineDirect3DVertexStridedData *up_strided;
+    struct wined3d_event_query *buffer_queries[MAX_ATTRIBS];
+    unsigned int num_buffer_queries;
 
     /* Context management */
     struct wined3d_context **contexts;
     UINT                    numContexts;
-    struct wined3d_context *pbufferContext;              /* The context that has a pbuffer as drawable */
-    DWORD                   pbufferWidth, pbufferHeight; /* Size of the buffer drawable */
 
     /* High level patch management */
@@ -1622,7 +1743,10 @@
 };
 
+BOOL device_context_add(IWineD3DDeviceImpl *device, struct wined3d_context *context) DECLSPEC_HIDDEN;
+void device_context_remove(IWineD3DDeviceImpl *device, struct wined3d_context *context) DECLSPEC_HIDDEN;
 HRESULT device_init(IWineD3DDeviceImpl *device, IWineD3DImpl *wined3d,
         UINT adapter_idx, WINED3DDEVTYPE device_type, HWND focus_window, DWORD flags,
         IUnknown *parent, IWineD3DDeviceParent *device_parent) DECLSPEC_HIDDEN;
+void device_preload_textures(IWineD3DDeviceImpl *device) DECLSPEC_HIDDEN;
 LRESULT device_process_message(IWineD3DDeviceImpl *device, HWND window,
         UINT message, WPARAM wparam, LPARAM lparam, WNDPROC proc) DECLSPEC_HIDDEN;
@@ -1631,6 +1755,5 @@
 void device_stream_info_from_declaration(IWineD3DDeviceImpl *This,
         BOOL use_vshader, struct wined3d_stream_info *stream_info, BOOL *fixup) DECLSPEC_HIDDEN;
-void device_stream_info_from_strided(const struct wined3d_gl_info *gl_info,
-        const struct WineDirect3DVertexStridedData *strided, struct wined3d_stream_info *stream_info) DECLSPEC_HIDDEN;
+void device_update_stream_info(IWineD3DDeviceImpl *device, const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
 HRESULT IWineD3DDeviceImpl_ClearSurface(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *target, DWORD Count,
         const WINED3DRECT *pRects, DWORD Flags, WINED3DCOLOR Color, float Z, DWORD Stencil) DECLSPEC_HIDDEN;
@@ -1677,5 +1800,5 @@
     UINT                    size;
     DWORD                   usage;
-    const struct GlPixelFormatDesc *format_desc;
+    const struct wined3d_format_desc *format_desc;
     DWORD                   priority;
     BYTE                   *allocatedMemory; /* Pointer to the real data location */
@@ -1700,5 +1823,5 @@
         void *data, DWORD *data_size) DECLSPEC_HIDDEN;
 HRESULT resource_init(IWineD3DResource *iface, WINED3DRESOURCETYPE resource_type,
-        IWineD3DDeviceImpl *device, UINT size, DWORD usage, const struct GlPixelFormatDesc *format_desc,
+        IWineD3DDeviceImpl *device, UINT size, DWORD usage, const struct wined3d_format_desc *format_desc,
         WINED3DPOOL pool, IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
 WINED3DRESOURCETYPE resource_get_type(IWineD3DResource *iface) DECLSPEC_HIDDEN;
@@ -1708,5 +1831,5 @@
 
 /* Tests show that the start address of resources is 32 byte aligned */
-#define RESOURCE_ALIGNMENT 32
+#define RESOURCE_ALIGNMENT 16
 
 /*****************************************************************************
@@ -1768,4 +1891,6 @@
 BOOL surface_init_sysmem(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
 BOOL surface_is_offscreen(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
+void surface_prepare_texture(IWineD3DSurfaceImpl *surface,
+        const struct wined3d_gl_info *gl_info, BOOL srgb) DECLSPEC_HIDDEN;
 
 typedef struct IWineD3DBaseTextureImpl
@@ -1790,5 +1915,5 @@
 DWORD basetexture_get_lod(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
 HRESULT basetexture_init(IWineD3DBaseTextureImpl *texture, UINT levels, WINED3DRESOURCETYPE resource_type,
-        IWineD3DDeviceImpl *device, UINT size, DWORD usage, const struct GlPixelFormatDesc *format_desc,
+        IWineD3DDeviceImpl *device, UINT size, DWORD usage, const struct wined3d_format_desc *format_desc,
         WINED3DPOOL pool, IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
 HRESULT basetexture_set_autogen_filter_type(IWineD3DBaseTexture *iface,
@@ -1915,6 +2040,6 @@
 {
     struct list entry;
-    IWineD3DSurface **render_targets;
-    IWineD3DSurface *depth_stencil;
+    IWineD3DSurfaceImpl **render_targets;
+    IWineD3DSurfaceImpl *depth_stencil;
     BOOL attached;
     GLuint id;
@@ -1957,7 +2082,4 @@
     /* A method to retrieve the drawable size. Not in the Vtable to make it changeable */
     void (*get_drawable_size)(struct wined3d_context *context, UINT *width, UINT *height);
-
-    /* Oversized texture */
-    RECT                      glRect;
 
     /* PBO */
@@ -2003,5 +2125,5 @@
 extern const IWineD3DSurfaceVtbl IWineGDISurface_Vtbl DECLSPEC_HIDDEN;
 
-UINT surface_calculate_size(const struct GlPixelFormatDesc *format_desc,
+UINT surface_calculate_size(const struct wined3d_format_desc *format_desc,
         UINT alignment, UINT width, UINT height) DECLSPEC_HIDDEN;
 void surface_gdi_cleanup(IWineD3DSurfaceImpl *This) DECLSPEC_HIDDEN;
@@ -2059,11 +2181,11 @@
 void get_drawable_size_swapchain(struct wined3d_context *context, UINT *width, UINT *height) DECLSPEC_HIDDEN;
 void get_drawable_size_backbuffer(struct wined3d_context *context, UINT *width, UINT *height) DECLSPEC_HIDDEN;
-void get_drawable_size_pbuffer(struct wined3d_context *context, UINT *width, UINT *height) DECLSPEC_HIDDEN;
 void get_drawable_size_fbo(struct wined3d_context *context, UINT *width, UINT *height) DECLSPEC_HIDDEN;
 
+void draw_textured_quad(IWineD3DSurfaceImpl *src_surface, const RECT *src_rect,
+                        const RECT *dst_rect, WINED3DTEXTUREFILTERTYPE Filter) DECLSPEC_HIDDEN;
 void flip_surface(IWineD3DSurfaceImpl *front, IWineD3DSurfaceImpl *back) DECLSPEC_HIDDEN;
 
 /* Surface flags: */
-#define SFLAG_OVERSIZE      0x00000001 /* Surface is bigger than gl size, blts only */
 #define SFLAG_CONVERTED     0x00000002 /* Converted for color keying or Palettized */
 #define SFLAG_DIBSECTION    0x00000004 /* Has a DIB section attached for GetDC */
@@ -2092,5 +2214,4 @@
 
 /* In some conditions the surface memory must not be freed:
- * SFLAG_OVERSIZE: Not all data can be kept in GL
  * SFLAG_CONVERTED: Converting the data back would take too long
  * SFLAG_DIBSECTION: The dib code manages the memory
@@ -2100,6 +2221,5 @@
  * SFLAG_CLIENT: OpenGL uses our memory as backup
  */
-#define SFLAG_DONOTFREE     (SFLAG_OVERSIZE   | \
-                             SFLAG_CONVERTED  | \
+#define SFLAG_DONOTFREE     (SFLAG_CONVERTED  | \
                              SFLAG_DIBSECTION | \
                              SFLAG_LOCKED     | \
@@ -2117,6 +2237,4 @@
                              SFLAG_DS_OFFSCREEN)
 #define SFLAG_DS_DISCARDED   SFLAG_DS_LOCATIONS
-
-BOOL CalculateTexRect(IWineD3DSurfaceImpl *This, RECT *Rect, float glTexCoord[4]) DECLSPEC_HIDDEN;
 
 typedef enum {
@@ -2148,6 +2266,7 @@
 } CONVERT_TYPES;
 
-HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_texturing, GLenum *format,
-        GLenum *internal, GLenum *type, CONVERT_TYPES *convert, int *target_bpp, BOOL srgb_mode) DECLSPEC_HIDDEN;
+HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_texturing,
+                        struct wined3d_format_desc *desc, CONVERT_TYPES *convert) DECLSPEC_HIDDEN;
+void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *This, BYTE table[256][4], BOOL colorkey) DECLSPEC_HIDDEN;
 
 BOOL palette9_changed(IWineD3DSurfaceImpl *This) DECLSPEC_HIDDEN;
@@ -2159,5 +2278,5 @@
 struct wined3d_vertex_declaration_element
 {
-    const struct GlPixelFormatDesc *format_desc;
+    const struct wined3d_format_desc *format_desc;
     BOOL ffp_valid;
     WORD input_slot;
@@ -2338,4 +2457,12 @@
 void stateblock_init_contained_states(IWineD3DStateBlockImpl *object) DECLSPEC_HIDDEN;
 
+static inline void stateblock_apply_state(DWORD state, IWineD3DStateBlockImpl *stateblock,
+        struct wined3d_context *context)
+{
+    const struct StateEntry *statetable = stateblock->device->StateTable;
+    DWORD rep = statetable[state].representative;
+    statetable[rep].apply(rep, stateblock, context);
+}
+
 /* Direct3D terminology with little modifications. We do not have an issued state
  * because only the driver knows about it, but we have a created state because d3d
@@ -2365,7 +2492,6 @@
 } IWineD3DQueryImpl;
 
-extern const IWineD3DQueryVtbl IWineD3DQuery_Vtbl DECLSPEC_HIDDEN;
-extern const IWineD3DQueryVtbl IWineD3DEventQuery_Vtbl DECLSPEC_HIDDEN;
-extern const IWineD3DQueryVtbl IWineD3DOcclusionQuery_Vtbl DECLSPEC_HIDDEN;
+HRESULT query_init(IWineD3DQueryImpl *query, IWineD3DDeviceImpl *device,
+        WINED3DQUERYTYPE type, IUnknown *parent) DECLSPEC_HIDDEN;
 
 /* IWineD3DBuffer */
@@ -2392,4 +2518,7 @@
 #define WINED3D_BUFFER_DOUBLEBUFFER 0x08    /* Use a vbo and local allocated memory */
 #define WINED3D_BUFFER_FLUSH        0x10    /* Manual unmap flushing */
+#define WINED3D_BUFFER_DISCARD      0x20    /* A DISCARD lock has occurred since the last PreLoad */
+#define WINED3D_BUFFER_NOSYNC       0x40    /* All locks since the last PreLoad had NOOVERWRITE set */
+#define WINED3D_BUFFER_APPLESYNC    0x80    /* Using sync as in GL_APPLE_flush_buffer_range */
 
 struct wined3d_buffer
@@ -2410,4 +2539,5 @@
     struct wined3d_map_range *maps;
     ULONG maps_size, modified_areas;
+    struct wined3d_event_query *query;
 
     /* conversion stuff */
@@ -2421,5 +2551,5 @@
 };
 
-const BYTE *buffer_get_memory(IWineD3DBuffer *iface, UINT offset, GLuint *buffer_object) DECLSPEC_HIDDEN;
+const BYTE *buffer_get_memory(IWineD3DBuffer *iface, GLuint *buffer_object) DECLSPEC_HIDDEN;
 BYTE *buffer_get_sysmem(struct wined3d_buffer *This) DECLSPEC_HIDDEN;
 HRESULT buffer_init(struct wined3d_buffer *buffer, IWineD3DDeviceImpl *device,
@@ -2437,5 +2567,6 @@
 };
 
-extern const IWineD3DRendertargetViewVtbl wined3d_rendertarget_view_vtbl DECLSPEC_HIDDEN;
+void wined3d_rendertarget_view_init(struct wined3d_rendertarget_view *view,
+        IWineD3DResource *resource, IUnknown *parent) DECLSPEC_HIDDEN;
 
 /*****************************************************************************
@@ -2460,4 +2591,5 @@
     WINED3DGAMMARAMP          orig_gamma;
     BOOL                      render_to_fbo;
+    const struct wined3d_format_desc *ds_format;
 
     long prev_time, frames;   /* Performance tracking */
@@ -2468,4 +2600,5 @@
 
     HWND                    win_handle;
+    HWND device_window;
 };
 
@@ -2518,4 +2651,5 @@
 const char *debug_d3drenderstate(DWORD state) DECLSPEC_HIDDEN;
 const char *debug_d3dsamplerstate(DWORD state) DECLSPEC_HIDDEN;
+const char *debug_d3dstate(DWORD state) DECLSPEC_HIDDEN;
 const char *debug_d3dtexturefiltertype(WINED3DTEXTUREFILTERTYPE filter_type) DECLSPEC_HIDDEN;
 const char *debug_d3dtexturestate(DWORD state) DECLSPEC_HIDDEN;
@@ -2529,4 +2663,7 @@
 void dump_color_fixup_desc(struct color_fixup_desc fixup) DECLSPEC_HIDDEN;
 const char *debug_surflocation(DWORD flag) DECLSPEC_HIDDEN;
+
+/* Color conversion routines */
+DWORD color_convert_argb_to_fmt(DWORD color, WINED3DFORMAT destfmt) DECLSPEC_HIDDEN;
 
 /* Routines for GL <-> D3D values */
@@ -2565,7 +2702,7 @@
 void surface_set_texture_target(IWineD3DSurface *iface, GLenum target) DECLSPEC_HIDDEN;
 
-BOOL getColorBits(const struct GlPixelFormatDesc *format_desc,
+BOOL getColorBits(const struct wined3d_format_desc *format_desc,
         short *redSize, short *greenSize, short *blueSize, short *alphaSize, short *totalSize) DECLSPEC_HIDDEN;
-BOOL getDepthStencilBits(const struct GlPixelFormatDesc *format_desc,
+BOOL getDepthStencilBits(const struct wined3d_format_desc *format_desc,
         short *depthSize, short *stencilSize) DECLSPEC_HIDDEN;
 
@@ -2575,10 +2712,4 @@
 unsigned int count_bits(unsigned int mask) DECLSPEC_HIDDEN;
 
-const struct blit_shader *select_blit_implementation(struct wined3d_adapter *adapter,
-        WINED3DDEVTYPE device_type) DECLSPEC_HIDDEN;
-const struct fragment_pipeline *select_fragment_implementation(struct wined3d_adapter *adapter,
-        WINED3DDEVTYPE device_type) DECLSPEC_HIDDEN;
-const shader_backend_t *select_shader_backend(struct wined3d_adapter *adapter,
-        WINED3DDEVTYPE device_type) DECLSPEC_HIDDEN;
 void select_shader_mode(const struct wined3d_gl_info *gl_info, int *ps_selected, int *vs_selected) DECLSPEC_HIDDEN;
 
@@ -2624,6 +2755,4 @@
         BYTE usage_req, BYTE usage_idx_req, unsigned int *regnum) DECLSPEC_HIDDEN;
 
-extern HRESULT allocate_shader_constants(IWineD3DStateBlockImpl* object) DECLSPEC_HIDDEN;
-
 /*****************************************************************************
  * IDirect3DBaseShader implementation structure
@@ -2674,5 +2803,4 @@
 BOOL shader_buffer_init(struct wined3d_shader_buffer *buffer) DECLSPEC_HIDDEN;
 void shader_buffer_free(struct wined3d_shader_buffer *buffer) DECLSPEC_HIDDEN;
-void shader_cleanup(IWineD3DBaseShader *iface) DECLSPEC_HIDDEN;
 void shader_dump_src_param(const struct wined3d_shader_src_param *param,
         const struct wined3d_shader_version *shader_version) DECLSPEC_HIDDEN;
@@ -2682,14 +2810,5 @@
 void shader_generate_main(IWineD3DBaseShader *iface, struct wined3d_shader_buffer *buffer,
         const shader_reg_maps *reg_maps, const DWORD *pFunction, void *backend_ctx) DECLSPEC_HIDDEN;
-HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3d_shader_frontend *fe,
-        struct shader_reg_maps *reg_maps, struct wined3d_shader_signature_element *input_signature,
-        struct wined3d_shader_signature_element *output_signature,
-        const DWORD *byte_code, DWORD constf_size) DECLSPEC_HIDDEN;
-void shader_init(struct IWineD3DBaseShaderClass *shader, IWineD3DDeviceImpl *device,
-        IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
 BOOL shader_match_semantic(const char *semantic_name, WINED3DDECLUSAGE usage) DECLSPEC_HIDDEN;
-const struct wined3d_shader_frontend *shader_select_frontend(DWORD version_token) DECLSPEC_HIDDEN;
-void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe_data, const DWORD *pFunction) DECLSPEC_HIDDEN;
-WINED3DDECLUSAGE shader_usage_from_semantic_name(const char *semantic_name) DECLSPEC_HIDDEN;
 
 static inline BOOL shader_is_pshader_version(enum wined3d_shader_type type)
@@ -2865,6 +2984,6 @@
 };
 
-extern const IWineD3DPaletteVtbl IWineD3DPalette_Vtbl DECLSPEC_HIDDEN;
-DWORD IWineD3DPaletteImpl_Size(DWORD dwFlags) DECLSPEC_HIDDEN;
+HRESULT wined3d_palette_init(IWineD3DPaletteImpl *palette, IWineD3DDeviceImpl *device,
+        DWORD flags, const PALETTEENTRY *entries, IUnknown *parent) DECLSPEC_HIDDEN;
 
 /* DirectDraw utility functions */
@@ -2885,6 +3004,7 @@
 #define WINED3DFMT_FLAG_COMPRESSED               0x80
 #define WINED3DFMT_FLAG_GETDC                    0x100
-
-struct GlPixelFormatDesc
+#define WINED3DFMT_FLAG_FLOAT                    0x200
+
+struct wined3d_format_desc
 {
     WINED3DFORMAT format;
@@ -2913,10 +3033,12 @@
     GLint glFormat;
     GLint glType;
+    UINT  conv_byte_count;
     unsigned int Flags;
     float heightscale;
     struct color_fixup_desc color_fixup;
-};
-
-const struct GlPixelFormatDesc *getFormatDescEntry(WINED3DFORMAT fmt,
+    void (*convert)(const BYTE *src, BYTE *dst, UINT pitch, UINT width, UINT height);
+};
+
+const struct wined3d_format_desc *getFormatDescEntry(WINED3DFORMAT fmt,
         const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
 
@@ -2938,6 +3060,6 @@
 
 void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface,
-        WINED3DRECT *src_rect, IWineD3DSurface *dst_surface, WINED3DRECT *dst_rect,
-        const WINED3DTEXTUREFILTERTYPE filter, BOOL flip) DECLSPEC_HIDDEN;
+        const RECT *src_rect, IWineD3DSurface *dst_surface, const RECT *dst_rect,
+        const WINED3DTEXTUREFILTERTYPE filter) DECLSPEC_HIDDEN;
 
 /* The WNDCLASS-Name for the fake window which we use to retrieve the GL capabilities */
@@ -2948,3 +3070,5 @@
         ((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 ))
 
+#define MAKEDWORD_VERSION(maj, min) (((maj & 0xffff) << 16) | (min & 0xffff))
+
 #endif
