[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>
diff --git a/src/dawn/native/BUILD.gn b/src/dawn/native/BUILD.gn
index f164a77..fbc3a1e 100644
--- a/src/dawn/native/BUILD.gn
+++ b/src/dawn/native/BUILD.gn
@@ -438,6 +438,7 @@
# 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 c5eae75..ab3b462 100644
--- a/src/dawn/native/CMakeLists.txt
+++ b/src/dawn/native/CMakeLists.txt
@@ -291,11 +291,14 @@
${CMAKE_DL_LIBS}
)
-# Only win32 app needs to link with user32.lib
+# Only win32 app needs to link with user32.lib and onecore_apiset.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)
+ list(APPEND conditional_private_platform_depends
+ user32.lib
+ onecore_apiset.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 cd51833..2c414ca 100644
--- a/src/dawn/native/d3d/PlatformFunctions.cpp
+++ b/src/dawn/native/d3d/PlatformFunctions.cpp
@@ -62,7 +62,6 @@
MaybeError PlatformFunctions::LoadFunctions() {
DAWN_TRY(LoadDXGI());
DAWN_TRY(LoadFXCompiler());
- DAWN_TRY(LoadKernelBase());
InitWindowsVersion();
return {};
}
@@ -105,19 +104,6 @@
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 a8d3d14..e886f86 100644
--- a/src/dawn/native/d3d/PlatformFunctions.h
+++ b/src/dawn/native/d3d/PlatformFunctions.h
@@ -64,20 +64,13 @@
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 45e07d0..e61ea15 100644
--- a/src/dawn/native/d3d11/SharedFenceD3D11.cpp
+++ b/src/dawn/native/d3d11/SharedFenceD3D11.cpp
@@ -42,8 +42,7 @@
return true;
}
- auto deviceD3D11 = ToBackend(device);
- return deviceD3D11->GetFunctions()->compareObjectHandles(handle, other);
+ return ::CompareObjectHandles(handle, other);
}
} // namespace