Revert "[Win] Call CompareObjectHandles directly"
This reverts commit 80906a48e38c4d549764f8159645c340e9c6844f.
Reason for revert: this is breaking the roll into Chromium with this linker error:
lld-link: error: could not open 'onecore_apiset.lib': No such file or directory
Example failing roll:
https://chromium-review.googlesource.com/c/chromium/src/+/6681536
Original change's description:
> [Win] Call CompareObjectHandles directly
>
> Now that Chromium only supports Win10+, we can call
> CompareObjectHandles directly. No need to query for its function
> pointer, or manually keep kernelbase.dll alive.
>
> Change-Id: I248418d9bfb7c5af6dc1838f0c27d23f93cf5f27
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/248954
> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
> Reviewed-by: Antonio Maiorano <amaiorano@google.com>
> Commit-Queue: Rafael Cintron <rafael.cintron@microsoft.com>
TBR=cwallez@chromium.org,rafael.cintron@microsoft.com,amaiorano@google.com,dawn-scoped@luci-project-accounts.iam.gserviceaccount.com
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: Id293301979e4408e8b6304ec6ef13d2b60b31863
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/249334
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: James Price <jrprice@google.com>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
diff --git a/src/dawn/native/BUILD.gn b/src/dawn/native/BUILD.gn
index fbc3a1e..f164a77 100644
--- a/src/dawn/native/BUILD.gn
+++ b/src/dawn/native/BUILD.gn
@@ -438,7 +438,6 @@
# In UWP, all available APIs are defined in WindowsApp.lib
if (is_win && !dawn_is_winuwp) {
libs += [
- "onecore_apiset.lib",
"user32.lib",
"delayimp.lib",
]
diff --git a/src/dawn/native/CMakeLists.txt b/src/dawn/native/CMakeLists.txt
index ab3b462..c5eae75 100644
--- a/src/dawn/native/CMakeLists.txt
+++ b/src/dawn/native/CMakeLists.txt
@@ -291,14 +291,11 @@
${CMAKE_DL_LIBS}
)
-# Only win32 app needs to link with user32.lib and onecore_apiset.lib
+# Only win32 app needs to link with user32.lib
# In UWP, all availiable APIs are defined in WindowsApp.lib
# and is automatically linked when WINDOWS_STORE set
if (WIN32 AND NOT WINDOWS_STORE)
- list(APPEND conditional_private_platform_depends
- user32.lib
- onecore_apiset.lib
- )
+ list(APPEND conditional_private_platform_depends user32.lib)
endif()
# DXGIGetDebugInterface1 is defined in dxgi.lib
diff --git a/src/dawn/native/d3d/PlatformFunctions.cpp b/src/dawn/native/d3d/PlatformFunctions.cpp
index 2c414ca..cd51833 100644
--- a/src/dawn/native/d3d/PlatformFunctions.cpp
+++ b/src/dawn/native/d3d/PlatformFunctions.cpp
@@ -62,6 +62,7 @@
MaybeError PlatformFunctions::LoadFunctions() {
DAWN_TRY(LoadDXGI());
DAWN_TRY(LoadFXCompiler());
+ DAWN_TRY(LoadKernelBase());
InitWindowsVersion();
return {};
}
@@ -104,6 +105,19 @@
return {};
}
+MaybeError PlatformFunctions::LoadKernelBase() {
+#if DAWN_PLATFORM_IS(WINUWP)
+ compareObjectHandles = &CompareObjectHandles;
+#else
+ std::string error;
+ if (!mKernelBaseLib.OpenSystemLibrary(L"kernelbase.dll", &error) ||
+ !mKernelBaseLib.GetProc(&compareObjectHandles, "CompareObjectHandles", &error)) {
+ return DAWN_INTERNAL_ERROR(error.c_str());
+ }
+#endif
+ return {};
+}
+
void PlatformFunctions::InitWindowsVersion() {
// Currently we only care about the build number of Windows 10 and Windows 11.
if (!IsWindows10OrGreater()) {
diff --git a/src/dawn/native/d3d/PlatformFunctions.h b/src/dawn/native/d3d/PlatformFunctions.h
index e886f86..a8d3d14 100644
--- a/src/dawn/native/d3d/PlatformFunctions.h
+++ b/src/dawn/native/d3d/PlatformFunctions.h
@@ -64,13 +64,20 @@
pD3DCompile d3dCompile = nullptr;
pD3DDisassemble d3dDisassemble = nullptr;
+ // Functions from kernelbase.dll
+ using PFN_COMPARE_OBJECT_HANDLES = BOOL(WINAPI*)(HANDLE hFirstObjectHandle,
+ HANDLE hSecondObjectHandle);
+ PFN_COMPARE_OBJECT_HANDLES compareObjectHandles = nullptr;
+
private:
MaybeError LoadDXGI();
MaybeError LoadFXCompiler();
+ MaybeError LoadKernelBase();
void InitWindowsVersion();
DynamicLib mDXGILib;
DynamicLib mFXCompilerLib;
+ DynamicLib mKernelBaseLib;
uint64_t mCurrentBuildNumber;
};
diff --git a/src/dawn/native/d3d11/SharedFenceD3D11.cpp b/src/dawn/native/d3d11/SharedFenceD3D11.cpp
index e61ea15..45e07d0 100644
--- a/src/dawn/native/d3d11/SharedFenceD3D11.cpp
+++ b/src/dawn/native/d3d11/SharedFenceD3D11.cpp
@@ -42,7 +42,8 @@
return true;
}
- return ::CompareObjectHandles(handle, other);
+ auto deviceD3D11 = ToBackend(device);
+ return deviceD3D11->GetFunctions()->compareObjectHandles(handle, other);
}
} // namespace