diff --git a/src/dawn_native/BUILD.gn b/src/dawn_native/BUILD.gn index 515ca9d3e3..711fa8c80a 100644 --- a/src/dawn_native/BUILD.gn +++ b/src/dawn_native/BUILD.gn @@ -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 += [ diff --git a/src/dawn_native/d3d12/BackendD3D12.cpp b/src/dawn_native/d3d12/BackendD3D12.cpp index df61c2af73..3e5c15b5b8 100644 --- a/src/dawn_native/d3d12/BackendD3D12.cpp +++ b/src/dawn_native/d3d12/BackendD3D12.cpp @@ -50,7 +50,8 @@ namespace dawn_native { namespace d3d12 { if (beginCaptureOnStartup) { ComPtr graphicsAnalysis; - if (SUCCEEDED(functions->dxgiGetDebugInterface1( + if (functions->dxgiGetDebugInterface1 != nullptr && + SUCCEEDED(functions->dxgiGetDebugInterface1( 0, IID_PPV_ARGS(&graphicsAnalysis)))) { graphicsAnalysis->BeginCapture(); } diff --git a/src/dawn_native/d3d12/PlatformFunctions.cpp b/src/dawn_native/d3d12/PlatformFunctions.cpp index ba1868e22e..8e0654ea35 100644 --- a/src/dawn_native/d3d12/PlatformFunctions.cpp +++ b/src/dawn_native/d3d12/PlatformFunctions.cpp @@ -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;