Branimir Karadžić %!s(int64=10) %!d(string=hai) anos
pai
achega
09e6aa3d9a
Modificáronse 2 ficheiros con 100 adicións e 96 borrados
  1. 99 95
      src/renderer_d3d11.cpp
  2. 1 1
      src/renderer_d3d11.h

+ 99 - 95
src/renderer_d3d11.cpp

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

+ 1 - 1
src/renderer_d3d11.h

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