Skip to content

Commit

Permalink
Enable MipMap support but disable MipMap filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud committed May 6, 2024
1 parent 62b98cf commit 5e81e98
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Dllmain/BuildNo.rc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define BUILD_NUMBER 7006
#define BUILD_NUMBER 7007
17 changes: 10 additions & 7 deletions ddraw/IDirect3DDeviceX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2840,11 +2840,7 @@ HRESULT m_IDirect3DDeviceX::SetRenderState(D3DRENDERSTATETYPE dwRenderStateType,
case D3DRENDERSTATE_TEXTUREADDRESSV: // 45
return SetTextureStageState(0, (D3DTEXTURESTAGESTATETYPE)D3DTSS_ADDRESSV, dwRenderState);
case D3DRENDERSTATE_MIPMAPLODBIAS: // 46
if (dwRenderState != 0) // 0.0
{
LOG_LIMIT(100, __FUNCTION__ << " Warning: 'D3DRENDERSTATE_MIPMAPLODBIAS' not implemented! " << dwRenderState);
}
return D3D_OK;
return SetTextureStageState(0, (D3DTEXTURESTAGESTATETYPE)D3DTSS_MIPMAPLODBIAS, dwRenderState);
case D3DRENDERSTATE_ZBIAS: // 47
{
FLOAT Biased = static_cast<FLOAT>(dwRenderState) * -0.000005f;
Expand Down Expand Up @@ -3030,8 +3026,7 @@ HRESULT m_IDirect3DDeviceX::GetRenderState(D3DRENDERSTATETYPE dwRenderStateType,
case D3DRENDERSTATE_TEXTUREADDRESSV: // 45
return GetTextureStageState(0, (D3DTEXTURESTAGESTATETYPE)D3DTSS_ADDRESSV, lpdwRenderState);
case D3DRENDERSTATE_MIPMAPLODBIAS: // 46
*lpdwRenderState = 0; // 0.0f
return D3D_OK;
return GetTextureStageState(0, (D3DTEXTURESTAGESTATETYPE)D3DTSS_MIPMAPLODBIAS, lpdwRenderState);
case D3DRENDERSTATE_ZBIAS: // 47
(*d3d9Device)->GetRenderState(D3DRS_DEPTHBIAS, lpdwRenderState);
*lpdwRenderState = static_cast<DWORD>(*reinterpret_cast<const FLOAT*>(lpdwRenderState) * -200000.0f);
Expand Down Expand Up @@ -4161,6 +4156,14 @@ inline void m_IDirect3DDeviceX::SetDrawStates(DWORD dwVertexTypeDesc, DWORD& dwF
dwFlags |= D3DDP_DXW_COLORKEYENABLE;
}
}
if (Config.Dd7to9)
{
// For now just disable mipmap filtering
for (int x = 0; x < 8; x++)
{
(*d3d9Device)->SetSamplerState(x, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
}
}
if (dwFlags & D3DDP_DXW_COLORKEYENABLE)
{
if (!colorkeyPixelShader || !*colorkeyPixelShader)
Expand Down
3 changes: 1 addition & 2 deletions ddraw/IDirectDrawSurfaceX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
bool dirtyFlag = false;
bool SceneReady = false;
bool IsPresentRunning = false;
bool UseMipMapSupport = false;

// Cached surface wrapper interface v1 list
std::vector<m_IDirectDrawSurface*> SurfaceWrapperListV1;
Expand Down Expand Up @@ -5069,7 +5068,7 @@ inline void m_IDirectDrawSurfaceX::InitSurfaceDesc(DWORD DirectXVersion)
}

// Handle mipmaps
if (UseMipMapSupport && (surfaceDesc2.dwFlags & DDSD_MIPMAPCOUNT) && (surfaceDesc2.dwMipMapCount != 1) &&
if ((surfaceDesc2.dwFlags & DDSD_MIPMAPCOUNT) && (surfaceDesc2.dwMipMapCount != 1) &&
(surfaceDesc2.ddsCaps.dwCaps & (DDSCAPS_MIPMAP | DDSCAPS_COMPLEX | DDSCAPS_TEXTURE)) == (DDSCAPS_MIPMAP | DDSCAPS_COMPLEX | DDSCAPS_TEXTURE))
{
DWORD MipMapLevelCount = surfaceDesc2.dwMipMapCount ? min(surfaceDesc2.dwMipMapCount, GetMaxMipMapLevel(surfaceDesc2.dwWidth, surfaceDesc2.dwHeight)) :
Expand Down
4 changes: 2 additions & 2 deletions ddraw/IDirectDrawTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ void ConvertCaps(DDCAPS &Caps7, D3DCAPS9 &Caps9)
DDCAPS_OVERLAYSTRETCH*/ | DDCAPS_PALETTE | DDCAPS_PALETTEVSYNC | DDCAPS_VBI | DDCAPS_COLORKEY | DDCAPS_ALPHA | /*DDCAPS_COLORKEYHWASSIST |*/
DDCAPS_BLTCOLORFILL | DDCAPS_CANCLIP | DDCAPS_CANCLIPSTRETCHED | DDCAPS_CANBLTSYSMEM) |
(!Config.DdrawDisableDirect3DCaps ? DDCAPS_3D | DDCAPS_BLTDEPTHFILL /*| DDCAPS_ZBLTS | DDCAPS_ZOVERLAYS*/ : 0);
Caps7.dwCaps2 = (Caps9.Caps2 & (D3DCAPS2_FULLSCREENGAMMA /*| D3DCAPS2_CANCALIBRATEGAMMA*/ | D3DCAPS2_CANMANAGERESOURCE | D3DCAPS2_DYNAMICTEXTURES | (UseMipMapSupport ? D3DCAPS2_CANAUTOGENMIPMAP : 0) /*| D3DCAPS2_CANSHARERESOURCE*/)) |
Caps7.dwCaps2 = (Caps9.Caps2 & (D3DCAPS2_FULLSCREENGAMMA /*| D3DCAPS2_CANCALIBRATEGAMMA*/ | D3DCAPS2_CANMANAGERESOURCE | D3DCAPS2_DYNAMICTEXTURES | D3DCAPS2_CANAUTOGENMIPMAP /*| D3DCAPS2_CANSHARERESOURCE*/)) |
(/*DDCAPS2_CANBOBINTERLEAVED | DDCAPS2_CANBOBNONINTERLEAVED | DDCAPS2_NONLOCALVIDMEM |*/ DDCAPS2_WIDESURFACES | /*DDCAPS2_CANFLIPODDEVEN |*/ DDCAPS2_COPYFOURCC | DDCAPS2_NOPAGELOCKREQUIRED |
DDCAPS2_PRIMARYGAMMA | DDCAPS2_CANRENDERWINDOWED /*| DDCAPS2_FLIPINTERVAL*/ | DDCAPS2_FLIPNOVSYNC);
Caps7.dwCKeyCaps = (DDCKEYCAPS_DESTBLT | /*DDCKEYCAPS_DESTBLTCLRSPACE | DDCKEYCAPS_DESTOVERLAY | DDCKEYCAPS_DESTOVERLAYCLRSPACE |*/ DDCKEYCAPS_SRCBLT /*| DDCKEYCAPS_SRCBLTCLRSPACE
Expand All @@ -234,7 +234,7 @@ void ConvertCaps(DDCAPS &Caps7, D3DCAPS9 &Caps9)
// ddsCaps
Caps7.ddsCaps.dwCaps = (DDSCAPS_BACKBUFFER | DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_FRONTBUFFER | DDSCAPS_LOCALVIDMEM | /*DDSCAPS_NONLOCALVIDMEM |*/
DDSCAPS_OFFSCREENPLAIN | /*DDSCAPS_OVERLAY | DDSCAPS_OWNDC |*/ DDSCAPS_PRIMARYSURFACE | DDSCAPS_VIDEOMEMORY) |
(!Config.DdrawDisableDirect3DCaps ? DDSCAPS_3DDEVICE | DDSCAPS_TEXTURE | DDSCAPS_ZBUFFER | (UseMipMapSupport ? DDSCAPS_MIPMAP : 0) : 0);
(!Config.DdrawDisableDirect3DCaps ? DDSCAPS_3DDEVICE | DDSCAPS_TEXTURE | DDSCAPS_ZBUFFER | DDSCAPS_MIPMAP : 0);
Caps7.ddsCaps.dwCaps2 = (!Config.DdrawDisableDirect3DCaps ? /*DDSCAPS2_CUBEMAP*/ 0 : 0); // Additional surface capabilities
Caps7.ddsCaps.dwCaps3 = 0; // Not used
Caps7.ddsCaps.dwCaps4 = 0; // Not used
Expand Down
1 change: 0 additions & 1 deletion ddraw/ddraw.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ extern DWORD ScaleDDCurrentWidth;
extern DWORD ScaleDDCurrentHeight;
extern DWORD ScaleDDPadX;
extern DWORD ScaleDDPadY;
extern bool UseMipMapSupport;

using namespace DdrawWrapper;

Expand Down

0 comments on commit 5e81e98

Please sign in to comment.