Remove reduntant dependencies in UWP compilation

Remove d3d12.li, dxgi.lib and d3d11.lib dependencies when targeting UWP.
Add dxgi.lib only for DXGIGetDebugInterface1 in debug build when targeting UWP.
Use DXGIGetDebugInterface1 only in debug build when targeting UWP.

Bug: dawn:766
Change-Id: I5fa53dbb257acf604836f861f75a122a7d417e7c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/49040
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: 陈俊嘉 <cjj19970505@live.cn>
This commit is contained in:
陈俊嘉 2021-04-27 06:09:36 +00:00 committed by Commit Bot service account
parent c952097dc6
commit cf569e2c58
3 changed files with 28 additions and 16 deletions

View File

@ -309,24 +309,28 @@ source_set("dawn_native_sources") {
]
}
if (is_win) {
# Only win32 app needs to link with user32.lib
# In UWP, all availiable APIs are defined in WindowsApp.lib
if (is_win && !dawn_is_winuwp) {
libs += [ "user32.lib" ]
if (dawn_is_winuwp) {
# UWP has a limited DLL search space.
# So we have to link with stub libs provided by Windows SDK
# to load DLLs correctly.
libs += [
"dxgi.lib",
"d3d12.lib",
"d3d11.lib",
# TODO(dawn:766):
# Somehow use dxcompiler.lib makes CoreApp unable to activate
# WinPIX should be added as third party tools and linked statically
]
}
}
if (dawn_is_winuwp && is_debug) {
# DXGIGetDebugInterface1 is defined in dxgi.lib
# But this API is tagged as a development-only capability
# which implies that linking to this function will cause
# the application to fail Windows store certification
# So we only link to it in debug build when compiling for UWP.
# In win32 we load dxgi.dll using LoadLibrary
# so no need for static linking.
libs += [ "dxgi.lib" ]
}
# TODO(dawn:766):
# Should link dxcompiler.lib and WinPixEventRuntime_UAP.lib in UWP
# Somehow use dxcompiler.lib makes CoreApp unable to activate
# WinPIX should be added as third party tools and linked statically
if (dawn_enable_d3d12) {
libs += [ "dxguid.lib" ]
sources += [

View File

@ -50,7 +50,8 @@ namespace dawn_native { namespace d3d12 {
if (beginCaptureOnStartup) {
ComPtr<IDXGraphicsAnalysis> graphicsAnalysis;
if (SUCCEEDED(functions->dxgiGetDebugInterface1(
if (functions->dxgiGetDebugInterface1 != nullptr &&
SUCCEEDED(functions->dxgiGetDebugInterface1(
0, IID_PPV_ARGS(&graphicsAnalysis)))) {
graphicsAnalysis->BeginCapture();
}

View File

@ -158,7 +158,14 @@ namespace dawn_native { namespace d3d12 {
MaybeError PlatformFunctions::LoadDXGI() {
#if DAWN_PLATFORM_WINUWP
# if defined(_DEBUG)
// DXGIGetDebugInterface1 is tagged as a development-only capability
// which implies that linking to this function will cause
// the application to fail Windows store certification
// But we need it when debuging using VS Graphics Diagnostics or PIX
// So we only link to it in debug build
dxgiGetDebugInterface1 = &DXGIGetDebugInterface1;
# endif
createDxgiFactory2 = &CreateDXGIFactory2;
#else
std::string error;