This commit is contained in:
Branimir Karadžić 2015-10-09 19:21:42 -07:00
parent e627c4a4d6
commit 09e6aa3d9a
2 changed files with 91 additions and 87 deletions

View file

@ -9,9 +9,9 @@
# include "renderer_d3d11.h" # include "renderer_d3d11.h"
#if BX_PLATFORM_WINRT #if BX_PLATFORM_WINRT
#include <inspectable.h> # include <inspectable.h>
#include <windows.ui.xaml.media.dxinterop.h> # include <windows.ui.xaml.media.dxinterop.h>
#endif #endif // BX_PLATFORM_WINRT
namespace bgfx { namespace d3d11 namespace bgfx { namespace d3d11
{ {
@ -1017,50 +1017,52 @@ BX_PRAGMA_DIAGNOSTIC_POP();
memset(&m_scd, 0, sizeof(m_scd) ); memset(&m_scd, 0, sizeof(m_scd) );
m_scd.Width = BGFX_DEFAULT_WIDTH; m_scd.Width = BGFX_DEFAULT_WIDTH;
m_scd.Height = BGFX_DEFAULT_HEIGHT; m_scd.Height = BGFX_DEFAULT_HEIGHT;
m_scd.Format = DXGI_FORMAT_R8G8B8A8_UNORM; m_scd.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
m_scd.Stereo = false; m_scd.Stereo = false;
m_scd.SampleDesc.Count = 1; m_scd.SampleDesc.Count = 1;
m_scd.SampleDesc.Quality = 0; m_scd.SampleDesc.Quality = 0;
m_scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; m_scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
m_scd.BufferCount = 2; m_scd.BufferCount = 2;
m_scd.Scaling = (g_platformData.ndt == 0) ? DXGI_SCALING_NONE : DXGI_SCALING_STRETCH; m_scd.Scaling = 0 == g_platformData.ndt
m_scd.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; ? DXGI_SCALING_NONE
m_scd.AlphaMode = DXGI_ALPHA_MODE_IGNORE; : DXGI_SCALING_STRETCH;
m_scd.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
m_scd.AlphaMode = DXGI_ALPHA_MODE_IGNORE;
if (g_platformData.ndt == 0) if (NULL == g_platformData.ndt)
{ {
hr = m_factory->CreateSwapChainForCoreWindow(m_device hr = m_factory->CreateSwapChainForCoreWindow(m_device
, (::IUnknown*)g_platformData.nwh , (::IUnknown*)g_platformData.nwh
, &m_scd , &m_scd
, NULL , NULL
, &m_swapChain , &m_swapChain
); );
BGFX_FATAL(SUCCEEDED(hr), Fatal::UnableToInitialize, "Unable to create Direct3D11 swap chain."); BGFX_FATAL(SUCCEEDED(hr), Fatal::UnableToInitialize, "Unable to create Direct3D11 swap chain.");
} }
else else
{ {
BGFX_FATAL(g_platformData.ndt == reinterpret_cast<void*>(1), Fatal::UnableToInitialize, "Unable to set swap chain on panel."); BGFX_FATAL(g_platformData.ndt == reinterpret_cast<void*>(1), Fatal::UnableToInitialize, "Unable to set swap chain on panel.");
hr = m_factory->CreateSwapChainForComposition( hr = m_factory->CreateSwapChainForComposition(m_device
m_device, , &m_scd
&m_scd, , NULL
NULL, , &m_swapChain
&m_swapChain); );
BX_WARN(SUCCEEDED(hr), "Unable to create Direct3D11 swap chain."); BX_WARN(SUCCEEDED(hr), "Unable to create Direct3D11 swap chain.");
IInspectable *nativeWindow = reinterpret_cast<IInspectable *>(g_platformData.nwh); IInspectable* nativeWindow = reinterpret_cast<IInspectable *>(g_platformData.nwh);
ISwapChainBackgroundPanelNative* panel = nullptr; ISwapChainBackgroundPanelNative* panel = NULL;
hr = nativeWindow->QueryInterface(__uuidof(ISwapChainBackgroundPanelNative), (void **)&panel); hr = nativeWindow->QueryInterface(__uuidof(ISwapChainBackgroundPanelNative), (void**)&panel);
BGFX_FATAL(SUCCEEDED(hr), Fatal::UnableToInitialize, "Unable to set swap chain on panel."); BGFX_FATAL(SUCCEEDED(hr), Fatal::UnableToInitialize, "Unable to set swap chain on panel.");
if (panel != nullptr) if (NULL != panel)
{ {
hr = panel->SetSwapChain(m_swapChain); hr = panel->SetSwapChain(m_swapChain);
BGFX_FATAL(SUCCEEDED(hr), Fatal::UnableToInitialize, "Unable to set swap chain on panel."); BGFX_FATAL(SUCCEEDED(hr), Fatal::UnableToInitialize, "Unable to set swap chain on panel.");
panel->Release(); panel->Release();
} }
} }
#else #else
hr = adapter->GetParent(IID_IDXGIFactory, (void**)&m_factory); hr = adapter->GetParent(IID_IDXGIFactory, (void**)&m_factory);
BX_WARN(SUCCEEDED(hr), "Unable to create Direct3D11 device."); BX_WARN(SUCCEEDED(hr), "Unable to create Direct3D11 device.");
@ -2155,46 +2157,46 @@ BX_PRAGMA_DIAGNOSTIC_POP();
#if BX_PLATFORM_WINRT #if BX_PLATFORM_WINRT
HRESULT hr; HRESULT hr;
if (g_platformData.ndt == 0) if (g_platformData.ndt == 0)
{ {
hr = m_factory->CreateSwapChainForCoreWindow(m_device hr = m_factory->CreateSwapChainForCoreWindow(m_device
, (::IUnknown*)g_platformData.nwh , (::IUnknown*)g_platformData.nwh
, scd , scd
, NULL , NULL
, &m_swapChain , &m_swapChain
); );
BGFX_FATAL(SUCCEEDED(hr), Fatal::UnableToInitialize, "Unable to create Direct3D11 swap chain."); BGFX_FATAL(SUCCEEDED(hr), Fatal::UnableToInitialize, "Unable to create Direct3D11 swap chain.");
} }
else else
{ {
BGFX_FATAL(g_platformData.ndt == reinterpret_cast<void*>(1), Fatal::UnableToInitialize, "Invalid native display type."); BGFX_FATAL(g_platformData.ndt == reinterpret_cast<void*>(1), Fatal::UnableToInitialize, "Invalid native display type.");
hr = m_factory->CreateSwapChainForComposition( hr = m_factory->CreateSwapChainForComposition(m_device
m_device, , &m_scd
&m_scd, , NULL
NULL, , &m_swapChain
&m_swapChain); );
BGFX_FATAL(SUCCEEDED(hr), Fatal::UnableToInitialize, "Unable to create Direct3D11 swap chain."); BGFX_FATAL(SUCCEEDED(hr), Fatal::UnableToInitialize, "Unable to create Direct3D11 swap chain.");
IInspectable *nativeWindow = reinterpret_cast<IInspectable *>(g_platformData.nwh); IInspectable *nativeWindow = reinterpret_cast<IInspectable *>(g_platformData.nwh);
ISwapChainBackgroundPanelNative* panel = nullptr; ISwapChainBackgroundPanelNative* panel = NULL;
hr = nativeWindow->QueryInterface(__uuidof(ISwapChainBackgroundPanelNative), (void **)&panel); hr = nativeWindow->QueryInterface(__uuidof(ISwapChainBackgroundPanelNative), (void **)&panel);
BGFX_FATAL(SUCCEEDED(hr), Fatal::UnableToInitialize, "Unable to set swap chain on panel."); BGFX_FATAL(SUCCEEDED(hr), Fatal::UnableToInitialize, "Unable to set swap chain on panel.");
if (panel != nullptr) if (NULL != panel)
{ {
hr = panel->SetSwapChain(m_swapChain); hr = panel->SetSwapChain(m_swapChain);
BGFX_FATAL(SUCCEEDED(hr), Fatal::UnableToInitialize, "Unable to set swap chain on panel."); BGFX_FATAL(SUCCEEDED(hr), Fatal::UnableToInitialize, "Unable to set swap chain on panel.");
panel->Release(); panel->Release();
} }
} }
#else #else
HRESULT hr; HRESULT hr;
hr = m_factory->CreateSwapChain(m_device hr = m_factory->CreateSwapChain(m_device
, scd , scd
, &m_swapChain , &m_swapChain
); );
#endif // BX_PLATFORM_WINRT #endif // BX_PLATFORM_WINRT
BGFX_FATAL(SUCCEEDED(hr), bgfx::Fatal::UnableToInitialize, "Failed to create swap chain."); BGFX_FATAL(SUCCEEDED(hr), bgfx::Fatal::UnableToInitialize, "Failed to create swap chain.");
} }
@ -3319,22 +3321,24 @@ BX_PRAGMA_DIAGNOSTIC_POP();
s_renderD3D11 = NULL; s_renderD3D11 = NULL;
} }
void trim() void trim()
{ {
if (s_renderD3D11) #if BX_PLATFORM_WINRT
{ if (NULL != s_renderD3D11)
if (s_renderD3D11->m_device) {
{ if (s_renderD3D11->m_device)
IDXGIDevice3 * pDXGIDevice; {
HRESULT hr = s_renderD3D11->m_device->QueryInterface(__uuidof(IDXGIDevice3), (void **)&pDXGIDevice); IDXGIDevice3* pDXGIDevice;
if (SUCCEEDED(hr)) HRESULT hr = s_renderD3D11->m_device->QueryInterface(__uuidof(IDXGIDevice3),(void **)&pDXGIDevice);
{ if (SUCCEEDED(hr) )
pDXGIDevice->Trim(); {
pDXGIDevice->Release(); pDXGIDevice->Trim();
} pDXGIDevice->Release();
} }
} }
} }
#endif // BX_PLATFORM_WINRT
}
void stubMultiDrawInstancedIndirect(uint32_t _numDrawIndirect, ID3D11Buffer* _ptr, uint32_t _offset, uint32_t _stride) void stubMultiDrawInstancedIndirect(uint32_t _numDrawIndirect, ID3D11Buffer* _ptr, uint32_t _offset, uint32_t _stride)
{ {

View file

@ -20,7 +20,7 @@ BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4005) // warning C4005: '' : macro redefinitio
#include <sal.h> #include <sal.h>
#define D3D11_NO_HELPERS #define D3D11_NO_HELPERS
#if BX_PLATFORM_WINRT #if BX_PLATFORM_WINRT
# include <d3d11_2.h> # include <d3d11_3.h>
#else #else
# include <d3d11.h> # include <d3d11.h>
#endif // BX_PLATFORM_WINRT #endif // BX_PLATFORM_WINRT