Skip to content

Commit

Permalink
Disable mipfilter when mipmap surface isn't filled
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud committed Aug 1, 2024
1 parent c67a90c commit 4e1896d
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Dllmain/BuildNo.rc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define BUILD_NUMBER 7077
#define BUILD_NUMBER 7078
20 changes: 20 additions & 0 deletions ddraw/IDirect3DDeviceX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4210,6 +4210,16 @@ inline void m_IDirect3DDeviceX::SetDrawStates(DWORD dwVertexTypeDesc, DWORD& dwF
}
}
}
if (!Config.DdrawForceMipMapAutoGen)
{
for (UINT x = 0; x < MaxTextureStages; x++)
{
if (ssMipFilter[x] != D3DTEXF_NONE && CurrentTextureSurfaceX[x] && !CurrentTextureSurfaceX[x]->IsMipMapReady())
{
(*d3d9Device)->SetSamplerState(x, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
}
}
}
if (rsColorKeyEnabled)
{
// Check for color key alpha texture
Expand Down Expand Up @@ -4274,6 +4284,16 @@ inline void m_IDirect3DDeviceX::RestoreDrawStates(DWORD dwVertexTypeDesc, DWORD
{
lpCurrentRenderTargetX->SetDirtyFlag();
}
if (!Config.DdrawForceMipMapAutoGen)
{
for (UINT x = 0; x < MaxTextureStages; x++)
{
if (ssMipFilter[x] != D3DTEXF_NONE && CurrentTextureSurfaceX[x] && !CurrentTextureSurfaceX[x]->IsMipMapReady())
{
(*d3d9Device)->SetSamplerState(x, D3DSAMP_MIPFILTER, ssMipFilter[x]);
}
}
}
if (Config.DdrawFixByteAlignment > 1)
{
for (UINT x = 0; x < MaxTextureStages; x++)
Expand Down
13 changes: 13 additions & 0 deletions ddraw/IDirectDrawSurfaceX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2683,6 +2683,19 @@ HRESULT m_IDirectDrawSurfaceX::Lock2(LPRECT lpDestRect, LPDDSURFACEDESC2 lpDDSur
<< " MipMapLevel: " << MipMapLevel);
}
MipMaps[Level].lPitch = LockedRect.Pitch;
MipMaps[Level].HasData = true;
if (!IsMipMapReadyToUse)
{
IsMipMapReadyToUse = true;
for (UINT x = 0; x < min(MaxMipMapLevel, MipMaps.size()); x++)
{
if (!MipMaps[x].HasData)
{
IsMipMapReadyToUse = false;
break;
}
}
}
}
else
{
Expand Down
3 changes: 3 additions & 0 deletions ddraw/IDirectDrawSurfaceX.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class m_IDirectDrawSurfaceX : public IUnknown, public AddressLookupTableDdrawObj
DWORD dwWidth = 0;
DWORD dwHeight = 0;
LONG lPitch = 0;
bool HasData = false;
};

// For aligning bits after a lock for games that hard code the pitch
Expand Down Expand Up @@ -146,6 +147,7 @@ class m_IDirectDrawSurfaceX : public IUnknown, public AddressLookupTableDdrawObj
m_IDirectDrawX *ddrawParent = nullptr; // DirectDraw parent device
std::vector<MIPMAP> MipMaps; // For MipMaps
DWORD MaxMipMapLevel = 1; // For MipMaps
bool IsMipMapReadyToUse = false; // For MipMaps
LPDIRECT3DTEXTURE9 PrimaryDisplayTexture = nullptr; // Used for the texture surface for the primary surface
m_IDirectDrawPalette *attachedPalette = nullptr; // Associated palette
m_IDirectDrawClipper *attachedClipper = nullptr; // Associated clipper
Expand Down Expand Up @@ -453,6 +455,7 @@ class m_IDirectDrawSurfaceX : public IUnknown, public AddressLookupTableDdrawObj
inline bool IsUsingEmulation() { return (surface.emu && surface.emu->DC && surface.emu->GameDC && surface.emu->pBits); }
inline bool IsEmulationDCReady() { return (IsUsingEmulation() && !surface.emu->UsingGameDC); }
inline bool IsSurfaceDirty() { return surface.IsDirtyFlag; }
inline bool IsMipMapReady() { return IsMipMapReadyToUse; }
void SetDirtyFlag();
void ClearDirtyFlags();
bool GetColorKeyForShader(float(&lowColorKey)[4], float(&highColorKey)[4]);
Expand Down

0 comments on commit 4e1896d

Please sign in to comment.