Tobias Jakobi : wined3d: Add pow2Matrix_identity flag to BaseTextureClass struct.

Alexandre Julliard julliard at winehq.org
Tue Mar 31 12:19:21 CDT 2009


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

Author: Tobias Jakobi <liquid.acid at gmx.net>
Date:   Thu Mar 26 03:12:50 2009 +0100

wined3d: Add pow2Matrix_identity flag to BaseTextureClass struct.

New flag helps to quickly find out whether the pow2Matrix is a
identity matrix (no texcoord fixup needed) or not.

---

 dlls/wined3d/basetexture.c     |    1 +
 dlls/wined3d/device.c          |   18 +++++++++++++++---
 dlls/wined3d/wined3d_private.h |    1 +
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/dlls/wined3d/basetexture.c b/dlls/wined3d/basetexture.c
index 8349064..caf2148 100644
--- a/dlls/wined3d/basetexture.c
+++ b/dlls/wined3d/basetexture.c
@@ -35,6 +35,7 @@ void basetexture_init(struct IWineD3DBaseTextureClass *texture, UINT levels, DWO
     texture->dirty = TRUE;
     texture->srgbDirty = TRUE;
     texture->is_srgb = FALSE;
+    texture->pow2Matrix_identity = TRUE;
 }
 
 void basetexture_cleanup(IWineD3DBaseTexture *iface)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 5d3f400..0f6885f 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -1233,6 +1233,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateTexture(IWineD3DDevice *iface,
        (Width != pow2Width || Height != pow2Height) &&
        !((Format == WINED3DFMT_P8) && GL_SUPPORT(EXT_PALETTED_TEXTURE) && (wined3d_settings.rendertargetlock_mode == RTL_READTEX || wined3d_settings.rendertargetlock_mode == RTL_TEXTEX)))
     {
+        if ((Width != 1) || (Height != 1)) {
+            object->baseTexture.pow2Matrix_identity = FALSE;
+        }
+
         object->baseTexture.pow2Matrix[0] =  (float)Width;
         object->baseTexture.pow2Matrix[5] =  (float)Height;
         object->baseTexture.pow2Matrix[10] = 1.0;
@@ -1241,8 +1245,15 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateTexture(IWineD3DDevice *iface,
         object->cond_np2 = TRUE;
         object->baseTexture.minMipLookup = minMipLookup_noFilter;
     } else {
-        object->baseTexture.pow2Matrix[0] =  (((float)Width)  / ((float)pow2Width));
-        object->baseTexture.pow2Matrix[5] =  (((float)Height) / ((float)pow2Height));
+        if ((Width != pow2Width) || (Height != pow2Height)) {
+            object->baseTexture.pow2Matrix_identity = FALSE;
+            object->baseTexture.pow2Matrix[0] =  (((float)Width)  / ((float)pow2Width));
+            object->baseTexture.pow2Matrix[5] =  (((float)Height) / ((float)pow2Height));
+        } else {
+            object->baseTexture.pow2Matrix[0] =  1.0;
+            object->baseTexture.pow2Matrix[5] =  1.0;
+        }
+
         object->baseTexture.pow2Matrix[10] = 1.0;
         object->baseTexture.pow2Matrix[15] = 1.0;
         object->target = GL_TEXTURE_2D;
@@ -1540,7 +1551,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface
     pow2EdgeLength = 1;
     while (pow2EdgeLength < EdgeLength) pow2EdgeLength <<= 1;
 
-    if (GL_SUPPORT(ARB_TEXTURE_NON_POWER_OF_TWO)) {
+    if (GL_SUPPORT(ARB_TEXTURE_NON_POWER_OF_TWO) || (EdgeLength == pow2EdgeLength)) {
         /* Precalculated scaling for 'faked' non power of two texture coords */
         object->baseTexture.pow2Matrix[ 0] = 1.0;
         object->baseTexture.pow2Matrix[ 5] = 1.0;
@@ -1552,6 +1563,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface
         object->baseTexture.pow2Matrix[ 5] = ((float)EdgeLength) / ((float)pow2EdgeLength);
         object->baseTexture.pow2Matrix[10] = ((float)EdgeLength) / ((float)pow2EdgeLength);
         object->baseTexture.pow2Matrix[15] = 1.0;
+        object->baseTexture.pow2Matrix_identity = FALSE;
     }
 
     if (object->resource.format_desc->Flags & WINED3DFMT_FLAG_FILTERING)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index fdd28da..abab9dc 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1384,6 +1384,7 @@ typedef struct IWineD3DBaseTextureClass
     LONG                    bindCount;
     DWORD                   sampler;
     BOOL                    is_srgb;
+    BOOL                    pow2Matrix_identity;
     const struct min_lookup *minMipLookup;
     const GLenum            *magLookup;
     void                    (*internal_preload)(IWineD3DBaseTexture *iface, enum WINED3DSRGB srgb);




More information about the wine-cvs mailing list