ソースを参照

Added Metal renderer backend stub.

Branimir Karadžić 10 年 前
コミット
52cfaf0aaa
9 ファイル変更41 行追加3 行削除
  1. 1 0
      include/bgfx.c99.h
  2. 1 0
      include/bgfx.h
  3. 3 1
      src/bgfx.cpp
  4. 1 0
      src/bgfx_p.h
  5. 9 0
      src/config.h
  6. 1 1
      src/renderer_d3d12.cpp
  7. 23 0
      src/renderer_mtl.cpp
  8. 1 1
      src/renderer_vk.cpp
  9. 1 0
      src/vertexdecl.cpp

+ 1 - 0
include/bgfx.c99.h

@@ -20,6 +20,7 @@ typedef enum bgfx_renderer_type
     BGFX_RENDERER_TYPE_DIRECT3D9,
     BGFX_RENDERER_TYPE_DIRECT3D11,
     BGFX_RENDERER_TYPE_DIRECT3D12,
+    BGFX_RENDERER_TYPE_METAL,
     BGFX_RENDERER_TYPE_OPENGLES,
     BGFX_RENDERER_TYPE_OPENGL,
     BGFX_RENDERER_TYPE_VULKAN,

+ 1 - 0
include/bgfx.h

@@ -47,6 +47,7 @@ namespace bgfx
 			Direct3D9,    //!< Direct3D 9.0
 			Direct3D11,   //!< Direct3D 11.0
 			Direct3D12,   //!< Direct3D 12.0
+			Metal,        //!< Metal
 			OpenGLES,     //!< OpenGL ES 2.0+
 			OpenGL,       //!< OpenGL 2.1+
 			Vulkan,       //!< Vulkan

+ 3 - 1
src/bgfx.cpp

@@ -1338,6 +1338,7 @@ namespace bgfx
 	BGFX_RENDERER_CONTEXT(d3d9);
 	BGFX_RENDERER_CONTEXT(d3d11);
 	BGFX_RENDERER_CONTEXT(d3d12);
+	BGFX_RENDERER_CONTEXT(mtl);
 	BGFX_RENDERER_CONTEXT(gl);
 	BGFX_RENDERER_CONTEXT(vk);
 
@@ -1353,10 +1354,11 @@ namespace bgfx
 
 	static const RendererCreator s_rendererCreator[] =
 	{
-		{ noop::rendererCreate,  noop::rendererDestroy,  BGFX_RENDERER_NULL_NAME,       !!BGFX_CONFIG_RENDERER_NULL       }, // Null
+		{ noop::rendererCreate,  noop::rendererDestroy,  BGFX_RENDERER_NULL_NAME,       !!BGFX_CONFIG_RENDERER_NULL       }, // Noop
 		{ d3d9::rendererCreate,  d3d9::rendererDestroy,  BGFX_RENDERER_DIRECT3D9_NAME,  !!BGFX_CONFIG_RENDERER_DIRECT3D9  }, // Direct3D9
 		{ d3d11::rendererCreate, d3d11::rendererDestroy, BGFX_RENDERER_DIRECT3D11_NAME, !!BGFX_CONFIG_RENDERER_DIRECT3D11 }, // Direct3D11
 		{ d3d12::rendererCreate, d3d12::rendererDestroy, BGFX_RENDERER_DIRECT3D12_NAME, !!BGFX_CONFIG_RENDERER_DIRECT3D12 }, // Direct3D12
+		{ mtl::rendererCreate,   mtl::rendererDestroy,   BGFX_RENDERER_METAL_NAME,      !!BGFX_CONFIG_RENDERER_METAL      }, // Metal
 		{ gl::rendererCreate,    gl::rendererDestroy,    BGFX_RENDERER_OPENGL_NAME,     !!BGFX_CONFIG_RENDERER_OPENGLES   }, // OpenGLES
 		{ gl::rendererCreate,    gl::rendererDestroy,    BGFX_RENDERER_OPENGL_NAME,     !!BGFX_CONFIG_RENDERER_OPENGL     }, // OpenGL
 		{ vk::rendererCreate,    vk::rendererDestroy,    BGFX_RENDERER_VULKAN_NAME,     !!BGFX_CONFIG_RENDERER_VULKAN     }, // Vulkan

+ 1 - 0
src/bgfx_p.h

@@ -174,6 +174,7 @@ namespace stl
 #define BGFX_RENDERER_DIRECT3D9_NAME  "Direct3D 9"
 #define BGFX_RENDERER_DIRECT3D11_NAME "Direct3D 11"
 #define BGFX_RENDERER_DIRECT3D12_NAME "Direct3D 12"
+#define BGFX_RENDERER_METAL_NAME "Metal"
 #define BGFX_RENDERER_VULKAN_NAME "Vulkan"
 #define BGFX_RENDERER_NULL_NAME "NULL"
 

+ 9 - 0
src/config.h

@@ -15,6 +15,7 @@
 #if !defined(BGFX_CONFIG_RENDERER_DIRECT3D9) \
 	&& !defined(BGFX_CONFIG_RENDERER_DIRECT3D11) \
 	&& !defined(BGFX_CONFIG_RENDERER_DIRECT3D12) \
+	&& !defined(BGFX_CONFIG_RENDERER_METAL) \
 	&& !defined(BGFX_CONFIG_RENDERER_OPENGL) \
 	&& !defined(BGFX_CONFIG_RENDERER_OPENGLES) \
 	&& !defined(BGFX_CONFIG_RENDERER_VULKAN) \
@@ -40,6 +41,10 @@
 					? 1 : 0)
 #	endif // BGFX_CONFIG_RENDERER_DIRECT3D12
 
+#	ifndef BGFX_CONFIG_RENDERER_METAL
+#		define BGFX_CONFIG_RENDERER_METAL 0
+#	endif // BGFX_CONFIG_RENDERER_METAL
+
 #	ifndef BGFX_CONFIG_RENDERER_OPENGL
 #		define BGFX_CONFIG_RENDERER_OPENGL (0 \
 					|| BX_PLATFORM_FREEBSD \
@@ -86,6 +91,10 @@
 #		define BGFX_CONFIG_RENDERER_DIRECT3D12 0
 #	endif // BGFX_CONFIG_RENDERER_DIRECT3D12
 
+#	ifndef BGFX_CONFIG_RENDERER_METAL
+#		define BGFX_CONFIG_RENDERER_METAL 0
+#	endif // BGFX_CONFIG_RENDERER_METAL
+
 #	ifndef BGFX_CONFIG_RENDERER_OPENGL
 #		define BGFX_CONFIG_RENDERER_OPENGL 0
 #	endif // BGFX_CONFIG_RENDERER_OPENGL

+ 1 - 1
src/renderer_d3d12.cpp

@@ -6,7 +6,7 @@
 #include "bgfx_p.h"
 
 #if BGFX_CONFIG_RENDERER_DIRECT3D12
-#	include "../../d3d12/src/renderer_d3d12.cpp"
+#	include "../../bgfx-ext/src/renderer_d3d12.cpp"
 #else
 
 namespace bgfx { namespace d3d12

+ 23 - 0
src/renderer_mtl.cpp

@@ -0,0 +1,23 @@
+/*
+ * Copyright 2011-2015 Branimir Karadzic. All rights reserved.
+ * License: http://www.opensource.org/licenses/BSD-2-Clause
+ */
+
+#include "bgfx_p.h"
+#if BGFX_CONFIG_RENDERER_METAL
+#	include "../../bgfx-ext/src/renderer_mtl.cpp"
+#else
+
+namespace bgfx { namespace mtl
+{
+	RendererContextI* rendererCreate()
+	{
+		return NULL;
+	}
+
+	void rendererDestroy()
+	{
+	}
+} /* namespace mtl */ } // namespace bgfx
+
+#endif // BGFX_CONFIG_RENDERER_METAL

+ 1 - 1
src/renderer_vk.cpp

@@ -5,7 +5,7 @@
 
 #include "bgfx_p.h"
 #if BGFX_CONFIG_RENDERER_VULKAN
-#	include "../../vk/src/renderer_vk.cpp"
+#	include "../../bgfx-ext/src/renderer_vk.cpp"
 #else
 
 namespace bgfx { namespace vk

+ 1 - 0
src/vertexdecl.cpp

@@ -45,6 +45,7 @@ namespace bgfx
 		&s_attribTypeSizeDx9,  // Direct3D9
 		&s_attribTypeSizeDx1x, // Direct3D11
 		&s_attribTypeSizeDx1x, // Direct3D12
+		&s_attribTypeSizeGl,   // Metal
 		&s_attribTypeSizeGl,   // OpenGLES
 		&s_attribTypeSizeGl,   // OpenGL
 		&s_attribTypeSizeGl,   // Vulkan