From 3243a17daff0cae11f2f0977bb5a9751fc32c0ce Mon Sep 17 00:00:00 2001 From: narzoul Date: Mon, 29 Aug 2016 21:09:42 +0200 Subject: [PATCH] Moved Direct3D DDI parts to D3dDdi namespace and subdirectory --- DDrawCompat/CompatD3dDdiAdapterCallbacks.cpp | 5 -- DDrawCompat/CompatD3dDdiAdapterCallbacks.h | 11 ---- DDrawCompat/CompatD3dDdiAdapterFuncs.cpp | 22 ------- DDrawCompat/CompatD3dDdiAdapterFuncs.h | 10 --- DDrawCompat/D3dDdi/AdapterCallbacks.cpp | 8 +++ DDrawCompat/D3dDdi/AdapterCallbacks.h | 14 ++++ DDrawCompat/D3dDdi/AdapterFuncs.cpp | 26 ++++++++ DDrawCompat/D3dDdi/AdapterFuncs.h | 13 ++++ .../DeviceCallbacks.cpp} | 7 +- .../DeviceCallbacks.h} | 11 ++-- .../DeviceFuncs.cpp} | 7 +- .../DeviceFuncs.h} | 11 ++-- .../{D3dDdiHooks.cpp => D3dDdi/Hooks.cpp} | 12 ++-- DDrawCompat/{D3dDdiHooks.h => D3dDdi/Hooks.h} | 2 +- DDrawCompat/D3dDdiDeviceCallbacksVisitor.h | 8 +-- DDrawCompat/D3dDdiDeviceFuncsVisitor.h | 10 +-- DDrawCompat/DDrawCompat.vcxproj | 20 +++--- DDrawCompat/DDrawCompat.vcxproj.filters | 66 ++++++++++--------- DDrawCompat/DllMain.cpp | 6 +- 19 files changed, 150 insertions(+), 119 deletions(-) delete mode 100644 DDrawCompat/CompatD3dDdiAdapterCallbacks.cpp delete mode 100644 DDrawCompat/CompatD3dDdiAdapterCallbacks.h delete mode 100644 DDrawCompat/CompatD3dDdiAdapterFuncs.cpp delete mode 100644 DDrawCompat/CompatD3dDdiAdapterFuncs.h create mode 100644 DDrawCompat/D3dDdi/AdapterCallbacks.cpp create mode 100644 DDrawCompat/D3dDdi/AdapterCallbacks.h create mode 100644 DDrawCompat/D3dDdi/AdapterFuncs.cpp create mode 100644 DDrawCompat/D3dDdi/AdapterFuncs.h rename DDrawCompat/{CompatD3dDdiDeviceCallbacks.cpp => D3dDdi/DeviceCallbacks.cpp} (95%) rename DDrawCompat/{CompatD3dDdiDeviceCallbacks.h => D3dDdi/DeviceCallbacks.h} (78%) rename DDrawCompat/{CompatD3dDdiDeviceFuncs.cpp => D3dDdi/DeviceFuncs.cpp} (94%) rename DDrawCompat/{CompatD3dDdiDeviceFuncs.h => D3dDdi/DeviceFuncs.h} (79%) rename DDrawCompat/{D3dDdiHooks.cpp => D3dDdi/Hooks.cpp} (94%) rename DDrawCompat/{D3dDdiHooks.h => D3dDdi/Hooks.h} (79%) diff --git a/DDrawCompat/CompatD3dDdiAdapterCallbacks.cpp b/DDrawCompat/CompatD3dDdiAdapterCallbacks.cpp deleted file mode 100644 index 8ef14c3..0000000 --- a/DDrawCompat/CompatD3dDdiAdapterCallbacks.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "CompatD3dDdiAdapterCallbacks.h" - -void CompatD3dDdiAdapterCallbacks::setCompatVtable(D3DDDI_ADAPTERCALLBACKS& /*vtable*/) -{ -} diff --git a/DDrawCompat/CompatD3dDdiAdapterCallbacks.h b/DDrawCompat/CompatD3dDdiAdapterCallbacks.h deleted file mode 100644 index 4058487..0000000 --- a/DDrawCompat/CompatD3dDdiAdapterCallbacks.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include "CompatVtable.h" -#include "D3dDdiAdapterCallbacksVisitor.h" - -class CompatD3dDdiAdapterCallbacks : - public CompatVtable -{ -public: - static void setCompatVtable(D3DDDI_ADAPTERCALLBACKS& vtable); -}; diff --git a/DDrawCompat/CompatD3dDdiAdapterFuncs.cpp b/DDrawCompat/CompatD3dDdiAdapterFuncs.cpp deleted file mode 100644 index eca9288..0000000 --- a/DDrawCompat/CompatD3dDdiAdapterFuncs.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "CompatD3dDdiAdapterFuncs.h" -#include "CompatD3dDdiDeviceCallbacks.h" -#include "CompatD3dDdiDeviceFuncs.h" - -namespace -{ - HRESULT APIENTRY createDevice(HANDLE hAdapter, D3DDDIARG_CREATEDEVICE* pCreateData) - { - CompatD3dDdiDeviceCallbacks::hookVtable(pCreateData->pCallbacks); - HRESULT result = CompatD3dDdiAdapterFuncs::s_origVtable.pfnCreateDevice(hAdapter, pCreateData); - if (SUCCEEDED(result)) - { - CompatD3dDdiDeviceFuncs::hookVtable(pCreateData->pDeviceFuncs); - } - return result; - } -} - -void CompatD3dDdiAdapterFuncs::setCompatVtable(D3DDDI_ADAPTERFUNCS& vtable) -{ - vtable.pfnCreateDevice = &createDevice; -} diff --git a/DDrawCompat/CompatD3dDdiAdapterFuncs.h b/DDrawCompat/CompatD3dDdiAdapterFuncs.h deleted file mode 100644 index eaa95cd..0000000 --- a/DDrawCompat/CompatD3dDdiAdapterFuncs.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -#include "CompatVtable.h" -#include "D3dDdiAdapterFuncsVisitor.h" - -class CompatD3dDdiAdapterFuncs : public CompatVtable -{ -public: - static void setCompatVtable(D3DDDI_ADAPTERFUNCS& vtable); -}; diff --git a/DDrawCompat/D3dDdi/AdapterCallbacks.cpp b/DDrawCompat/D3dDdi/AdapterCallbacks.cpp new file mode 100644 index 0000000..782ff74 --- /dev/null +++ b/DDrawCompat/D3dDdi/AdapterCallbacks.cpp @@ -0,0 +1,8 @@ +#include "D3dDdi/AdapterCallbacks.h" + +namespace D3dDdi +{ + void AdapterCallbacks::setCompatVtable(D3DDDI_ADAPTERCALLBACKS& /*vtable*/) + { + } +} diff --git a/DDrawCompat/D3dDdi/AdapterCallbacks.h b/DDrawCompat/D3dDdi/AdapterCallbacks.h new file mode 100644 index 0000000..369c8d6 --- /dev/null +++ b/DDrawCompat/D3dDdi/AdapterCallbacks.h @@ -0,0 +1,14 @@ +#pragma once + +#include "CompatVtable.h" +#include "D3dDdiAdapterCallbacksVisitor.h" + +namespace D3dDdi +{ + class AdapterCallbacks : + public CompatVtable + { + public: + static void setCompatVtable(D3DDDI_ADAPTERCALLBACKS& vtable); + }; +} diff --git a/DDrawCompat/D3dDdi/AdapterFuncs.cpp b/DDrawCompat/D3dDdi/AdapterFuncs.cpp new file mode 100644 index 0000000..45ca3b3 --- /dev/null +++ b/DDrawCompat/D3dDdi/AdapterFuncs.cpp @@ -0,0 +1,26 @@ +#include "D3dDdi/AdapterFuncs.h" +#include "D3dDdi/DeviceCallbacks.h" +#include "D3dDdi/DeviceFuncs.h" + +namespace +{ + HRESULT APIENTRY createDevice(HANDLE hAdapter, D3DDDIARG_CREATEDEVICE* pCreateData) + { + D3dDdi::DeviceCallbacks::hookVtable(pCreateData->pCallbacks); + HRESULT result = D3dDdi::AdapterFuncs::s_origVtable.pfnCreateDevice( + hAdapter, pCreateData); + if (SUCCEEDED(result)) + { + D3dDdi::DeviceFuncs::hookVtable(pCreateData->pDeviceFuncs); + } + return result; + } +} + +namespace D3dDdi +{ + void AdapterFuncs::setCompatVtable(D3DDDI_ADAPTERFUNCS& vtable) + { + vtable.pfnCreateDevice = &createDevice; + } +} diff --git a/DDrawCompat/D3dDdi/AdapterFuncs.h b/DDrawCompat/D3dDdi/AdapterFuncs.h new file mode 100644 index 0000000..0c65d18 --- /dev/null +++ b/DDrawCompat/D3dDdi/AdapterFuncs.h @@ -0,0 +1,13 @@ +#pragma once + +#include "CompatVtable.h" +#include "D3dDdiAdapterFuncsVisitor.h" + +namespace D3dDdi +{ + class AdapterFuncs : public CompatVtable + { + public: + static void setCompatVtable(D3DDDI_ADAPTERFUNCS& vtable); + }; +} diff --git a/DDrawCompat/CompatD3dDdiDeviceCallbacks.cpp b/DDrawCompat/D3dDdi/DeviceCallbacks.cpp similarity index 95% rename from DDrawCompat/CompatD3dDdiDeviceCallbacks.cpp rename to DDrawCompat/D3dDdi/DeviceCallbacks.cpp index 6638514..049ea0d 100644 --- a/DDrawCompat/CompatD3dDdiDeviceCallbacks.cpp +++ b/DDrawCompat/D3dDdi/DeviceCallbacks.cpp @@ -3,7 +3,7 @@ #include #include <../km/d3dkmthk.h> -#include "CompatD3dDdiDeviceCallbacks.h" +#include "D3dDdi/DeviceCallbacks.h" #include "DDrawLog.h" #include "Hook.h" @@ -95,6 +95,9 @@ std::ostream& operator<<(std::ostream& os, const D3DDDICB_UNLOCK2& data) << Compat::hex(data.hAllocation); } -void CompatD3dDdiDeviceCallbacks::setCompatVtable(D3DDDI_DEVICECALLBACKS& /*vtable*/) +namespace D3dDdi { + void DeviceCallbacks::setCompatVtable(D3DDDI_DEVICECALLBACKS& /*vtable*/) + { + } } diff --git a/DDrawCompat/CompatD3dDdiDeviceCallbacks.h b/DDrawCompat/D3dDdi/DeviceCallbacks.h similarity index 78% rename from DDrawCompat/CompatD3dDdiDeviceCallbacks.h rename to DDrawCompat/D3dDdi/DeviceCallbacks.h index 0f9c260..7ff07f2 100644 --- a/DDrawCompat/CompatD3dDdiDeviceCallbacks.h +++ b/DDrawCompat/D3dDdi/DeviceCallbacks.h @@ -12,8 +12,11 @@ std::ostream& operator<<(std::ostream& os, const D3DDDICB_LOCK2& data); std::ostream& operator<<(std::ostream& os, const D3DDDICB_UNLOCK& data); std::ostream& operator<<(std::ostream& os, const D3DDDICB_UNLOCK2& data); -class CompatD3dDdiDeviceCallbacks : public CompatVtable +namespace D3dDdi { -public: - static void setCompatVtable(D3DDDI_DEVICECALLBACKS& vtable); -}; + class DeviceCallbacks : public CompatVtable + { + public: + static void setCompatVtable(D3DDDI_DEVICECALLBACKS& vtable); + }; +} diff --git a/DDrawCompat/CompatD3dDdiDeviceFuncs.cpp b/DDrawCompat/D3dDdi/DeviceFuncs.cpp similarity index 94% rename from DDrawCompat/CompatD3dDdiDeviceFuncs.cpp rename to DDrawCompat/D3dDdi/DeviceFuncs.cpp index 95fd517..df60245 100644 --- a/DDrawCompat/CompatD3dDdiDeviceFuncs.cpp +++ b/DDrawCompat/D3dDdi/DeviceFuncs.cpp @@ -1,4 +1,4 @@ -#include "CompatD3dDdiDeviceFuncs.h" +#include "D3dDdi/DeviceFuncs.h" std::ostream& operator<<(std::ostream& os, const D3DDDI_RATIONAL& val) { @@ -99,6 +99,9 @@ std::ostream& operator<<(std::ostream& os, const D3DDDIBOX& box) << box.Back; } -void CompatD3dDdiDeviceFuncs::setCompatVtable(D3DDDI_DEVICEFUNCS& /*vtable*/) +namespace D3dDdi { + void DeviceFuncs::setCompatVtable(D3DDDI_DEVICEFUNCS& /*vtable*/) + { + } } diff --git a/DDrawCompat/CompatD3dDdiDeviceFuncs.h b/DDrawCompat/D3dDdi/DeviceFuncs.h similarity index 79% rename from DDrawCompat/CompatD3dDdiDeviceFuncs.h rename to DDrawCompat/D3dDdi/DeviceFuncs.h index af68244..df5a314 100644 --- a/DDrawCompat/CompatD3dDdiDeviceFuncs.h +++ b/DDrawCompat/D3dDdi/DeviceFuncs.h @@ -12,8 +12,11 @@ std::ostream& operator<<(std::ostream& os, const D3DDDIARG_OPENRESOURCE& val); std::ostream& operator<<(std::ostream& os, const D3DDDIARG_UNLOCK& val); std::ostream& operator<<(std::ostream& os, const D3DDDIBOX& val); -class CompatD3dDdiDeviceFuncs : public CompatVtable +namespace D3dDdi { -public: - static void setCompatVtable(D3DDDI_DEVICEFUNCS& vtable); -}; + class DeviceFuncs : public CompatVtable + { + public: + static void setCompatVtable(D3DDDI_DEVICEFUNCS& vtable); + }; +} diff --git a/DDrawCompat/D3dDdiHooks.cpp b/DDrawCompat/D3dDdi/Hooks.cpp similarity index 94% rename from DDrawCompat/D3dDdiHooks.cpp rename to DDrawCompat/D3dDdi/Hooks.cpp index ff30c8c..0bf8df1 100644 --- a/DDrawCompat/D3dDdiHooks.cpp +++ b/DDrawCompat/D3dDdi/Hooks.cpp @@ -5,8 +5,8 @@ #include #include <..\km\d3dkmthk.h> -#include "CompatD3dDdiAdapterCallbacks.h" -#include "CompatD3dDdiAdapterFuncs.h" +#include "D3dDdi/AdapterCallbacks.h" +#include "D3dDdi/AdapterFuncs.h" #include "DDrawLog.h" #include "Hook.h" @@ -114,12 +114,12 @@ namespace HRESULT APIENTRY openAdapter(D3DDDIARG_OPENADAPTER* pOpenData) { Compat::LogEnter("openAdapter", pOpenData); - CompatD3dDdiAdapterCallbacks::hookVtable(pOpenData->pAdapterCallbacks); + D3dDdi::AdapterCallbacks::hookVtable(pOpenData->pAdapterCallbacks); HRESULT result = CALL_ORIG_FUNC(OpenAdapter)(pOpenData); if (SUCCEEDED(result)) { g_ddiVersion = min(pOpenData->Version, pOpenData->DriverVersion); - CompatD3dDdiAdapterFuncs::hookVtable(pOpenData->pAdapterFuncs); + D3dDdi::AdapterFuncs::hookVtable(pOpenData->pAdapterFuncs); } Compat::LogLeave("openAdapter", pOpenData) << result; return result; @@ -139,7 +139,7 @@ namespace } } -namespace D3dDdiHooks +namespace D3dDdi { UINT getDdiVersion() { @@ -154,7 +154,7 @@ namespace D3dDdiHooks { Compat::Log() << "Failed to load the primary display driver library"; } - + char umdFileName[MAX_PATH] = {}; wcstombs_s(nullptr, umdFileName, primaryUmd.UmdFileName, _TRUNCATE); Compat::hookFunction( diff --git a/DDrawCompat/D3dDdiHooks.h b/DDrawCompat/D3dDdi/Hooks.h similarity index 79% rename from DDrawCompat/D3dDdiHooks.h rename to DDrawCompat/D3dDdi/Hooks.h index d3cb7ac..8c7ab30 100644 --- a/DDrawCompat/D3dDdiHooks.h +++ b/DDrawCompat/D3dDdi/Hooks.h @@ -1,6 +1,6 @@ #pragma once -namespace D3dDdiHooks +namespace D3dDdi { UINT getDdiVersion(); void installHooks(); diff --git a/DDrawCompat/D3dDdiDeviceCallbacksVisitor.h b/DDrawCompat/D3dDdiDeviceCallbacksVisitor.h index cd82406..54b24db 100644 --- a/DDrawCompat/D3dDdiDeviceCallbacksVisitor.h +++ b/DDrawCompat/D3dDdiDeviceCallbacksVisitor.h @@ -5,7 +5,7 @@ #include #include -#include "D3dDdiHooks.h" +#include "D3dDdi/Hooks.h" #include "DDrawVtableVisitor.h" struct D3dDdiDeviceCallbacksIntf @@ -42,7 +42,7 @@ struct DDrawVtableForEach // DD_VISIT(pfnSetAsyncCallbacksCb); -- not set by ddraw DD_VISIT(pfnSetDisplayPrivateDriverFormatCb); - if (D3dDdiHooks::getDdiVersion() >= D3D_UMD_INTERFACE_VERSION_WIN8) + if (D3dDdi::getDdiVersion() >= D3D_UMD_INTERFACE_VERSION_WIN8) { DD_VISIT(pfnOfferAllocationsCb); DD_VISIT(pfnReclaimAllocationsCb); @@ -52,12 +52,12 @@ struct DDrawVtableForEach // DD_VISIT(pfnPresentMultiPlaneOverlayCb); -- not set by ddraw } - if (D3dDdiHooks::getDdiVersion() >= D3D_UMD_INTERFACE_VERSION_WDDM1_3) + if (D3dDdi::getDdiVersion() >= D3D_UMD_INTERFACE_VERSION_WDDM1_3) { // DD_VISIT(pfnLogUMDMarkerCb); -- not set by ddraw } - if (D3dDdiHooks::getDdiVersion() >= D3D_UMD_INTERFACE_VERSION_WDDM2_0) + if (D3dDdi::getDdiVersion() >= D3D_UMD_INTERFACE_VERSION_WDDM2_0) { DD_VISIT(pfnMakeResidentCb); DD_VISIT(pfnEvictCb); diff --git a/DDrawCompat/D3dDdiDeviceFuncsVisitor.h b/DDrawCompat/D3dDdiDeviceFuncsVisitor.h index 39df6de..4c6b6be 100644 --- a/DDrawCompat/D3dDdiDeviceFuncsVisitor.h +++ b/DDrawCompat/D3dDdiDeviceFuncsVisitor.h @@ -5,7 +5,7 @@ #include #include -#include "D3dDdiHooks.h" +#include "D3dDdi/Hooks.h" #include "DDrawVtableVisitor.h" struct D3dDdiDeviceFuncsIntf @@ -119,7 +119,7 @@ struct DDrawVtableForEach DD_VISIT(pfnUnlockAsync); DD_VISIT(pfnRename); - if (D3dDdiHooks::getDdiVersion() >= D3D_UMD_INTERFACE_VERSION_WIN7) + if (D3dDdi::getDdiVersion() >= D3D_UMD_INTERFACE_VERSION_WIN7) { DD_VISIT(pfnCreateVideoProcessor); DD_VISIT(pfnSetVideoProcessBltState); @@ -145,7 +145,7 @@ struct DDrawVtableForEach DD_VISIT(pfnResolveSharedResource); } - if (D3dDdiHooks::getDdiVersion() >= D3D_UMD_INTERFACE_VERSION_WIN8) + if (D3dDdi::getDdiVersion() >= D3D_UMD_INTERFACE_VERSION_WIN8) { DD_VISIT(pfnVolBlt1); DD_VISIT(pfnBufBlt1); @@ -159,7 +159,7 @@ struct DDrawVtableForEach DD_VISIT(pfnPresentMultiPlaneOverlay); } - if (D3dDdiHooks::getDdiVersion() >= D3D_UMD_INTERFACE_VERSION_WDDM1_3) + if (D3dDdi::getDdiVersion() >= D3D_UMD_INTERFACE_VERSION_WDDM1_3) { // DD_VISIT(pfnReserved1); -- unused DD_VISIT(pfnFlush1); @@ -173,7 +173,7 @@ struct DDrawVtableForEach DD_VISIT(pfnSetMarkerMode); } - if (D3dDdiHooks::getDdiVersion() >= D3D_UMD_INTERFACE_VERSION_WDDM2_0) + if (D3dDdi::getDdiVersion() >= D3D_UMD_INTERFACE_VERSION_WDDM2_0) { DD_VISIT(pfnTrimResidencySet); } diff --git a/DDrawCompat/DDrawCompat.vcxproj b/DDrawCompat/DDrawCompat.vcxproj index 3539404..e765524 100644 --- a/DDrawCompat/DDrawCompat.vcxproj +++ b/DDrawCompat/DDrawCompat.vcxproj @@ -149,10 +149,6 @@ - - - - @@ -166,7 +162,11 @@ - + + + + + @@ -208,14 +208,14 @@ - - - - - + + + + + diff --git a/DDrawCompat/DDrawCompat.vcxproj.filters b/DDrawCompat/DDrawCompat.vcxproj.filters index b72434c..fdc8ca3 100644 --- a/DDrawCompat/DDrawCompat.vcxproj.filters +++ b/DDrawCompat/DDrawCompat.vcxproj.filters @@ -31,6 +31,12 @@ {08a23b36-cd96-4214-985b-0473ecf6ecab} + + {10719dd2-f68b-4f6c-82b1-3e3bd8def099} + + + {9c81f8c4-c564-49f2-b66f-c051d332d6a0} + @@ -102,21 +108,6 @@ Header Files - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - Header Files\Gdi @@ -204,6 +195,21 @@ Header Files\Direct3d + + Header Files\D3dDdi + + + Header Files\D3dDdi + + + Header Files\D3dDdi + + + Header Files\D3dDdi + + + Header Files\D3dDdi + @@ -233,21 +239,6 @@ Source Files - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - Source Files\Gdi @@ -323,6 +314,21 @@ Source Files\Direct3d + + Source Files\D3dDdi + + + Source Files\D3dDdi + + + Source Files\D3dDdi + + + Source Files\D3dDdi + + + Source Files\D3dDdi + diff --git a/DDrawCompat/DllMain.cpp b/DDrawCompat/DllMain.cpp index 93f122d..915b759 100644 --- a/DDrawCompat/DllMain.cpp +++ b/DDrawCompat/DllMain.cpp @@ -8,7 +8,7 @@ #include "CompatFontSmoothing.h" #include "CompatHooks.h" #include "CompatRegistry.h" -#include "D3dDdiHooks.h" +#include "D3dDdi/Hooks.h" #include "DDraw/DisplayMode.h" #include "DDraw/Hooks.h" #include "DDrawProcs.h" @@ -29,7 +29,7 @@ namespace if (!isAlreadyInstalled) { Compat::Log() << "Installing Direct3D driver hooks"; - D3dDdiHooks::installHooks(); + D3dDdi::installHooks(); Compat::Log() << "Installing DirectDraw hooks"; DDraw::installHooks(); Compat::Log() << "Installing Direct3D hooks"; @@ -139,7 +139,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID /*lpvReserved*/) { Compat::Log() << "Detaching DDrawCompat"; DDraw::uninstallHooks(); - D3dDdiHooks::uninstallHooks(); + D3dDdi::uninstallHooks(); Gdi::uninstallHooks(); Compat::unhookAllFunctions(); FreeLibrary(g_origDInputModule);