Bläddra i källkod

DX11: Added static linking with D3D libs for WinRT.

Branimir Karadžić 11 år sedan
förälder
incheckning
5ddec2b790
5 ändrade filer med 27 tillägg och 7 borttagningar
  1. 14 3
      src/renderer_d3d11.cpp
  2. 7 0
      src/renderer_d3d11.h
  3. 2 1
      src/renderer_d3d9.cpp
  4. 2 1
      src/renderer_gl.cpp
  5. 2 2
      src/renderer_gl.h

+ 14 - 3
src/renderer_d3d11.cpp

@@ -248,7 +248,7 @@ namespace bgfx
 	};
 	BX_STATIC_ASSERT(TextureFormat::Count == BX_COUNTOF(s_textureFormat) );
 
-	static const D3D11_INPUT_ELEMENT_DESC s_attrib[Attrib::Count] =
+	static const D3D11_INPUT_ELEMENT_DESC s_attrib[] =
 	{
 		{ "POSITION",     0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
 		{ "NORMAL",       0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
@@ -266,6 +266,7 @@ namespace bgfx
 		{ "TEXCOORD",     6, DXGI_FORMAT_R32G32_FLOAT,    0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
 		{ "TEXCOORD",     7, DXGI_FORMAT_R32G32_FLOAT,    0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
 	};
+	BX_STATIC_ASSERT(Attrib::Count == BX_COUNTOF(s_attrib) );
 
 	static const DXGI_FORMAT s_attribType[AttribType::Count][4][2] =
 	{
@@ -422,6 +423,7 @@ namespace bgfx
 			memset(m_uniforms, 0, sizeof(m_uniforms) );
 			memset(&m_resolution, 0, sizeof(m_resolution) );
 
+#if USE_D3D11_DYNAMIC_LIB
 			m_d3d11dll = bx::dlopen("d3d11.dll");
 			BGFX_FATAL(NULL != m_d3d11dll, Fatal::UnableToInitialize, "Failed to load d3d11.dll.");
 
@@ -432,9 +434,9 @@ namespace bgfx
 				m_d3d9dll = bx::dlopen("d3d9.dll");
 				BGFX_FATAL(NULL != m_d3d9dll, Fatal::UnableToInitialize, "Failed to load d3d9.dll.");
 
-				m_D3DPERF_SetMarker = (D3DPERF_SetMarkerFunc)bx::dlsym(m_d3d9dll, "D3DPERF_SetMarker");
+				m_D3DPERF_SetMarker  = (D3DPERF_SetMarkerFunc )bx::dlsym(m_d3d9dll, "D3DPERF_SetMarker" );
 				m_D3DPERF_BeginEvent = (D3DPERF_BeginEventFunc)bx::dlsym(m_d3d9dll, "D3DPERF_BeginEvent");
-				m_D3DPERF_EndEvent = (D3DPERF_EndEventFunc)bx::dlsym(m_d3d9dll, "D3DPERF_EndEvent");
+				m_D3DPERF_EndEvent   = (D3DPERF_EndEventFunc  )bx::dlsym(m_d3d9dll, "D3DPERF_EndEvent"  );
 				BX_CHECK(NULL != m_D3DPERF_SetMarker
 					  && NULL != m_D3DPERF_BeginEvent
 					  && NULL != m_D3DPERF_EndEvent
@@ -450,6 +452,10 @@ namespace bgfx
 
 			PFN_CREATEDXGIFACTORY dxgiCreateDXGIFactory = (PFN_CREATEDXGIFACTORY)bx::dlsym(m_dxgidll, "CreateDXGIFactory");
 			BGFX_FATAL(NULL != dxgiCreateDXGIFactory, Fatal::UnableToInitialize, "Function CreateDXGIFactory not found.");
+#else
+			PFN_D3D11_CREATE_DEVICE d3D11CreateDevice     = D3D11CreateDevice;
+			PFN_CREATEDXGIFACTORY   dxgiCreateDXGIFactory = CreateDXGIFactory;
+#endif // USE_D3D11_DYNAMIC_LIB
 
 			HRESULT hr;
 
@@ -655,8 +661,10 @@ namespace bgfx
 			DX_RELEASE(m_device, 0);
 			DX_RELEASE(m_factory, 0);
 
+#if USE_D3D11_DYNAMIC_LIB
 			bx::dlclose(m_dxgidll);
 			bx::dlclose(m_d3d11dll);
+#endif // USE_D3D11_DYNAMIC_LIB
 		}
 
 		RendererType::Enum getRendererType() const BX_OVERRIDE
@@ -1768,8 +1776,11 @@ namespace bgfx
 		D3DPERF_BeginEventFunc m_D3DPERF_BeginEvent;
 		D3DPERF_EndEventFunc m_D3DPERF_EndEvent;
 
+#if USE_D3D11_DYNAMIC_LIB
 		void* m_d3d11dll;
 		void* m_dxgidll;
+#endif // USE_D3D11_DYNAMIC_LIB
+
 		D3D_DRIVER_TYPE m_driverType;
 		IDXGIAdapter* m_adapter;
 		DXGI_ADAPTER_DESC m_adapterDesc;

+ 7 - 0
src/renderer_d3d11.h

@@ -6,6 +6,13 @@
 #ifndef BGFX_RENDERER_D3D11_H_HEADER_GUARD
 #define BGFX_RENDERER_D3D11_H_HEADER_GUARD
 
+#define USE_D3D11_DYNAMIC_LIB !BX_PLATFORM_WINRT
+
+#if !USE_D3D11_DYNAMIC_LIB
+#	undef  BGFX_CONFIG_DEBUG_PIX
+#	define BGFX_CONFIG_DEBUG_PIX 0
+#endif // !USE_D3D11_DYNAMIC_LIB
+
 #define D3D11_NO_HELPERS
 #include <d3d11.h>
 #include "renderer_d3d.h"

+ 2 - 1
src/renderer_d3d9.cpp

@@ -1547,7 +1547,7 @@ namespace bgfx
 		}
 	}
 
-	static const D3DVERTEXELEMENT9 s_attrib[Attrib::Count+1] =
+	static const D3DVERTEXELEMENT9 s_attrib[] =
 	{
 		{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION,     0 },
 		{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL,       0 },
@@ -1566,6 +1566,7 @@ namespace bgfx
 		{ 0, 0, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD,     7 },
 		D3DDECL_END()
 	};
+	BX_STATIC_ASSERT(Attrib::Count == BX_COUNTOF(s_attrib)-1);
 
 	static const D3DDECLTYPE s_attribType[AttribType::Count][4][2] =
 	{

+ 2 - 1
src/renderer_gl.cpp

@@ -38,7 +38,7 @@ namespace bgfx
 		"Point",
 	};
 
-	static const char* s_attribName[Attrib::Count] =
+	static const char* s_attribName[] =
 	{
 		"a_position",
 		"a_normal",
@@ -56,6 +56,7 @@ namespace bgfx
 		"a_texcoord6",
 		"a_texcoord7",
 	};
+	BX_STATIC_ASSERT(Attrib::Count == BX_COUNTOF(s_attribName) );
 
 	static const char* s_instanceDataName[BGFX_CONFIG_MAX_INSTANCE_DATA_COUNT] =
 	{

+ 2 - 2
src/renderer_gl.h

@@ -501,11 +501,11 @@ typedef uint64_t GLuint64;
 #endif // BGFX_USE_WGL
 
 #ifndef GL_APIENTRY
-#   define GL_APIENTRY APIENTRY
+#	define GL_APIENTRY APIENTRY
 #endif // GL_APIENTRY
 
 #ifndef GL_APIENTRYP
-#   define GL_APIENTRYP GL_APIENTRY*
+#	define GL_APIENTRYP GL_APIENTRY*
 #endif // GL_APIENTRYP
 
 #if !BGFX_CONFIG_RENDERER_OPENGL