wined3d: Make minMipLookup_noFilter and magLookup_noFilter const.

Note that minMipLookup and magLookup aren't particularly safe to use,
they're global arrays initialized from IWineD3DImpl_FillGLCaps(). The same
goes for the other global dynamic lookup tables.
This commit is contained in:
Henri Verbeet 2008-11-26 16:14:40 +01:00 committed by Alexandre Julliard
parent 449c219eb0
commit c7880e8916
5 changed files with 57 additions and 48 deletions

View File

@ -426,7 +426,7 @@ void WINAPI IWineD3DBaseTextureImpl_ApplyStateChanges(IWineD3DBaseTexture *iface
if (state > WINED3DTEXF_ANISOTROPIC) {
FIXME("Unrecognized or unsupported MAGFILTER* value %d\n", state);
} else {
glValue = (*This->baseTexture.magLookup)[state - WINED3DTEXF_NONE];
glValue = This->baseTexture.magLookup[state - WINED3DTEXF_NONE];
TRACE("ValueMAG=%d setting MAGFILTER to %x\n", state, glValue);
glTexParameteri(textureDimensions, GL_TEXTURE_MAG_FILTER, glValue);
/* We need to reset the Anisotropic filtering state when we change the mag filter to WINED3DTEXF_ANISOTROPIC (this seems a bit weird, check the documentation to see how it should be switched off. */
@ -455,9 +455,9 @@ void WINAPI IWineD3DBaseTextureImpl_ApplyStateChanges(IWineD3DBaseTexture *iface
This->baseTexture.states[WINED3DTEXSTA_MINFILTER],
This->baseTexture.states[WINED3DTEXSTA_MIPFILTER]);
}
glValue = (*This->baseTexture.minMipLookup)
glValue = This->baseTexture.minMipLookup
[min(max(samplerStates[WINED3DSAMP_MINFILTER],WINED3DTEXF_NONE), WINED3DTEXF_ANISOTROPIC)]
[min(max(samplerStates[WINED3DSAMP_MIPFILTER],WINED3DTEXF_NONE), WINED3DTEXF_LINEAR)];
.mip[min(max(samplerStates[WINED3DSAMP_MIPFILTER],WINED3DTEXF_NONE), WINED3DTEXF_LINEAR)];
TRACE("ValueMIN=%d, ValueMIP=%d, setting MINFILTER to %x\n",
samplerStates[WINED3DSAMP_MINFILTER],

View File

@ -779,11 +779,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateTexture(IWineD3DDevice *iface, U
object->height = Height;
if(glDesc->Flags & WINED3DFMT_FLAG_FILTERING) {
object->baseTexture.minMipLookup = &minMipLookup;
object->baseTexture.magLookup = &magLookup;
object->baseTexture.minMipLookup = minMipLookup;
object->baseTexture.magLookup = magLookup;
} else {
object->baseTexture.minMipLookup = &minMipLookup_noFilter;
object->baseTexture.magLookup = &magLookup_noFilter;
object->baseTexture.minMipLookup = minMipLookup_noFilter;
object->baseTexture.magLookup = magLookup_noFilter;
}
/** Non-power2 support **/
@ -821,7 +821,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateTexture(IWineD3DDevice *iface, U
object->baseTexture.pow2Matrix[15] = 1.0;
object->target = GL_TEXTURE_2D;
object->cond_np2 = TRUE;
object->baseTexture.minMipLookup = &minMipLookup_noFilter;
object->baseTexture.minMipLookup = minMipLookup_noFilter;
} else if(GL_SUPPORT(ARB_TEXTURE_RECTANGLE) &&
(Width != pow2Width || Height != pow2Height) &&
!((Format == WINED3DFMT_P8) && GL_SUPPORT(EXT_PALETTED_TEXTURE) && (wined3d_settings.rendertargetlock_mode == RTL_READTEX || wined3d_settings.rendertargetlock_mode == RTL_TEXTEX)))
@ -832,7 +832,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateTexture(IWineD3DDevice *iface, U
object->baseTexture.pow2Matrix[15] = 1.0;
object->target = GL_TEXTURE_RECTANGLE_ARB;
object->cond_np2 = TRUE;
object->baseTexture.minMipLookup = &minMipLookup_noFilter;
object->baseTexture.minMipLookup = minMipLookup_noFilter;
} else {
object->baseTexture.pow2Matrix[0] = (((float)Width) / ((float)pow2Width));
object->baseTexture.pow2Matrix[5] = (((float)Height) / ((float)pow2Height));
@ -943,11 +943,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateVolumeTexture(IWineD3DDevice *ifa
object->baseTexture.pow2Matrix[15] = 1.0;
if(glDesc->Flags & WINED3DFMT_FLAG_FILTERING) {
object->baseTexture.minMipLookup = &minMipLookup;
object->baseTexture.magLookup = &magLookup;
object->baseTexture.minMipLookup = minMipLookup;
object->baseTexture.magLookup = magLookup;
} else {
object->baseTexture.minMipLookup = &minMipLookup_noFilter;
object->baseTexture.magLookup = &magLookup_noFilter;
object->baseTexture.minMipLookup = minMipLookup_noFilter;
object->baseTexture.magLookup = magLookup_noFilter;
}
/* Calculate levels for mip mapping */
@ -1098,11 +1098,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface
}
if(glDesc->Flags & WINED3DFMT_FLAG_FILTERING) {
object->baseTexture.minMipLookup = &minMipLookup;
object->baseTexture.magLookup = &magLookup;
object->baseTexture.minMipLookup = minMipLookup;
object->baseTexture.magLookup = magLookup;
} else {
object->baseTexture.minMipLookup = &minMipLookup_noFilter;
object->baseTexture.magLookup = &magLookup_noFilter;
object->baseTexture.minMipLookup = minMipLookup_noFilter;
object->baseTexture.magLookup = magLookup_noFilter;
}
/* Calculate levels for mip mapping */

View File

@ -158,16 +158,18 @@ int minLookup[MAX_LOOKUPS];
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},
struct min_lookup minMipLookup[WINED3DTEXF_ANISOTROPIC + 1];
const struct min_lookup minMipLookup_noFilter[WINED3DTEXF_ANISOTROPIC + 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}},
};
DWORD magLookup[WINED3DTEXF_ANISOTROPIC + 1];
DWORD magLookup_noFilter[WINED3DTEXF_ANISOTROPIC + 1] = {
GLenum magLookup[WINED3DTEXF_ANISOTROPIC + 1];
const GLenum magLookup_noFilter[WINED3DTEXF_ANISOTROPIC + 1] =
{
GL_NEAREST, GL_NEAREST, GL_NEAREST, GL_NEAREST
};
@ -1367,19 +1369,21 @@ BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) {
gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC] ? GL_LINEAR : GL_NEAREST;
minMipLookup[WINED3DTEXF_NONE][WINED3DTEXF_NONE] = GL_LINEAR;
minMipLookup[WINED3DTEXF_NONE][WINED3DTEXF_POINT] = GL_LINEAR;
minMipLookup[WINED3DTEXF_NONE][WINED3DTEXF_LINEAR] = GL_LINEAR;
minMipLookup[WINED3DTEXF_POINT][WINED3DTEXF_NONE] = GL_NEAREST;
minMipLookup[WINED3DTEXF_POINT][WINED3DTEXF_POINT] = GL_NEAREST_MIPMAP_NEAREST;
minMipLookup[WINED3DTEXF_POINT][WINED3DTEXF_LINEAR] = GL_NEAREST_MIPMAP_LINEAR;
minMipLookup[WINED3DTEXF_LINEAR][WINED3DTEXF_NONE] = GL_LINEAR;
minMipLookup[WINED3DTEXF_LINEAR][WINED3DTEXF_POINT] = GL_LINEAR_MIPMAP_NEAREST;
minMipLookup[WINED3DTEXF_LINEAR][WINED3DTEXF_LINEAR] = GL_LINEAR_MIPMAP_LINEAR;
minMipLookup[WINED3DTEXF_ANISOTROPIC][WINED3DTEXF_NONE] = gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC] ?
GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR;
minMipLookup[WINED3DTEXF_ANISOTROPIC][WINED3DTEXF_POINT] = gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC] ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR;
minMipLookup[WINED3DTEXF_ANISOTROPIC][WINED3DTEXF_LINEAR] = gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC] ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR;
minMipLookup[WINED3DTEXF_NONE].mip[WINED3DTEXF_NONE] = GL_LINEAR;
minMipLookup[WINED3DTEXF_NONE].mip[WINED3DTEXF_POINT] = GL_LINEAR;
minMipLookup[WINED3DTEXF_NONE].mip[WINED3DTEXF_LINEAR] = GL_LINEAR;
minMipLookup[WINED3DTEXF_POINT].mip[WINED3DTEXF_NONE] = GL_NEAREST;
minMipLookup[WINED3DTEXF_POINT].mip[WINED3DTEXF_POINT] = GL_NEAREST_MIPMAP_NEAREST;
minMipLookup[WINED3DTEXF_POINT].mip[WINED3DTEXF_LINEAR] = GL_NEAREST_MIPMAP_LINEAR;
minMipLookup[WINED3DTEXF_LINEAR].mip[WINED3DTEXF_NONE] = GL_LINEAR;
minMipLookup[WINED3DTEXF_LINEAR].mip[WINED3DTEXF_POINT] = GL_LINEAR_MIPMAP_NEAREST;
minMipLookup[WINED3DTEXF_LINEAR].mip[WINED3DTEXF_LINEAR] = GL_LINEAR_MIPMAP_LINEAR;
minMipLookup[WINED3DTEXF_ANISOTROPIC].mip[WINED3DTEXF_NONE]
= gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC] ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR;
minMipLookup[WINED3DTEXF_ANISOTROPIC].mip[WINED3DTEXF_POINT]
= gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC] ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR;
minMipLookup[WINED3DTEXF_ANISOTROPIC].mip[WINED3DTEXF_LINEAR]
= gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC] ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR;
/* TODO: config lookups */

View File

@ -2990,7 +2990,7 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine
magLookup[Filter - WINED3DTEXF_NONE]);
checkGLcall("glTexParameteri");
glTexParameteri(texture_target, GL_TEXTURE_MIN_FILTER,
minMipLookup[Filter][WINED3DTEXF_NONE]);
minMipLookup[Filter].mip[WINED3DTEXF_NONE]);
checkGLcall("glTexParameteri");
if(!swapchain || (IWineD3DSurface *) Src == swapchain->backBuffer[0]) {
@ -3530,7 +3530,7 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const
magLookup[Filter - WINED3DTEXF_NONE]);
checkGLcall("glTexParameteri");
glTexParameteri(Src->glDescription.target, GL_TEXTURE_MIN_FILTER,
minMipLookup[Filter][WINED3DTEXF_NONE]);
minMipLookup[Filter].mip[WINED3DTEXF_NONE]);
checkGLcall("glTexParameteri");
glTexParameteri(Src->glDescription.target, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(Src->glDescription.target, GL_TEXTURE_WRAP_T, GL_CLAMP);

View File

@ -111,13 +111,18 @@ extern int minLookup[MAX_LOOKUPS];
extern int maxLookup[MAX_LOOKUPS];
extern DWORD *stateLookup[MAX_LOOKUPS];
typedef DWORD magLookup_t[WINED3DTEXF_ANISOTROPIC + 1];
extern magLookup_t magLookup;
extern magLookup_t magLookup_noFilter;
struct min_lookup
{
GLenum mip[WINED3DTEXF_LINEAR + 1];
};
typedef DWORD minMipLookup_t[WINED3DTEXF_ANISOTROPIC + 1][WINED3DTEXF_LINEAR + 1];
extern minMipLookup_t minMipLookup;
extern minMipLookup_t minMipLookup_noFilter;
struct min_lookup minMipLookup[WINED3DTEXF_ANISOTROPIC + 1];
const struct min_lookup minMipLookup_noFilter[WINED3DTEXF_ANISOTROPIC + 1];
GLenum magLookup[WINED3DTEXF_ANISOTROPIC + 1];
const GLenum magLookup_noFilter[WINED3DTEXF_ANISOTROPIC + 1];
extern const struct filter_lookup filter_lookup_nofilter;
extern struct filter_lookup filter_lookup;
void init_type_lookup(WineD3D_GL_Info *gl_info);
#define WINED3D_ATR_TYPE(type) GLINFO_LOCATION.glTypeLookup[type].d3dType
@ -1229,8 +1234,8 @@ typedef struct IWineD3DBaseTextureClass
UINT srgb_mode_change_count;
WINED3DFORMAT shader_conversion_group;
float pow2Matrix[16];
minMipLookup_t *minMipLookup;
magLookup_t *magLookup;
const struct min_lookup *minMipLookup;
const GLenum *magLookup;
} IWineD3DBaseTextureClass;
typedef struct IWineD3DBaseTextureImpl