Stefan Dösinger : wined3d: Set the pow2 sizes in gl surface private setup.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Jul 26 06:36:55 CDT 2007


Module: wine
Branch: master
Commit: 59efd5c7eceded40483821d3e0f3774b97cc9dae
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=59efd5c7eceded40483821d3e0f3774b97cc9dae

Author: Stefan Dösinger <stefan at codeweavers.com>
Date:   Mon Jul 16 20:42:16 2007 +0200

wined3d: Set the pow2 sizes in gl surface private setup.

---

 dlls/wined3d/device.c      |   27 ---------------------------
 dlls/wined3d/surface.c     |   30 ++++++++++++++++++++++++++++++
 dlls/wined3d/surface_gdi.c |    6 ------
 3 files changed, 30 insertions(+), 33 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 07d5a79..d795e25 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -575,7 +575,6 @@ If this flag is set, the contents of the depth stencil buffer will be invalid af
 static HRESULT  WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, UINT Width, UINT Height, WINED3DFORMAT Format, BOOL Lockable, BOOL Discard, UINT Level, IWineD3DSurface **ppSurface,WINED3DRESOURCETYPE Type, DWORD Usage, WINED3DPOOL Pool, WINED3DMULTISAMPLE_TYPE MultiSample ,DWORD MultisampleQuality, HANDLE* pSharedHandle, WINED3DSURFTYPE Impl, IUnknown *parent) {
     IWineD3DDeviceImpl  *This = (IWineD3DDeviceImpl *)iface;    
     IWineD3DSurfaceImpl *object; /*NOTE: impl ref allowed since this is a create function */
-    unsigned int pow2Width, pow2Height;
     unsigned int Size       = 1;
     const PixelFormatDesc *tableEntry = getFormatDescEntry(Format);
     TRACE("(%p) Create surface\n",This);
@@ -616,27 +615,6 @@ static HRESULT  WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, U
     *    by the device.
       *******************************/
 
-    /* Non-power2 support */
-    if (GL_SUPPORT(ARB_TEXTURE_NON_POWER_OF_TWO)) {
-        pow2Width = Width;
-        pow2Height = Height;
-    } else {
-        /* Find the nearest pow2 match */
-        pow2Width = pow2Height = 1;
-        while (pow2Width < Width) pow2Width <<= 1;
-        while (pow2Height < Height) pow2Height <<= 1;
-    }
-
-    if (pow2Width > Width || pow2Height > Height) {
-         /** TODO: add support for non power two compressed textures (OpenGL 2 provices support for * non-power-two textures gratis) **/
-        if (Format == WINED3DFMT_DXT1 || Format == WINED3DFMT_DXT2 || Format == WINED3DFMT_DXT3
-               || Format == WINED3DFMT_DXT4 || Format == WINED3DFMT_DXT5) {
-            FIXME("(%p) Compressed non-power-two textures are not supported w(%d) h(%d)\n",
-                    This, Width, Height);
-            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!
@@ -675,13 +653,8 @@ static HRESULT  WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, U
     object->glDescription.level            = Level;
     object->glDescription.target           = GL_TEXTURE_2D;
 
-    /* Internal data */
-    object->pow2Width  = pow2Width;
-    object->pow2Height = pow2Height;
-
     /* Flags */
     object->Flags      = 0;
-    object->Flags     |= (pow2Width != Width || pow2Height != Height) ? SFLAG_NONPOW2 : 0;
     object->Flags     |= Discard ? SFLAG_DISCARD : 0;
     object->Flags     |= (WINED3DFMT_D16_LOCKABLE == Format) ? SFLAG_LOCKABLE : 0;
     object->Flags     |= Lockable ? SFLAG_LOCKABLE : 0;
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 11e0fba..f0a2b4c 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -3435,6 +3435,36 @@ HRESULT WINAPI IWineD3DSurfaceImpl_SetColorKey(IWineD3DSurface *iface, DWORD Fla
 static HRESULT WINAPI IWineD3DSurfaceImpl_PrivateSetup(IWineD3DSurface *iface) {
     /** Check against the maximum texture sizes supported by the video card **/
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
+    unsigned int pow2Width, pow2Height;
+
+    /* Non-power2 support */
+    if (GL_SUPPORT(ARB_TEXTURE_NON_POWER_OF_TWO)) {
+        pow2Width = This->currentDesc.Width;
+        pow2Height = This->currentDesc.Height;
+    } else {
+        /* Find the nearest pow2 match */
+        pow2Width = pow2Height = 1;
+        while (pow2Width < This->currentDesc.Width) pow2Width <<= 1;
+        while (pow2Height < This->currentDesc.Height) pow2Height <<= 1;
+    }
+    This->pow2Width  = pow2Width;
+    This->pow2Height = pow2Height;
+
+    if (pow2Width > This->currentDesc.Width || pow2Height > This->currentDesc.Height) {
+        WINED3DFORMAT Format = This->resource.format;
+        /** TODO: add support for non power two compressed textures **/
+        if (Format == WINED3DFMT_DXT1 || Format == WINED3DFMT_DXT2 || Format == WINED3DFMT_DXT3
+            || Format == WINED3DFMT_DXT4 || Format == WINED3DFMT_DXT5) {
+            FIXME("(%p) Compressed non-power-two textures are not supported w(%d) h(%d)\n",
+                  This, This->currentDesc.Width, This->currentDesc.Height);
+            return WINED3DERR_NOTAVAILABLE;
+        }
+    }
+
+    if(pow2Width != This->currentDesc.Width ||
+       pow2Height != This->currentDesc.Height) {
+        This->Flags |= SFLAG_NONPOW2;
+    }
 
     TRACE("%p\n", This);
     if ((This->pow2Width > GL_LIMITS(texture_size) || This->pow2Height > GL_LIMITS(texture_size)) && !(This->resource.usage & (WINED3DUSAGE_RENDERTARGET | WINED3DUSAGE_DEPTHSTENCIL))) {
diff --git a/dlls/wined3d/surface_gdi.c b/dlls/wined3d/surface_gdi.c
index c994000..f3a3fea 100644
--- a/dlls/wined3d/surface_gdi.c
+++ b/dlls/wined3d/surface_gdi.c
@@ -1513,7 +1513,6 @@ IWineGDISurfaceImpl_PrivateSetup(IWineD3DSurface *iface)
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
     HRESULT hr;
     HDC hdc;
-    long oldsize = This->resource.size;
 
     if(This->resource.usage & WINED3DUSAGE_OVERLAY)
     {
@@ -1527,13 +1526,8 @@ IWineGDISurfaceImpl_PrivateSetup(IWineD3DSurface *iface)
     This->resource.allocatedMemory = NULL;
 
     /* We don't mind the nonpow2 stuff in GDI */
-    This->resource.size = IWineD3DSurface_GetPitch(iface) * This->currentDesc.Height;
     This->pow2Width = This->currentDesc.Width;
     This->pow2Height = This->currentDesc.Height;
-    This->Flags &= ~SFLAG_NONPOW2;
-
-    /* Adjust the opengl mem counter */
-    globalChangeGlRam(This->resource.size - oldsize);
 
     /* Call GetDC to create a DIB section. We will use that
      * DIB section for rendering




More information about the wine-cvs mailing list