From 0cbd08b2b909a33fe45c6e482fa81cb6149a8278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20D=C3=B6singer?= Date: Sun, 6 Apr 2008 00:22:08 +0200 Subject: [PATCH] wined3d: Disable texture filtering on textures that do not support it. OpenGL always offers filtering on all formats, and if the hardware doesn't support it the driver falls back to software. Direct3D on the other hand silently disables filtering, so that's what we should do too. --- dlls/wined3d/device.c | 19 ++++++++++++++++--- dlls/wined3d/directx.c | 6 ++++++ dlls/wined3d/wined3d_private.h | 1 + 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 82bdf2f6588..489b36e2062 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -789,7 +789,12 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateTexture(IWineD3DDevice *iface, U D3DINITIALIZEBASETEXTURE(object->baseTexture); object->width = Width; object->height = Height; - object->baseTexture.minMipLookup = &minMipLookup; + + if(glDesc->Flags & WINED3DFMT_FLAG_FILTERING) { + object->baseTexture.minMipLookup = &minMipLookup; + } else { + object->baseTexture.minMipLookup = &minMipLookup_noFilter; + } /** Non-power2 support **/ if (GL_SUPPORT(ARB_TEXTURE_NON_POWER_OF_TWO)) { @@ -935,7 +940,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateVolumeTexture(IWineD3DDevice *ifa object->baseTexture.pow2Matrix[10] = 1.0; object->baseTexture.pow2Matrix[15] = 1.0; - object->baseTexture.minMipLookup = &minMipLookup; + if(glDesc->Flags & WINED3DFMT_FLAG_FILTERING) { + object->baseTexture.minMipLookup = &minMipLookup; + } else { + object->baseTexture.minMipLookup = &minMipLookup_noFilter; + } /* Calculate levels for mip mapping */ if (Usage & WINED3DUSAGE_AUTOGENMIPMAP) { @@ -1084,7 +1093,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface object->baseTexture.pow2Matrix[10] = ((float)EdgeLength) / ((float)pow2EdgeLength); object->baseTexture.pow2Matrix[15] = 1.0; - object->baseTexture.minMipLookup = &minMipLookup; + if(glDesc->Flags & WINED3DFMT_FLAG_FILTERING) { + object->baseTexture.minMipLookup = &minMipLookup; + } else { + object->baseTexture.minMipLookup = &minMipLookup_noFilter; + } /* Calculate levels for mip mapping */ if (Usage & WINED3DUSAGE_AUTOGENMIPMAP) { diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index d0fbf3aef25..c29fbf1db84 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -155,6 +155,12 @@ int maxLookup[MAX_LOOKUPS]; DWORD *stateLookup[MAX_LOOKUPS]; DWORD minMipLookup[WINED3DTEXF_ANISOTROPIC + 1][WINED3DTEXF_LINEAR + 1]; +DWORD minMipLookup_noFilter[WINED3DTEXF_ANISOTROPIC + 1][WINED3DTEXF_LINEAR + 1] = { + {GL_NEAREST, GL_NEAREST, GL_NEAREST}, + {GL_NEAREST, GL_NEAREST, GL_NEAREST}, + {GL_NEAREST, GL_NEAREST, GL_NEAREST}, + {GL_NEAREST, GL_NEAREST, GL_NEAREST}, +}; /* drawStridedSlow attributes */ glAttribFunc position_funcs[WINED3DDECLTYPE_UNUSED]; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 46075fa8034..077e4560c17 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -114,6 +114,7 @@ extern DWORD *stateLookup[MAX_LOOKUPS]; typedef DWORD minMipLookup_t[WINED3DTEXF_ANISOTROPIC + 1][WINED3DTEXF_LINEAR + 1]; extern minMipLookup_t minMipLookup; +extern minMipLookup_t minMipLookup_noFilter; void init_type_lookup(WineD3D_GL_Info *gl_info); #define WINED3D_ATR_TYPE(type) GLINFO_LOCATION.glTypeLookup[type].d3dType