Skip to content

Commit

Permalink
Rename a few D9 functions
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud committed Sep 29, 2024
1 parent 32a9a75 commit dba6f7a
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 45 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 7217
#define BUILD_NUMBER 7218
6 changes: 3 additions & 3 deletions ddraw/IDirect3DDeviceX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ HRESULT m_IDirect3DDeviceX::EnumTextureFormats(LPD3DENUMPIXELFORMATSCALLBACK lpd
return DDERR_INVALIDOBJECT;
}

LPDIRECT3D9 d3d9Object = ddrawParent->GetDirect3D9Object();
LPDIRECT3D9 d3d9Object = ddrawParent->GetDirectD9Object();

if (!d3d9Object)
{
Expand Down Expand Up @@ -4218,7 +4218,7 @@ void m_IDirect3DDeviceX::InitDevice(DWORD DirectXVersion)

if (ddrawParent)
{
d3d9Device = ddrawParent->GetDirect3D9Device();
d3d9Device = ddrawParent->GetDirectD9Device();
ddrawParent->SetD3DDevice(this);

if (CurrentRenderTarget)
Expand Down Expand Up @@ -4275,7 +4275,7 @@ HRESULT m_IDirect3DDeviceX::CheckInterface(char *FunctionName, bool CheckD3DDevi
// Check d3d9 device
if (CheckD3DDevice)
{
if (!ddrawParent->CheckD3D9Device() || !d3d9Device || !*d3d9Device)
if (!ddrawParent->CheckD9Device() || !d3d9Device || !*d3d9Device)
{
LOG_LIMIT(100, FunctionName << " Error: d3d9 device not setup!");
return DDERR_INVALIDOBJECT;
Expand Down
4 changes: 2 additions & 2 deletions ddraw/IDirect3DVertexBufferX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ void m_IDirect3DVertexBufferX::InitVertexBuffer(DWORD DirectXVersion)
{
ddrawParent->AddVertexBufferToVector(this);

d3d9Device = ddrawParent->GetDirect3D9Device();
d3d9Device = ddrawParent->GetDirectD9Device();
}

AddRef(DirectXVersion);
Expand Down Expand Up @@ -587,7 +587,7 @@ HRESULT m_IDirect3DVertexBufferX::CheckInterface(char* FunctionName, bool CheckD
// Check d3d9 device
if (CheckD3DDevice)
{
if (!ddrawParent->CheckD3D9Device() || !d3d9Device || !*d3d9Device)
if (!ddrawParent->CheckD9Device() || !d3d9Device || !*d3d9Device)
{
LOG_LIMIT(100, FunctionName << " Error: d3d9 device not setup!");
return DDERR_INVALIDOBJECT;
Expand Down
4 changes: 2 additions & 2 deletions ddraw/IDirect3DX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ void m_IDirect3DX::GetCap9Cache()
if (ddrawParent)
{
// Get d3d9Object
IDirect3D9* d3d9Object = ddrawParent->GetDirect3D9Object();
IDirect3D9* d3d9Object = ddrawParent->GetDirectD9Object();
if (d3d9Object)
{
UINT AdapterCount = d3d9Object->GetAdapterCount();
Expand Down Expand Up @@ -786,7 +786,7 @@ HRESULT m_IDirect3DX::EnumZBufferFormats(REFCLSID riidDevice, LPD3DENUMPIXELFORM
}

// Get d3d9Object
IDirect3D9 *d3d9Object = ddrawParent->GetDirect3D9Object();
IDirect3D9 *d3d9Object = ddrawParent->GetDirectD9Object();

if (riidDevice == IID_IDirect3DRGBDevice || riidDevice == IID_IDirect3DMMXDevice || riidDevice == IID_IDirect3DRefDevice ||
riidDevice == IID_IDirect3DHALDevice || riidDevice == IID_IDirect3DTnLHalDevice)
Expand Down
4 changes: 2 additions & 2 deletions ddraw/IDirectDrawSurfaceX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3952,7 +3952,7 @@ void m_IDirectDrawSurfaceX::InitSurface(DWORD DirectXVersion)
{
ddrawParent->AddSurfaceToVector(this);

d3d9Device = ddrawParent->GetDirect3D9Device();
d3d9Device = ddrawParent->GetDirectD9Device();
}

// Set Uniqueness Value
Expand Down Expand Up @@ -4240,7 +4240,7 @@ HRESULT m_IDirectDrawSurfaceX::CheckInterface(char *FunctionName, bool CheckD3DD
// Check d3d9 device
if (CheckD3DDevice)
{
if (!ddrawParent->CheckD3D9Device() || !d3d9Device || !*d3d9Device)
if (!ddrawParent->CheckD9Device() || !d3d9Device || !*d3d9Device)
{
LOG_LIMIT(100, FunctionName << " Error: d3d9 device not setup!");
return DDERR_INVALIDOBJECT;
Expand Down
52 changes: 26 additions & 26 deletions ddraw/IDirectDrawX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1610,7 +1610,7 @@ HRESULT m_IDirectDrawX::RestoreDisplayMode()
if (d3d9Device)
{
ReleaseAllD9Resources(true, false);
ReleaseD3D9Device();
ReleaseD9Device();
}

return DD_OK;
Expand Down Expand Up @@ -1733,7 +1733,7 @@ HRESULT m_IDirectDrawX::SetCooperativeLevel(HWND hWnd, DWORD dwFlags, DWORD Dire
if ((dwFlags & (DDSCL_NORMAL | DDSCL_EXCLUSIVE)) && (d3d9Device || LastUsedHWnd == DisplayMode.hWnd) &&
(LastExclusiveMode != ExclusiveMode || LasthWnd != DisplayMode.hWnd || LastFPUPreserve != Device.FPUPreserve))
{
CreateD3D9Device();
CreateD9Device();
}
}

Expand Down Expand Up @@ -1934,7 +1934,7 @@ HRESULT m_IDirectDrawX::SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBP
SetResolution = ExclusiveMode;

// Reset d3d9 device
CreateD3D9Device();
CreateD9Device();
}
else if (LastBPP != DisplayMode.BPP)
{
Expand Down Expand Up @@ -2656,13 +2656,13 @@ void m_IDirectDrawX::ReleaseDdraw()
// Release d3d9device
if (d3d9Device)
{
ReleaseD3D9Device();
ReleaseD9Device();
}

// Release d3d9object
if (d3d9Object)
{
ReleaseD3D9Object();
ReleaseD9Object();
}

// Close DDI
Expand Down Expand Up @@ -2786,7 +2786,7 @@ HRESULT m_IDirectDrawX::CheckInterface(char *FunctionName, bool CheckD3DDevice)
if (!d3d9Object)
{
// Create d3d9 object
if (FAILED(CreateD3D9Object()))
if (FAILED(CreateD9Object()))
{
LOG_LIMIT(100, FunctionName << " Error: d3d9 object not setup!");
return DDERR_GENERIC;
Expand All @@ -2797,7 +2797,7 @@ HRESULT m_IDirectDrawX::CheckInterface(char *FunctionName, bool CheckD3DDevice)
if (CheckD3DDevice && !d3d9Device)
{
// Create d3d9 device
if (FAILED(CreateD3D9Device()))
if (FAILED(CreateD9Device()))
{
LOG_LIMIT(100, FunctionName << " Error: d3d9 device not setup!");
return DDERR_GENERIC;
Expand All @@ -2822,21 +2822,21 @@ bool m_IDirectDrawX::IsInScene()
return (D3DDeviceInterface && D3DDeviceInterface->IsDeviceInScene());
}

bool m_IDirectDrawX::CheckD3D9Device()
bool m_IDirectDrawX::CheckD9Device()
{
if (!d3d9Device && FAILED(CreateD3D9Device()))
if (!d3d9Device && FAILED(CreateD9Device()))
{
return false;
}
return true;
}

LPDIRECT3D9 m_IDirectDrawX::GetDirect3D9Object()
LPDIRECT3D9 m_IDirectDrawX::GetDirectD9Object()
{
return d3d9Object;
}

LPDIRECT3DDEVICE9* m_IDirectDrawX::GetDirect3D9Device()
LPDIRECT3DDEVICE9* m_IDirectDrawX::GetDirectD9Device()
{
return &d3d9Device;
}
Expand Down Expand Up @@ -2924,7 +2924,7 @@ D3DMULTISAMPLE_TYPE m_IDirectDrawX::GetMultiSampleTypeQuality(D3DFORMAT Format,
}

// Creates or resets the d3d9 device
HRESULT m_IDirectDrawX::CreateD3D9Device()
HRESULT m_IDirectDrawX::CreateD9Device()
{
// Check for device interface
if (FAILED(CheckInterface(__FUNCTION__, false)))
Expand Down Expand Up @@ -3102,7 +3102,7 @@ HRESULT m_IDirectDrawX::CreateD3D9Device()
" BehaviorFlags: " << Logging::hex(LastBehaviorFlags) << "->" << Logging::hex(BehaviorFlags);

ReleaseAllD9Resources(false, false); // Cannot backup surface after a failed reset
ReleaseD3D9Device();
ReleaseD9Device();
}
}
// Release existing device
Expand All @@ -3113,7 +3113,7 @@ HRESULT m_IDirectDrawX::CreateD3D9Device()
Logging::hex(LastBehaviorFlags) << "->" << Logging::hex(BehaviorFlags);

ReleaseAllD9Resources(true, false);
ReleaseD3D9Device();
ReleaseD9Device();
}
}

Expand Down Expand Up @@ -3375,7 +3375,7 @@ HRESULT m_IDirectDrawX::CreateVertexBuffer(DWORD Width, DWORD Height)
}

// Creates d3d9 object
HRESULT m_IDirectDrawX::CreateD3D9Object()
HRESULT m_IDirectDrawX::CreateD9Object()
{
// Create d3d9 object
if (!d3d9Object)
Expand Down Expand Up @@ -3468,15 +3468,15 @@ HRESULT m_IDirectDrawX::ReinitDevice()
{
LOG_LIMIT(100, __FUNCTION__ << " Error: Reset failed! " << (D3DERR)hr);
ReleaseAllD9Resources(false, false); // Cannot backup surface after a failed reset
ReleaseD3D9Device();
hr = CreateD3D9Device();
ReleaseD9Device();
hr = CreateD9Device();
}
}
else
{
ReleaseAllD9Resources(true, false);
ReleaseD3D9Device();
hr = CreateD3D9Device();
ReleaseD9Device();
hr = CreateD9Device();
}

// Check if reset device failed
Expand Down Expand Up @@ -3619,7 +3619,7 @@ HRESULT m_IDirectDrawX::SetDepthStencilSurface(m_IDirectDrawSurfaceX* lpSurface)
return hr;
}

void m_IDirectDrawX::Release3DForAllSurfaces()
void m_IDirectDrawX::Clear3DFlagForAllSurfaces()
{
SetCriticalSection();

Expand Down Expand Up @@ -3656,7 +3656,7 @@ inline void m_IDirectDrawX::ReleaseAllD9Resources(bool BackupData, bool ResetInt
SetPTCriticalSection();

// Remove render target and depth stencil surfaces
if (d3d9Device && BackupData && (RenderTargetSurface || DepthStencilSurface))
if (d3d9Device && ResetInterface && (RenderTargetSurface || DepthStencilSurface))
{
SetRenderTargetSurface(nullptr);
}
Expand Down Expand Up @@ -3725,7 +3725,7 @@ inline void m_IDirectDrawX::ReleaseAllD9Resources(bool BackupData, bool ResetInt
if (palettePixelShader)
{
Logging::LogDebug() << __FUNCTION__ << " Releasing Direct3D9 palette pixel shader";
if (d3d9Device && BackupData)
if (d3d9Device && ResetInterface)
{
d3d9Device->SetPixelShader(nullptr);
}
Expand All @@ -3741,7 +3741,7 @@ inline void m_IDirectDrawX::ReleaseAllD9Resources(bool BackupData, bool ResetInt
if (colorkeyPixelShader)
{
Logging::LogDebug() << __FUNCTION__ << " Releasing Direct3D9 color key pixel shader";
if (d3d9Device && BackupData)
if (d3d9Device && ResetInterface)
{
d3d9Device->SetPixelShader(nullptr);
}
Expand All @@ -3758,7 +3758,7 @@ inline void m_IDirectDrawX::ReleaseAllD9Resources(bool BackupData, bool ResetInt
}

// Release d3d9 device
void m_IDirectDrawX::ReleaseD3D9Device()
void m_IDirectDrawX::ReleaseD9Device()
{
SetCriticalSection();
SetPTCriticalSection();
Expand All @@ -3785,7 +3785,7 @@ void m_IDirectDrawX::ReleaseD3D9Device()
}

// Release d3d9 object
void m_IDirectDrawX::ReleaseD3D9Object()
void m_IDirectDrawX::ReleaseD9Object()
{
if (d3d9Object)
{
Expand Down Expand Up @@ -4155,7 +4155,7 @@ HRESULT m_IDirectDrawX::SetClipperHWnd(HWND hWnd)
}
if (!DisplayMode.hWnd && ClipperHWnd && ClipperHWnd != OldClipperHWnd)
{
return CreateD3D9Device();
return CreateD9Device();
}
}
return DD_OK;
Expand Down
18 changes: 9 additions & 9 deletions ddraw/IDirectDrawX.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ class m_IDirectDrawX : public IUnknown, public AddressLookupTableDdrawObject

// Direct3D9 interface functions
HRESULT CheckInterface(char *FunctionName, bool CheckD3DDevice);
HRESULT CreateD3D9Object();
void Release3DForAllSurfaces();
HRESULT CreateD9Object();
void Clear3DFlagForAllSurfaces();
void ResetAllSurfaceDisplay();
void ReleaseAllD9Resources(bool BackupData, bool ResetInterface);
void ReleaseD3D9Device();
void ReleaseD3D9Object();
void ReleaseD9Device();
void ReleaseD9Object();

public:
m_IDirectDrawX(IDirectDraw7 *aOriginal, DWORD DirectXVersion) : ProxyInterface(aOriginal)
Expand Down Expand Up @@ -177,21 +177,21 @@ class m_IDirectDrawX : public IUnknown, public AddressLookupTableDdrawObject
inline void ClearD3D() { D3DInterface = nullptr; }
void SetD3DDevice(m_IDirect3DDeviceX* D3DDevice);
inline m_IDirect3DDeviceX** GetCurrentD3DDevice() { return &D3DDeviceInterface; }
inline void ClearD3DDevice() { Using3D = false; D3DDeviceInterface = nullptr; SetRenderTargetSurface(nullptr); Release3DForAllSurfaces(); }
inline void ClearD3DDevice() { Using3D = false; D3DDeviceInterface = nullptr; SetRenderTargetSurface(nullptr); Clear3DFlagForAllSurfaces(); }
inline void Enable3D() { Using3D = true; }
inline bool IsUsing3D() { return Using3D; }
inline bool IsPrimaryRenderTarget() { return PrimarySurface ? PrimarySurface->IsRenderTarget() : false; }
bool IsInScene();

// Direct3D9 interfaces
bool CheckD3D9Device();
LPDIRECT3D9 GetDirect3D9Object();
LPDIRECT3DDEVICE9 *GetDirect3D9Device();
bool CheckD9Device();
LPDIRECT3D9 GetDirectD9Object();
LPDIRECT3DDEVICE9 *GetDirectD9Device();
bool CreatePaletteShader();
LPDIRECT3DPIXELSHADER9* GetColorKeyShader();
LPDIRECT3DVERTEXBUFFER9 GetValidateDeviceVertexBuffer(DWORD& FVF, DWORD& Size);
D3DMULTISAMPLE_TYPE GetMultiSampleTypeQuality(D3DFORMAT Format, DWORD MaxSampleType, DWORD& QualityLevels);
HRESULT CreateD3D9Device();
HRESULT CreateD9Device();
HRESULT CreateVertexBuffer(DWORD Width, DWORD Height);
HRESULT ReinitDevice();
HRESULT TestD3D9CooperativeLevel();
Expand Down

0 comments on commit dba6f7a

Please sign in to comment.