Stefan Dösinger : wined3d: Sort of oversized surface support.

Alexandre Julliard julliard at wine.codeweavers.com
Sat May 20 07:27:27 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: cfcdb6515b5059aa1f4253a2e51a55fa67c78dfe
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=cfcdb6515b5059aa1f4253a2e51a55fa67c78dfe

Author: Stefan Dösinger <stefan at codeweavers.com>
Date:   Fri May 19 00:13:29 2006 +0200

wined3d: Sort of oversized surface support.

---

 dlls/wined3d/device.c          |   19 +++----------------
 dlls/wined3d/surface.c         |   34 +++++++++++++++++++++++++++++++++-
 dlls/wined3d/wined3d_private.h |    3 +++
 3 files changed, 39 insertions(+), 17 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index cdedac0..c74b125 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -644,19 +644,6 @@ HRESULT  WINAPI IWineD3DDeviceImpl_Creat
         }
     }
 
-    /** Check against the maximum texture sizes supported by the video card **/
-    if (pow2Width > GL_LIMITS(texture_size) || pow2Height > GL_LIMITS(texture_size)) {
-        /* one of three options
-        1: Do the same as we do with nonpow 2 and scale the texture, (any texture ops would require the texture to be scaled which is potentially slow)
-        2: Set the texture to the maxium size (bad idea)
-        3:    WARN and return WINED3DERR_NOTAVAILABLE;
-        */
-        WARN("(%p) Application requested a surface w %d, h %d, but the graphics card only supports %d\n", This, Width, Height, GL_LIMITS(texture_size));
-         return WINED3DERR_NOTAVAILABLE;
-    }
-
-
-
     /** DXTn mipmaps use the same number of 'levels' down to eg. 8x1, but since
      *  it is based around 4x4 pixel blocks it requires padding, so allocate enough
      *  space!
@@ -850,12 +837,12 @@ HRESULT  WINAPI IWineD3DDeviceImpl_Creat
     {
         /* use the callback to create the texture surface */
         hr = D3DCB_CreateSurface(This->parent, tmpW, tmpH, Format, Usage, Pool, i, &object->surfaces[i],NULL);
-        if (hr!= WINED3D_OK) {
+        if (hr!= WINED3D_OK || ( (IWineD3DSurfaceImpl *) object->surfaces[i])->Flags & SFLAG_OVERSIZE) {
             int j;
             FIXME("Failed to create surface  %p\n", object);
             /* clean up */
-            for (j = 0 ; j < i ; j++) {
-                IWineD3DSurface_Release(object->surfaces[j]);
+            for (j = 0 ; j <= i ; j++) {
+                if(object->surfaces[j]) IWineD3DSurface_Release(object->surfaces[j]);
             }
             /* heap free object */
             HeapFree(GetProcessHeap(), 0, object);
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 7016f5d..a267ad2 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -1161,6 +1161,11 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadT
         return WINED3D_OK;
     }
 
+    if(!This->Flags & SFLAG_OVERSIZE) {
+        ERR("Loading an oversized texture not supported yet, will follow soon\n");
+        return WINED3D_OK;  /* Return OK for now, easier for merging the code */
+    }
+
     This->Flags &= ~SFLAG_DIRTY;
 
     /* Resources are placed in system RAM and do not need to be recreated when a device is lost.
@@ -1916,7 +1921,34 @@ HRESULT WINAPI IWineD3DSurfaceImpl_SetCo
 }
 
 HRESULT WINAPI IWineD3DSurfaceImpl_PrivateSetup(IWineD3DSurface *iface) {
-    /* Nothing to do for now */
+    /** Check against the maximum texture sizes supported by the video card **/
+    IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
+
+    TRACE("%p\n", This);
+    if ((This->pow2Width > GL_LIMITS(texture_size) || This->pow2Height > GL_LIMITS(texture_size)) && !(This->resource.usage & (WINED3DUSAGE_RENDERTARGET | WINED3DUSAGE_DEPTHSTENCIL))) {
+        /* one of three options
+        1: Do the same as we do with nonpow 2 and scale the texture, (any texture ops would require the texture to be scaled which is potentially slow)
+        2: Set the texture to the maxium size (bad idea)
+        3:    WARN and return WINED3DERR_NOTAVAILABLE;
+        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\n", This);
+        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 {
+        /* 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;
+    }
+
     return WINED3D_OK;
 }
 
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index ebb2d86..0addae6 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -845,6 +845,9 @@ struct IWineD3DSurfaceImpl
     UINT                      pow2Height;
     UINT                      pow2Size;
 
+    /* Oversized texture */
+    RECT                      glRect;
+
 #if 0
     /* precalculated x and y scalings for texture coords */
     float                     pow2scalingFactorX; /* =  (Width  / pow2Width ) */




More information about the wine-cvs mailing list