Index: /trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp	(revision 30884)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp	(revision 30885)
@@ -1253,11 +1253,15 @@
         {FALSE, D3DTSS_ALPHAARG0},               /* 27, D3DDDITSS_ALPHAARG0 */
         {FALSE, D3DTSS_RESULTARG},               /* 28, D3DDDITSS_RESULTARG */
-        {FALSE, D3DTSS_FORCE_DWORD},             /* 29, D3DDDITSS_SRGBTEXTURE */
-        {FALSE, D3DTSS_FORCE_DWORD},             /* 30, D3DDDITSS_ELEMENTINDEX */
-        {FALSE, D3DTSS_FORCE_DWORD},             /* 31, D3DDDITSS_DMAPOFFSET */
+        {TRUE, D3DSAMP_SRGBTEXTURE},             /* 29, D3DDDITSS_SRGBTEXTURE */
+        {TRUE, D3DSAMP_ELEMENTINDEX},            /* 30, D3DDDITSS_ELEMENTINDEX */
+        {TRUE, D3DSAMP_DMAPOFFSET},              /* 31, D3DDDITSS_DMAPOFFSET */
         {FALSE, D3DTSS_CONSTANT},                /* 32, D3DDDITSS_CONSTANT */
         {FALSE, D3DTSS_FORCE_DWORD},             /* 33, D3DDDITSS_DISABLETEXTURECOLORKEY */
         {FALSE, D3DTSS_FORCE_DWORD},             /* 34, D3DDDITSS_TEXTURECOLORKEYVAL */
     };
+
+    Assert(enmType > 0);
+    Assert(enmType < RT_ELEMENTS(lookup));
+    Assert(lookup[enmType].dType != D3DTSS_FORCE_DWORD);
 
     return lookup[enmType];
@@ -4470,5 +4474,4 @@
     Assert(pRc);
     Assert(pData->SubResourceIndex < pRc->cAllocations);
-    Assert(pRc == pDevice->pRenderTargetRc);
     if (pRc == pDevice->pRenderTargetRc)
     {
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3DCmn.h
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3DCmn.h	(revision 30884)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3DCmn.h	(revision 30885)
@@ -38,4 +38,5 @@
 # define VBOXWDDMDISP_DEBUG
 # define VBOXWDDMDISP_DEBUG_FLOW
+//# define VBOXWDDMDISP_DEBUG_DUMPSURFDATA
 #endif
 
@@ -82,8 +83,12 @@
         vboxVDbgDoMpPrintAlloc _m ; \
     } while (0)
+#ifdef VBOXWDDMDISP_DEBUG_DUMPSURFDATA
 #define vboxVDbgDumpSurfData(_m) \
     do { \
         vboxVDbgDoDumpSurfData _m ; \
     } while (0)
+#else
+#define vboxVDbgDumpSurfData(_m) do {} while (0)
+#endif
 #ifdef VBOXWDDMDISP_DEBUG_FLOW
 # define vboxVDbgPrintF  vboxVDbgPrint
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/glsl_shader.c
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/glsl_shader.c	(revision 30884)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/glsl_shader.c	(revision 30885)
@@ -126,6 +126,21 @@
     struct ps_compile_args      ps_args;
     UINT                        constant_version;
+#ifdef VBOXWDDM
+    UINT                        inp2Fixup_info;
+#else
     const struct ps_np2fixup_info *np2Fixup_info;
+#endif
 };
+
+#ifdef VBOXWDDM
+#define WINEFIXUPINFO_NOINDEX (~0UL)
+#define WINEFIXUPINFO_GET(_p) get_fixup_info((const IWineD3DPixelShaderImpl*)(_p)->pshader, (_p)->inp2Fixup_info)
+#define WINEFIXUPINFO_ISVALID(_p) ((_p)->inp2Fixup_info != WINEFIXUPINFO_NOINDEX)
+#define WINEFIXUPINFO_INIT(_p) ((_p)->inp2Fixup_info == WINEFIXUPINFO_NOINDEX)
+#else
+#define WINEFIXUPINFO_GET(_p) ((_p)->np2Fixup_info)
+#define WINEFIXUPINFO_ISVALID(_p) (!!(_p)->np2Fixup_info)
+#define WINEFIXUPINFO_INIT(_p) ((_p)->np2Fixup_info == NULL)
+#endif
 
 typedef struct {
@@ -673,4 +688,29 @@
 }
 
+#ifdef VBOXWDDM
+static const struct ps_np2fixup_info * get_fixup_info(const IWineD3DPixelShaderImpl *shader, UINT inp2fixup_info)
+{
+    struct glsl_pshader_private    *shader_data = shader->baseShader.backend_data;
+
+    if (inp2fixup_info == WINEFIXUPINFO_NOINDEX)
+        return NULL;
+
+    if (!shader->baseShader.backend_data)
+    {
+        ERR("no backend data\n");
+        return NULL;
+    }
+    shader_data = shader->baseShader.backend_data;
+
+    if (inp2fixup_info >= shader_data->num_gl_shaders)
+    {
+        ERR("invalid index\n");
+        return NULL;
+    }
+
+    return &shader_data->gl_shaders[inp2fixup_info].np2fixup;
+}
+#endif
+
 /**
  * Loads the texture dimensions for NP2 fixup into the currently set GLSL program.
@@ -702,6 +742,8 @@
         GLfloat np2fixup_constants[4 * MAX_FRAGMENT_SAMPLERS];
 
+        const struct ps_np2fixup_info *np2Fixup_info = WINEFIXUPINFO_GET(prog);
+
         for (i = 0; fixup; fixup >>= 1, ++i) {
-            const unsigned char idx = prog->np2Fixup_info->idx[i];
+            const unsigned char idx = np2Fixup_info->idx[i];
             const IWineD3DBaseTextureImpl* const tex = (const IWineD3DBaseTextureImpl*) stateBlock->textures[i];
             GLfloat* tex_dim = &np2fixup_constants[(idx >> 1) * 4];
@@ -719,5 +761,5 @@
         }
 
-        GL_EXTCALL(glUniform4fvARB(prog->np2Fixup_location, prog->np2Fixup_info->num_consts, np2fixup_constants));
+        GL_EXTCALL(glUniform4fvARB(prog->np2Fixup_location, np2Fixup_info->num_consts, np2fixup_constants));
     }
 }
@@ -4136,5 +4178,11 @@
 static GLhandleARB find_glsl_pshader(const struct wined3d_context *context,
         struct wined3d_shader_buffer *buffer, IWineD3DPixelShaderImpl *shader,
-        const struct ps_compile_args *args, const struct ps_np2fixup_info **np2fixup_info)
+        const struct ps_compile_args *args,
+#ifdef VBOXWDDM
+        UINT *inp2fixup_info
+#else
+        const struct ps_np2fixup_info **np2fixup_info
+#endif
+        )
 {
     UINT i;
@@ -4162,5 +4210,11 @@
     for(i = 0; i < shader_data->num_gl_shaders; i++) {
         if(memcmp(&shader_data->gl_shaders[i].args, args, sizeof(*args)) == 0) {
-            if(args->np2_fixup) *np2fixup_info = &shader_data->gl_shaders[i].np2fixup;
+            if(args->np2_fixup) {
+#ifdef VBOXWDDM
+                *inp2fixup_info = i;
+#else
+                *np2fixup_info = &shader_data->gl_shaders[i].np2fixup;
+#endif
+            }
             return shader_data->gl_shaders[i].prgId;
         }
@@ -4197,6 +4251,10 @@
     shader_buffer_clear(buffer);
     ret = shader_glsl_generate_pshader(context, buffer, shader, args, np2fixup);
+#ifdef VBOXWDDM
+    *inp2fixup_info = shader_data->num_gl_shaders;
+#else
+    *np2fixup_info = np2fixup;
+#endif
     shader_data->gl_shaders[shader_data->num_gl_shaders++].prgId = ret;
-    *np2fixup_info = np2fixup;
 
     return ret;
@@ -4318,5 +4376,5 @@
     entry->ps_args = ps_compile_args;
     entry->constant_version = 0;
-    entry->np2Fixup_info = NULL;
+    WINEFIXUPINFO_INIT(entry);
     /* Add the hash table entry */
     add_glsl_program_entry(priv, entry);
@@ -4371,5 +4429,11 @@
     {
         GLhandleARB pshader_id = find_glsl_pshader(context, &priv->shader_buffer,
-                (IWineD3DPixelShaderImpl *)pshader, &ps_compile_args, &entry->np2Fixup_info);
+                (IWineD3DPixelShaderImpl *)pshader, &ps_compile_args,
+#ifdef VBOXWDDM
+                &entry->inp2Fixup_info
+#else
+                &entry->np2Fixup_info
+#endif
+                );
         TRACE("Attaching GLSL shader object %u to program %u\n", pshader_id, programId);
         GL_EXTCALL(glAttachObjectARB(programId, pshader_id));
@@ -4422,5 +4486,5 @@
 
         if (ps_compile_args.np2_fixup) {
-            if (entry->np2Fixup_info) {
+            if (WINEFIXUPINFO_ISVALID(entry)) {
                 entry->np2Fixup_location = GL_EXTCALL(glGetUniformLocationARB(programId, "PsamplerNP2Fixup"));
             } else {
@@ -4585,5 +4649,5 @@
      * constants. This has to be done because it can't be guaranteed that sampler() (from state.c) is
      * called between selecting the shader and using it, which results in wrong fixup for some frames. */
-    if (priv->glsl_program && priv->glsl_program->np2Fixup_info)
+    if (priv->glsl_program && WINEFIXUPINFO_ISVALID(priv->glsl_program))
     {
         shader_glsl_load_np2fixup_constants((IWineD3DDevice *)device, usePS, useVS);
