diff --git a/dlls/wined3d/basetexture.c b/dlls/wined3d/basetexture.c index 834906482bb..caf2148ba55 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 5d3f4009666..0f6885ff297 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 fdd28da1d04..abab9dc7877 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);