Skip to content

Commit

Permalink
Remove CheckSurfaceExists() on SetTexture()
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud committed Sep 13, 2024
1 parent 5f9cfbb commit 93e5b6e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 9 additions & 7 deletions ddraw/IDirect3DDeviceX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,10 @@ HRESULT m_IDirect3DDeviceX::SetTexture(DWORD dwStage, LPDIRECTDRAWSURFACE7 lpSur
return DDERR_INVALIDOBJECT;
}

#ifdef ENABLE_PROFILING
auto startTime = std::chrono::high_resolution_clock::now();
#endif

m_IDirectDrawSurfaceX* lpDDSrcSurfaceX = nullptr;

HRESULT hr;
Expand All @@ -932,12 +936,6 @@ HRESULT m_IDirect3DDeviceX::SetTexture(DWORD dwStage, LPDIRECTDRAWSURFACE7 lpSur
}
else
{
if (!CheckSurfaceExists(lpSurface))
{
LOG_LIMIT(100, __FUNCTION__ << " Error: could not find source surface! " << lpSurface);
return DDERR_INVALIDPARAMS;
}

lpSurface->QueryInterface(IID_GetInterfaceX, (LPVOID*)&lpDDSrcSurfaceX);
if (!lpDDSrcSurfaceX)
{
Expand All @@ -961,6 +959,10 @@ HRESULT m_IDirect3DDeviceX::SetTexture(DWORD dwStage, LPDIRECTDRAWSURFACE7 lpSur
CurrentTextureSurfaceX[dwStage] = lpDDSrcSurfaceX;
}

#ifdef ENABLE_PROFILING
Logging::Log() << __FUNCTION__ << " (" << this << ") hr = " << (D3DERR)hr << " Timing = " << Logging::GetTimeLapseInMS(startTime);
#endif

return hr;
}

Expand All @@ -978,7 +980,7 @@ HRESULT m_IDirect3DDeviceX::SetRenderTarget(LPDIRECTDRAWSURFACE7 lpNewRenderTarg

if (Config.Dd7to9)
{
if (!lpNewRenderTarget || !CheckSurfaceExists(lpNewRenderTarget))
if (!lpNewRenderTarget)
{
return DDERR_INVALIDPARAMS;
}
Expand Down
2 changes: 1 addition & 1 deletion ddraw/IDirectDrawX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4541,7 +4541,7 @@ HRESULT m_IDirectDrawX::Present(RECT* pSourceRect, RECT* pDestRect)
}

// Use WaitForVerticalBlank for wait timer
if (EnableWaitVsync && !Config.EnableVSync && !Config.ForceVsyncMode && !IsUsing3D())
if (EnableWaitVsync && !Config.EnableVSync && !Config.ForceVsyncMode)
{
// Check how long since the last successful present
LARGE_INTEGER ClickTime = {};
Expand Down

0 comments on commit 93e5b6e

Please sign in to comment.