From 0d1cf61bb162c6e1f5889f3e8a6ba2667b502166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Wed, 13 Dec 2017 23:40:39 -0800 Subject: [PATCH] Fixed UWP build. --- examples/common/bgfx_utils.cpp | 2 +- scripts/bgfx.lua | 2 +- scripts/example-common.lua | 2 +- scripts/genie.lua | 9 +++++---- scripts/texturev.lua | 3 ++- src/config.h | 1 + src/renderer_d3d11.cpp | 10 ++++++++-- src/renderer_d3d11.h | 1 + src/renderer_d3d12.cpp | 36 ++++++++++++++++++++++------------ src/renderer_d3d12.h | 1 + 10 files changed, 45 insertions(+), 22 deletions(-) diff --git a/examples/common/bgfx_utils.cpp b/examples/common/bgfx_utils.cpp index befcd3250..0d63567b6 100644 --- a/examples/common/bgfx_utils.cpp +++ b/examples/common/bgfx_utils.cpp @@ -676,7 +676,7 @@ Args::Args(int _argc, const char* const* _argv) { m_type = bgfx::RendererType::Noop; } - else if (BX_ENABLED(BX_PLATFORM_WINDOWS) ) + else if (BX_ENABLED(BX_PLATFORM_WINDOWS|BX_PLATFORM_WINRT|BX_PLATFORM_XBOXONE) ) { if (cmdLine.hasArg("d3d9") ) { diff --git a/scripts/bgfx.lua b/scripts/bgfx.lua index adccbf026..c2a1f8d0a 100644 --- a/scripts/bgfx.lua +++ b/scripts/bgfx.lua @@ -127,7 +127,7 @@ function bgfxProjectBase(_kind, _defines) "GLESv2", } - configuration { "winphone8* or winstore8*" } + configuration { "winphone* or winstore*" } linkoptions { "/ignore:4264" -- LNK4264: archiving object file compiled with /ZW into a static library; note that when authoring Windows Runtime types it is not recommended to link with a static library that contains Windows Runtime metadata } diff --git a/scripts/example-common.lua b/scripts/example-common.lua index 78fe16ed1..579910d60 100644 --- a/scripts/example-common.lua +++ b/scripts/example-common.lua @@ -90,7 +90,7 @@ project ("example-common") path.join(BGFX_DIR, "examples/common/**.mm"), } - configuration { "winphone8* or winstore8* or durango"} + configuration { "winphone* or winstore* or durango"} files { path.join(BGFX_DIR, "examples/common/**.cx"), } diff --git a/scripts/genie.lua b/scripts/genie.lua index cacec034e..59632549a 100644 --- a/scripts/genie.lua +++ b/scripts/genie.lua @@ -232,7 +232,7 @@ function exampleProjectDefaults() "kernelx", } - configuration { "winphone8* or winstore8*" } + configuration { "winphone* or winstore*" } removelinks { "DelayImp", "gdi32", @@ -240,6 +240,7 @@ function exampleProjectDefaults() } links { "d3d11", + "d3d12", "dxgi" } linkoptions { @@ -247,15 +248,15 @@ function exampleProjectDefaults() } -- WinRT targets need their own output directories or build files stomp over each other - configuration { "x32", "winphone8* or winstore8*" } + configuration { "x32", "winphone* or winstore*" } targetdir (path.join(BGFX_BUILD_DIR, "win32_" .. _ACTION, "bin", _name)) objdir (path.join(BGFX_BUILD_DIR, "win32_" .. _ACTION, "obj", _name)) - configuration { "x64", "winphone8* or winstore8*" } + configuration { "x64", "winphone* or winstore*" } targetdir (path.join(BGFX_BUILD_DIR, "win64_" .. _ACTION, "bin", _name)) objdir (path.join(BGFX_BUILD_DIR, "win64_" .. _ACTION, "obj", _name)) - configuration { "ARM", "winphone8* or winstore8*" } + configuration { "ARM", "winphone* or winstore*" } targetdir (path.join(BGFX_BUILD_DIR, "arm_" .. _ACTION, "bin", _name)) objdir (path.join(BGFX_BUILD_DIR, "arm_" .. _ACTION, "obj", _name)) diff --git a/scripts/texturev.lua b/scripts/texturev.lua index 4443391a2..7169bf441 100644 --- a/scripts/texturev.lua +++ b/scripts/texturev.lua @@ -132,7 +132,7 @@ project ("texturev") "psapi", } - configuration { "winphone8*"} + configuration { "winphone* or winstore*" } removelinks { "DelayImp", "gdi32", @@ -140,6 +140,7 @@ project ("texturev") } links { "d3d11", + "d3d12", "dxgi" } linkoptions { diff --git a/src/config.h b/src/config.h index 7c0387158..a631eeef3 100644 --- a/src/config.h +++ b/src/config.h @@ -38,6 +38,7 @@ # ifndef BGFX_CONFIG_RENDERER_DIRECT3D12 # define BGFX_CONFIG_RENDERER_DIRECT3D12 (0 \ || BX_PLATFORM_WINDOWS \ + || BX_PLATFORM_WINRT \ || BX_PLATFORM_XBOXONE \ ? 1 : 0) # endif // BGFX_CONFIG_RENDERER_DIRECT3D12 diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index 20aea8fa9..e6e94bade 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -402,6 +402,7 @@ namespace bgfx { namespace d3d11 static const GUID WKPDID_D3DDebugObjectName = { 0x429b8c22, 0x9188, 0x4b0c, { 0x87, 0x42, 0xac, 0xb0, 0xbf, 0x85, 0xc2, 0x00 } }; static const GUID IID_ID3D11Texture2D = { 0x6f15aaf2, 0xd208, 0x4e89, { 0x9a, 0xb4, 0x48, 0x95, 0x35, 0xd3, 0x4f, 0x9c } }; static const GUID IID_IDXGIFactory = { 0x7b7166ec, 0x21c7, 0x44ae, { 0xb2, 0x1a, 0xc9, 0xae, 0x32, 0x1a, 0xe3, 0x69 } }; + static const GUID IID_IDXGIFactory2 = { 0x50c83a1c, 0xe072, 0x4c48, { 0x87, 0xb0, 0x36, 0x30, 0xfa, 0x36, 0xa6, 0xd0 } }; static const GUID IID_IDXGIDevice0 = { 0x54ec77fa, 0x1377, 0x44e6, { 0x8c, 0x32, 0x88, 0xfd, 0x5f, 0x44, 0xc8, 0x4c } }; static const GUID IID_IDXGIDevice1 = { 0x77db970f, 0x6276, 0x48ba, { 0xba, 0x28, 0x07, 0x01, 0x43, 0xb4, 0x39, 0x2c } }; static const GUID IID_IDXGIDevice2 = { 0x05008617, 0xfbfd, 0x4051, { 0xa7, 0x90, 0x14, 0x48, 0x84, 0xb4, 0xf6, 0xa9 } }; @@ -954,7 +955,7 @@ namespace bgfx { namespace d3d11 IDXGIFactory* factory; #if BX_PLATFORM_WINRT // WinRT requires the IDXGIFactory2 interface, which isn't supported on older platforms - hr = CreateDXGIFactory1(__uuidof(IDXGIFactory2), (void**)&factory); + hr = CreateDXGIFactory1(IID_IDXGIFactory2, (void**)&factory); #elif BX_PLATFORM_WINDOWS hr = CreateDXGIFactory(IID_IDXGIFactory, (void**)&factory); #else @@ -1282,7 +1283,12 @@ BX_PRAGMA_DIAGNOSTIC_POP(); , NULL , &m_swapChain ); - BGFX_FATAL(SUCCEEDED(hr), Fatal::UnableToInitialize, "Unable to create Direct3D11 swap chain."); + + if (FAILED(hr) ) + { + BX_TRACE("Init error: Unable to create Direct3D11 swap chain."); + goto error; + } } else { diff --git a/src/renderer_d3d11.h b/src/renderer_d3d11.h index b0b1e49bd..ef7bed286 100644 --- a/src/renderer_d3d11.h +++ b/src/renderer_d3d11.h @@ -24,6 +24,7 @@ BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4005) // warning C4005: '' : macro redefinitio # include # include #elif BX_PLATFORM_WINRT +# define __D3D10_1SHADER_H__ // BK - not used keep quiet! # include #else # include diff --git a/src/renderer_d3d12.cpp b/src/renderer_d3d12.cpp index 203510bfb..633fdb4db 100644 --- a/src/renderer_d3d12.cpp +++ b/src/renderer_d3d12.cpp @@ -8,6 +8,13 @@ #if BGFX_CONFIG_RENDERER_DIRECT3D12 # include "renderer_d3d12.h" +#if !BX_PLATFORM_WINDOWS +# include +# if BX_PLATFORM_WINRT +# include +# endif // BX_PLATFORM_WINRT +#endif // !BX_PLATFORM_WINDOWS + namespace bgfx { namespace d3d12 { static wchar_t s_viewNameW[BGFX_CONFIG_MAX_VIEWS][BGFX_CONFIG_MAX_VIEW_NAME]; @@ -357,7 +364,6 @@ namespace bgfx { namespace d3d12 _commandList->ResourceBarrier(1, &barrier); } -#if USE_D3D12_DYNAMIC_LIB static const GUID IID_ID3D12CommandAllocator = { 0x6102dee4, 0xaf59, 0x4b09, { 0xb9, 0x99, 0xb4, 0x4d, 0x73, 0xf0, 0x9b, 0x24 } }; static const GUID IID_ID3D12CommandQueue = { 0x0ec870a6, 0x5d7e, 0x4c22, { 0x8c, 0xfc, 0x5b, 0xaa, 0xe0, 0x76, 0x16, 0xed } }; static const GUID IID_ID3D12CommandSignature = { 0xc36a797c, 0xec80, 0x4f0a, { 0x89, 0x85, 0xa7, 0xb2, 0x47, 0x50, 0x82, 0xd1 } }; @@ -372,11 +378,12 @@ namespace bgfx { namespace d3d12 static const GUID IID_ID3D12Resource = { 0x696442be, 0xa72e, 0x4059, { 0xbc, 0x79, 0x5b, 0x5c, 0x98, 0x04, 0x0f, 0xad } }; static const GUID IID_ID3D12RootSignature = { 0xc54a6b66, 0x72df, 0x4ee8, { 0x8b, 0xe5, 0xa9, 0x46, 0xa1, 0x42, 0x92, 0x14 } }; static const GUID IID_ID3D12QueryHeap = { 0x0d9658ae, 0xed45, 0x469e, { 0xa6, 0x1d, 0x97, 0x0e, 0xc5, 0x83, 0xca, 0xb4 } }; + static const GUID IID_IDXGIDevice0 = { 0x54ec77fa, 0x1377, 0x44e6, { 0x8c, 0x32, 0x88, 0xfd, 0x5f, 0x44, 0xc8, 0x4c } }; + static const GUID IID_IDXGIDevice1 = { 0x77db970f, 0x6276, 0x48ba, { 0xba, 0x28, 0x07, 0x01, 0x43, 0xb4, 0x39, 0x2c } }; + static const GUID IID_IDXGIDevice2 = { 0x05008617, 0xfbfd, 0x4051, { 0xa7, 0x90, 0x14, 0x48, 0x84, 0xb4, 0xf6, 0xa9 } }; + static const GUID IID_IDXGIDevice3 = { 0x6007896c, 0x3244, 0x4afd, { 0xbf, 0x18, 0xa6, 0xd3, 0xbe, 0xda, 0x50, 0x23 } }; + static const GUID IID_IDXGIFactory2 = { 0x50c83a1c, 0xe072, 0x4c48, { 0x87, 0xb0, 0x36, 0x30, 0xfa, 0x36, 0xa6, 0xd0 } }; static const GUID IID_IDXGIFactory4 = { 0x1bc6ea02, 0xef36, 0x464f, { 0xbf, 0x0c, 0x21, 0xca, 0x39, 0xe5, 0x16, 0x8a } }; -#else - static const GUID IID_ID3D12CommandSignature = { 0xc36a797c, 0xec80, 0x4f0a, { 0x89, 0x85, 0xa7, 0xb2, 0x47, 0x50, 0x82, 0xd1 } }; - static const GUID IID_ID3D12QueryHeap = { 0x0d9658ae, 0xed45, 0x469e, { 0xa6, 0x1d, 0x97, 0x0e, 0xc5, 0x83, 0xca, 0xb4 } }; -#endif // USE_D3D12_DYNAMIC_LIB struct HeapProperty { @@ -670,7 +677,7 @@ namespace bgfx { namespace d3d12 HRESULT hr; -#if BX_PLATFORM_WINDOWS +#if BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT hr = CreateDXGIFactory1(IID_IDXGIFactory4, (void**)&m_factory); #else hr = S_OK; @@ -690,7 +697,7 @@ namespace bgfx { namespace d3d12 if (NULL != m_factory) { -#if BX_PLATFORM_WINDOWS +#if BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT IDXGIAdapter3* adapter; #else IDXGIAdapter* adapter; @@ -875,7 +882,7 @@ namespace bgfx { namespace d3d12 goto error; } - hr = m_adapter->GetParent(IID_IDXGIFactory2, (void**)&m_factory); + hr = m_adapter->GetParent(IID_IDXGIFactory4, (void**)&m_factory); if (FAILED(hr) ) { @@ -903,7 +910,7 @@ namespace bgfx { namespace d3d12 { #if !BX_PLATFORM_WINDOWS hr = m_adapter->GetParent(__uuidof(IDXGIFactory2), (void**)&m_factory); - DX_RELEASE(m_adapter, 1); + DX_RELEASE(m_adapter, 0); if (FAILED(hr) ) { BX_TRACE("Init error: Unable to create Direct3D11 device."); @@ -924,13 +931,18 @@ namespace bgfx { namespace d3d12 if (NULL == g_platformData.ndt) { - hr = m_factory->CreateSwapChainForCoreWindow(m_device + hr = m_factory->CreateSwapChainForCoreWindow(m_cmd.m_commandQueue , (::IUnknown*)g_platformData.nwh , &m_scd , NULL , &m_swapChain ); - BGFX_FATAL(SUCCEEDED(hr), Fatal::UnableToInitialize, "Unable to create Direct3D11 swap chain."); + + if (FAILED(hr) ) + { + BX_TRACE("Init error: Unable to create Direct3D12 swap chain."); + goto error; + } } else { @@ -3016,7 +3028,7 @@ data.NumQualityLevels = 0; ID3D12InfoQueue* m_infoQueue; #else IDXGIAdapter* m_adapter; - IDXGIFactory2* m_factory; + IDXGIFactory4* m_factory; IDXGISwapChain1* m_swapChain; #endif // BX_PLATFORM_WINDOWS diff --git a/src/renderer_d3d12.h b/src/renderer_d3d12.h index 04ede7a7d..42243c72e 100644 --- a/src/renderer_d3d12.h +++ b/src/renderer_d3d12.h @@ -13,6 +13,7 @@ # include #else # include +# include #endif // BX_PLATFORM_XBOXONE #if defined(__MINGW32__) // BK - temp workaround for MinGW until I nuke d3dx12 usage.