From 2ce33465d581fe2d37fc35b022607cda303659b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Thu, 5 Mar 2015 20:34:39 -0800 Subject: [PATCH] Added Vulkan stub. --- include/bgfx.c99.h | 4 +++- include/bgfx.h | 1 + src/bgfx.cpp | 4 ++++ src/bgfx_p.h | 1 + src/config.h | 9 +++++++++ src/renderer_vk.cpp | 22 ++++++++++++++++++++++ src/vertexdecl.cpp | 5 +++-- 7 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 src/renderer_vk.cpp diff --git a/include/bgfx.c99.h b/include/bgfx.c99.h index 1368c8b21..43effbcc5 100644 --- a/include/bgfx.c99.h +++ b/include/bgfx.c99.h @@ -19,8 +19,10 @@ typedef enum bgfx_renderer_type BGFX_RENDERER_TYPE_NULL, BGFX_RENDERER_TYPE_DIRECT3D9, BGFX_RENDERER_TYPE_DIRECT3D11, - BGFX_RENDERER_TYPE_OPENGLES = 4, + BGFX_RENDERER_TYPE_DIRECT3D12, + BGFX_RENDERER_TYPE_OPENGLES, BGFX_RENDERER_TYPE_OPENGL, + BGFX_RENDERER_TYPE_VULKAN, BGFX_RENDERER_TYPE_COUNT diff --git a/include/bgfx.h b/include/bgfx.h index 00c6637b9..dd3b4c5db 100644 --- a/include/bgfx.h +++ b/include/bgfx.h @@ -49,6 +49,7 @@ namespace bgfx Direct3D12, //!< Direct3D 12.0 OpenGLES, //!< OpenGL ES 2.0+ OpenGL, //!< OpenGL 2.1+ + Vulkan, //!< Vulkan Count }; diff --git a/src/bgfx.cpp b/src/bgfx.cpp index 7775f60a0..709622ae2 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -1347,6 +1347,9 @@ namespace bgfx extern RendererContextI* rendererCreateD3D12(); extern void rendererDestroyD3D12(); + extern RendererContextI* rendererCreateVK(); + extern void rendererDestroyVK(); + struct RendererCreator { RendererCreateFn createFn; @@ -1363,6 +1366,7 @@ namespace bgfx { rendererCreateD3D12, rendererDestroyD3D12, BGFX_RENDERER_DIRECT3D12_NAME, !!BGFX_CONFIG_RENDERER_DIRECT3D12 }, // Direct3D12 { rendererCreateGL, rendererDestroyGL, BGFX_RENDERER_OPENGL_NAME, !!BGFX_CONFIG_RENDERER_OPENGLES }, // OpenGLES { rendererCreateGL, rendererDestroyGL, BGFX_RENDERER_OPENGL_NAME, !!BGFX_CONFIG_RENDERER_OPENGL }, // OpenGL + { rendererCreateVK, rendererDestroyVK, BGFX_RENDERER_VULKAN_NAME, !!BGFX_CONFIG_RENDERER_VULKAN }, // Vulkan }; BX_STATIC_ASSERT(BX_COUNTOF(s_rendererCreator) == RendererType::Count); diff --git a/src/bgfx_p.h b/src/bgfx_p.h index 166d19c59..11ccfa7b8 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -154,6 +154,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_VULKAN_NAME "Vulkan" #define BGFX_RENDERER_NULL_NAME "NULL" #if BGFX_CONFIG_RENDERER_OPENGL diff --git a/src/config.h b/src/config.h index 396e65063..07fde5584 100644 --- a/src/config.h +++ b/src/config.h @@ -17,6 +17,7 @@ && !defined(BGFX_CONFIG_RENDERER_DIRECT3D12) \ && !defined(BGFX_CONFIG_RENDERER_OPENGL) \ && !defined(BGFX_CONFIG_RENDERER_OPENGLES) \ + && !defined(BGFX_CONFIG_RENDERER_VULKAN) \ && !defined(BGFX_CONFIG_RENDERER_NULL) # ifndef BGFX_CONFIG_RENDERER_DIRECT3D9 @@ -59,6 +60,10 @@ ? 1 : 0) # endif // BGFX_CONFIG_RENDERER_OPENGLES +# ifndef BGFX_CONFIG_RENDERER_VULKAN +# define BGFX_CONFIG_RENDERER_VULKAN 0 +# endif // BGFX_CONFIG_RENDERER_VULKAN + # ifndef BGFX_CONFIG_RENDERER_NULL # define BGFX_CONFIG_RENDERER_NULL (!(0 \ || BGFX_CONFIG_RENDERER_DIRECT3D9 \ @@ -89,6 +94,10 @@ # define BGFX_CONFIG_RENDERER_OPENGLES 0 # endif // BGFX_CONFIG_RENDERER_OPENGLES +# ifndef BGFX_CONFIG_RENDERER_VULKAN +# define BGFX_CONFIG_RENDERER_VULKAN 0 +# endif // BGFX_CONFIG_RENDERER_VULKAN + # ifndef BGFX_CONFIG_RENDERER_NULL # define BGFX_CONFIG_RENDERER_NULL 0 # endif // BGFX_CONFIG_RENDERER_NULL diff --git a/src/renderer_vk.cpp b/src/renderer_vk.cpp new file mode 100644 index 000000000..b9977c53d --- /dev/null +++ b/src/renderer_vk.cpp @@ -0,0 +1,22 @@ +/* + * 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_VULKAN +# include "../../vk/src/renderer_vk.cpp" +#else + +namespace bgfx +{ + RendererContextI* rendererCreateVK() + { + return NULL; + } + void rendererDestroyVK() + { + } +} // namespace bgfx + +#endif // BGFX_CONFIG_RENDERER_VULKAN diff --git a/src/vertexdecl.cpp b/src/vertexdecl.cpp index ed5059a7a..c0c4edeef 100644 --- a/src/vertexdecl.cpp +++ b/src/vertexdecl.cpp @@ -45,7 +45,7 @@ namespace bgfx &s_attribTypeSizeDx9, #elif BGFX_CONFIG_RENDERER_DIRECT3D11 || BGFX_CONFIG_RENDERER_DIRECT3D12 &s_attribTypeSizeDx1x, -#elif BGFX_CONFIG_RENDERER_OPENGL || BGFX_CONFIG_RENDERER_OPENGLES +#elif BGFX_CONFIG_RENDERER_OPENGL || BGFX_CONFIG_RENDERER_OPENGLES || BGFX_CONFIG_RENDERER_VULKAN &s_attribTypeSizeGl, #else &s_attribTypeSizeDx9, @@ -55,6 +55,7 @@ namespace bgfx &s_attribTypeSizeDx1x, // Direct3D12 &s_attribTypeSizeGl, // OpenGLES &s_attribTypeSizeGl, // OpenGL + &s_attribTypeSizeGl, // Vulkan }; BX_STATIC_ASSERT(BX_COUNTOF(s_attribTypeSize) == bgfx::RendererType::Count); @@ -140,7 +141,7 @@ namespace bgfx _asInt = !!(val&(1<<7) ); } - static const char* s_attrName[] = + static const char* s_attrName[] = { "Attrib::Position", "Attrib::Normal",