diff --git a/include/bgfx.c99.h b/include/bgfx.c99.h index 6a8e1ecab..91b8a5be2 100644 --- a/include/bgfx.c99.h +++ b/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, diff --git a/include/bgfx.h b/include/bgfx.h index 9d00be6c0..82faf053c 100644 --- a/include/bgfx.h +++ b/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 diff --git a/src/bgfx.cpp b/src/bgfx.cpp index c5fba4e04..1d53bd986 100644 --- a/src/bgfx.cpp +++ b/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 diff --git a/src/bgfx_p.h b/src/bgfx_p.h index 0d78baf0e..1156740ee 100644 --- a/src/bgfx_p.h +++ b/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" diff --git a/src/config.h b/src/config.h index 9323a1388..8a00e6fcd 100644 --- a/src/config.h +++ b/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 diff --git a/src/renderer_d3d12.cpp b/src/renderer_d3d12.cpp index b41207cbc..03736ea4a 100644 --- a/src/renderer_d3d12.cpp +++ b/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 diff --git a/src/renderer_mtl.cpp b/src/renderer_mtl.cpp new file mode 100644 index 000000000..feeddd00a --- /dev/null +++ b/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 diff --git a/src/renderer_vk.cpp b/src/renderer_vk.cpp index e2ff8cdfe..13bfb1728 100644 --- a/src/renderer_vk.cpp +++ b/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 diff --git a/src/vertexdecl.cpp b/src/vertexdecl.cpp index 83435fa8c..78d207600 100644 --- a/src/vertexdecl.cpp +++ b/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