Skip to content

Commit

Permalink
Revert some of last check-ins
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud committed Mar 24, 2024
1 parent 53b7309 commit d738036
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 47 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 6978
#define BUILD_NUMBER 6979
7 changes: 5 additions & 2 deletions ddraw/IDirect3DDeviceX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2230,6 +2230,9 @@ HRESULT m_IDirect3DDeviceX::SetRenderState(D3DRENDERSTATETYPE dwRenderStateType,
case D3DRENDERSTATE_SRCBLEND:
rsSrcBlend = dwRenderState;
break;
case D3DRENDERSTATE_DESTBLEND:
rsDestBlend = dwRenderState;
break;
case D3DRENDERSTATE_COLORKEYENABLE:
rsColorKeyEnabled = dwRenderState;
return D3D_OK;
Expand Down Expand Up @@ -3359,11 +3362,11 @@ inline void m_IDirect3DDeviceX::UpdateDrawFlags(DWORD& dwFlags)
// You can use D3DRENDERSTATE_COLORKEYENABLE render state with D3DRENDERSTATE_ALPHABLENDENABLE to implement fine blending control.
if (rsColorKeyEnabled && rsAlphaBlendEnabled)
{
LOG_LIMIT(100, __FUNCTION__ << " Warning: mixing color keying with alpha blending is not implemented: " << rsSrcBlend);
LOG_LIMIT(100, __FUNCTION__ << " Warning: mixing color keying with alpha blending is not implemented: " << rsSrcBlend << " " << rsDestBlend);
}

// Check for color key
if (rsColorKeyEnabled && !(rsAlphaBlendEnabled && rsSrcBlend == D3DBLEND_ONE) &&
if (rsColorKeyEnabled && !(rsAlphaBlendEnabled && (rsSrcBlend == D3DBLEND_ONE || rsSrcBlend == D3DBLEND_SRCALPHA)) &&
CurrentTextureSurfaceX && CurrentTextureSurfaceX->GetColorKeyForShader(DrawStates.lowColorKey, DrawStates.highColorKey))
{
dwFlags |= D3DDP_DXW_COLORKEYENABLE;
Expand Down
1 change: 1 addition & 0 deletions ddraw/IDirect3DDeviceX.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class m_IDirect3DDeviceX : public IUnknown, public AddressLookupTableDdrawObject
// Render states
DWORD rsAlphaBlendEnabled = FALSE;
DWORD rsSrcBlend = 0;
DWORD rsDestBlend = 0;
DWORD rsColorKeyEnabled = FALSE;

// SetTexture array
Expand Down
46 changes: 4 additions & 42 deletions ddraw/IDirectDrawSurfaceX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1762,11 +1762,6 @@ bool m_IDirectDrawSurfaceX::GetColorKeyForPrimaryShader(float(&lowColorKey)[4],

bool m_IDirectDrawSurfaceX::GetColorKeyForShader(float(&lowColorKey)[4], float(&highColorKey)[4])
{
if (!ShaderColorKey.IsCreatedWithColorKey)
{
return false;
}

// Surface low and high color space
if (!ShaderColorKey.IsSet)
{
Expand Down Expand Up @@ -2345,27 +2340,12 @@ HRESULT m_IDirectDrawSurfaceX::Lock2(LPRECT lpDestRect, LPDDSURFACEDESC2 lpDDSur
HRESULT ret = LockD39Surface(&LockedRect, &DestRect, Flags);
if (FAILED(ret))
{
// If surface is locked already with null rect
if (IsSurfaceLocked() && LockRectList.empty())
if (IsSurfaceLocked())
{
if (!LastLock.LockedRect.pBits || !LastLock.LockedRect.Pitch)
{
LOG_LIMIT(100, __FUNCTION__ << " Error: could not get last lock data!");
}
LockedRect.pBits = LastLock.LockedRect.pBits;
LockedRect.Pitch = LastLock.LockedRect.Pitch;
ret = DD_OK;
}
// If surface is locked with specific rect
else
{
if (IsSurfaceLocked())
{
LOG_LIMIT(100, __FUNCTION__ << " Warning: attempting to lock surface twice!");
}
UnlockD39Surface();
ret = LockD39Surface(&LockedRect, &DestRect, Flags);
LOG_LIMIT(100, __FUNCTION__ << " Warning: attempting to lock surface twice!");
}
UnlockD39Surface();
ret = LockD39Surface(&LockedRect, &DestRect, Flags);
}
if (FAILED(ret))
{
Expand Down Expand Up @@ -2407,10 +2387,6 @@ HRESULT m_IDirectDrawSurfaceX::Lock2(LPRECT lpDestRect, LPDDSURFACEDESC2 lpDDSur
RECT lRect = { lpDestRect->left, lpDestRect->top, lpDestRect->right, lpDestRect->bottom };
LockRectList.push_back(lRect);
}
else
{
LockedCount++;
}

// Set surfaceDesc
if (!(lpDDSurfaceDesc2->dwFlags & DDSD_LPSURFACE))
Expand Down Expand Up @@ -2876,14 +2852,6 @@ HRESULT m_IDirectDrawSurfaceX::Unlock(LPRECT lpRect)
}
}

// Check if locked more than once with null rect
if (LockedCount > 1)
{
LockedCount--;
hr = DD_OK;
break;
}

// Check for device interface
HRESULT c_hr = CheckInterface(__FUNCTION__, true, true, true);
if (FAILED(c_hr))
Expand Down Expand Up @@ -4827,12 +4795,6 @@ inline void m_IDirectDrawSurfaceX::InitSurfaceDesc(DWORD DirectXVersion)
surfaceDesc2.ddsCaps.dwCaps &= ~DDSCAPS_NONLOCALVIDMEM;
}

// Note: any textures that were not created with the DDSD_CKSRCBLT flag will not display color-key effects, even if they contain the color key
if (surfaceDesc2.dwFlags & DDSD_CKSRCBLT)
{
ShaderColorKey.IsCreatedWithColorKey = true;
}

// Create backbuffers
if (surfaceDesc2.dwBackBufferCount)
{
Expand Down
2 changes: 0 additions & 2 deletions ddraw/IDirectDrawSurfaceX.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class m_IDirectDrawSurfaceX : public IUnknown, public AddressLookupTableDdrawObj
struct COLORKEY
{
bool IsSet = false;
bool IsCreatedWithColorKey = false;
float lowColorKey[4] = {};
float highColorKey[4] = {};
};
Expand Down Expand Up @@ -136,7 +135,6 @@ class m_IDirectDrawSurfaceX : public IUnknown, public AddressLookupTableDdrawObj
bool IsInBlt = false;
bool IsInBltBatch = false;
bool IsLocked = false;
DWORD LockedCount = 0; // Counts the number of null rect locks happen
DWORD LockedWithID = 0; // Thread ID of the current lock
LASTLOCK LastLock; // Remember the last lock info
std::vector<RECT> LockRectList; // Rects used to lock the surface
Expand Down

0 comments on commit d738036

Please sign in to comment.