diff --git a/examples/common/bgfx_utils.cpp b/examples/common/bgfx_utils.cpp index e9883557a..fa7dcc9d5 100644 --- a/examples/common/bgfx_utils.cpp +++ b/examples/common/bgfx_utils.cpp @@ -110,6 +110,7 @@ static bgfx::ShaderHandle loadShader(bx::FileReaderI* _reader, const char* _name case bgfx::RendererType::Direct3D12: shaderPath = "shaders/dx11/"; break; case bgfx::RendererType::Gnm: shaderPath = "shaders/pssl/"; break; case bgfx::RendererType::Metal: shaderPath = "shaders/metal/"; break; + case bgfx::RendererType::Nvn: shaderPath = "shaders/nvn/"; break; case bgfx::RendererType::OpenGL: shaderPath = "shaders/glsl/"; break; case bgfx::RendererType::OpenGLES: shaderPath = "shaders/essl/"; break; case bgfx::RendererType::Vulkan: shaderPath = "shaders/spirv/"; break; diff --git a/include/bgfx/bgfx.h b/include/bgfx/bgfx.h index ed7a16a25..8dbef04c7 100644 --- a/include/bgfx/bgfx.h +++ b/include/bgfx/bgfx.h @@ -57,6 +57,7 @@ namespace bgfx Direct3D12, //!< Direct3D 12.0 Gnm, //!< GNM Metal, //!< Metal + Nvn, //!< NVN OpenGLES, //!< OpenGL ES 2.0+ OpenGL, //!< OpenGL 2.1+ Vulkan, //!< Vulkan diff --git a/include/bgfx/c99/bgfx.h b/include/bgfx/c99/bgfx.h index dc024fd18..824fd7b65 100644 --- a/include/bgfx/c99/bgfx.h +++ b/include/bgfx/c99/bgfx.h @@ -85,9 +85,10 @@ typedef enum bgfx_renderer_type BGFX_RENDERER_TYPE_DIRECT3D12, /** ( 3) Direct3D 12.0 */ BGFX_RENDERER_TYPE_GNM, /** ( 4) GNM */ BGFX_RENDERER_TYPE_METAL, /** ( 5) Metal */ - BGFX_RENDERER_TYPE_OPENGLES, /** ( 6) OpenGL ES 2.0+ */ - BGFX_RENDERER_TYPE_OPENGL, /** ( 7) OpenGL 2.1+ */ - BGFX_RENDERER_TYPE_VULKAN, /** ( 8) Vulkan */ + BGFX_RENDERER_TYPE_NVN, /** ( 6) NVN */ + BGFX_RENDERER_TYPE_OPENGLES, /** ( 7) OpenGL ES 2.0+ */ + BGFX_RENDERER_TYPE_OPENGL, /** ( 8) OpenGL 2.1+ */ + BGFX_RENDERER_TYPE_VULKAN, /** ( 9) Vulkan */ BGFX_RENDERER_TYPE_COUNT diff --git a/include/bgfx/embedded_shader.h b/include/bgfx/embedded_shader.h index 577bc9659..704c6e063 100644 --- a/include/bgfx/embedded_shader.h +++ b/include/bgfx/embedded_shader.h @@ -14,8 +14,9 @@ #define BGFX_EMBEDDED_SHADER_PSSL(...) #define BGFX_EMBEDDED_SHADER_ESSL(...) #define BGFX_EMBEDDED_SHADER_GLSL(...) -#define BGFX_EMBEDDED_SHADER_SPIRV(...) #define BGFX_EMBEDDED_SHADER_METAL(...) +#define BGFX_EMBEDDED_SHADER_NVN(...) +#define BGFX_EMBEDDED_SHADER_SPIRV(...) #define BGFX_PLATFORM_SUPPORTS_DX9BC (0 \ || BX_PLATFORM_WINDOWS \ @@ -48,6 +49,9 @@ || BX_PLATFORM_IOS \ || BX_PLATFORM_OSX \ ) +#define BGFX_PLATFORM_SUPPORTS_NVN (0 \ + || BX_PLATFORM_NX \ + ) #define BGFX_PLATFORM_SUPPORTS_SPIRV (0 \ || BX_PLATFORM_ANDROID \ || BX_PLATFORM_LINUX \ @@ -105,6 +109,7 @@ BGFX_EMBEDDED_SHADER_DXBC (bgfx::RendererType::Direct3D12, _name) \ BGFX_EMBEDDED_SHADER_PSSL (bgfx::RendererType::Gnm, _name) \ BGFX_EMBEDDED_SHADER_METAL(bgfx::RendererType::Metal, _name) \ + BGFX_EMBEDDED_SHADER_NVN (bgfx::RendererType::Nvn, _name) \ BGFX_EMBEDDED_SHADER_ESSL (bgfx::RendererType::OpenGLES, _name) \ BGFX_EMBEDDED_SHADER_GLSL (bgfx::RendererType::OpenGL, _name) \ BGFX_EMBEDDED_SHADER_SPIRV(bgfx::RendererType::Vulkan, _name) \ diff --git a/scripts/bgfx.idl b/scripts/bgfx.idl index dcb397b4f..aff532739 100644 --- a/scripts/bgfx.idl +++ b/scripts/bgfx.idl @@ -42,6 +42,7 @@ enum.RendererType { comment = "Renderer types:" } .Direct3D12 --- Direct3D 12.0 .Gnm --- GNM .Metal --- Metal + .Nvn --- NVN .OpenGLES --- OpenGL ES 2.0+ .OpenGL --- OpenGL 2.1+ .Vulkan --- Vulkan diff --git a/scripts/bgfx.lua b/scripts/bgfx.lua index b02ae85b9..1043e8abb 100644 --- a/scripts/bgfx.lua +++ b/scripts/bgfx.lua @@ -153,11 +153,16 @@ function bgfxProjectBase(_kind, _defines) path.join(BGFX_DIR, "src/**.bin.h"), } - overridefiles(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-ext"), { + overridefiles(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-gnm"), { path.join(BGFX_DIR, "src/renderer_gnm.cpp"), path.join(BGFX_DIR, "src/renderer_gnm.h"), }) + overridefiles(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-nvn"), { + path.join(BGFX_DIR, "src/renderer_nvn.cpp"), + path.join(BGFX_DIR, "src/renderer_nvn.h"), + }) + if _OPTIONS["with-amalgamated"] then excludes { path.join(BGFX_DIR, "src/bgfx.cpp"), @@ -205,10 +210,16 @@ function bgfxProjectBase(_kind, _defines) } end - if filesexist(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-ext"), { + if filesexist(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-gnm"), { path.join(BGFX_DIR, "scripts/bgfx.lua"), }) then - dofile(path.join(BGFX_DIR, "../bgfx-ext/scripts/bgfx.lua") ) + dofile(path.join(BGFX_DIR, "../bgfx-gnm/scripts/bgfx.lua") ) + end + + if filesexist(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-nvn"), { + path.join(BGFX_DIR, "scripts/bgfx.lua"), }) then + + dofile(path.join(BGFX_DIR, "../bgfx-nvn/scripts/bgfx.lua") ) end configuration {} diff --git a/src/bgfx.cpp b/src/bgfx.cpp index 6b39ed7ac..23bea7fc3 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -2436,6 +2436,7 @@ namespace bgfx BGFX_RENDERER_CONTEXT(d3d12); BGFX_RENDERER_CONTEXT(gnm); BGFX_RENDERER_CONTEXT(mtl); + BGFX_RENDERER_CONTEXT(nvn); BGFX_RENDERER_CONTEXT(gl); BGFX_RENDERER_CONTEXT(vk); @@ -2461,6 +2462,7 @@ namespace bgfx #else { noop::rendererCreate, noop::rendererDestroy, BGFX_RENDERER_NOOP_NAME, false }, // Noop #endif // BX_PLATFORM_OSX || BX_PLATFORM_IOS + { nvn::rendererCreate, nvn::rendererDestroy, BGFX_RENDERER_NVN_NAME, !!BGFX_CONFIG_RENDERER_NVN }, // NVN { 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 5e5a087d4..b206e7128 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -221,9 +221,10 @@ namespace stl = std; #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_GNM_NAME "GNM" +#define BGFX_RENDERER_METAL_NAME "Metal" +#define BGFX_RENDERER_NVN_NAME "NVN" +#define BGFX_RENDERER_VULKAN_NAME "Vulkan" #define BGFX_RENDERER_NOOP_NAME "Noop" #if BGFX_CONFIG_RENDERER_OPENGL diff --git a/src/config.h b/src/config.h index 1d4468916..5d8275713 100644 --- a/src/config.h +++ b/src/config.h @@ -15,11 +15,12 @@ #if !defined(BGFX_CONFIG_RENDERER_DIRECT3D9) \ && !defined(BGFX_CONFIG_RENDERER_DIRECT3D11) \ && !defined(BGFX_CONFIG_RENDERER_DIRECT3D12) \ + && !defined(BGFX_CONFIG_RENDERER_GNM) \ && !defined(BGFX_CONFIG_RENDERER_METAL) \ + && !defined(BGFX_CONFIG_RENDERER_NVN) \ && !defined(BGFX_CONFIG_RENDERER_OPENGL) \ && !defined(BGFX_CONFIG_RENDERER_OPENGLES) \ - && !defined(BGFX_CONFIG_RENDERER_VULKAN) \ - && !defined(BGFX_CONFIG_RENDERER_GNM) + && !defined(BGFX_CONFIG_RENDERER_VULKAN) # ifndef BGFX_CONFIG_RENDERER_DIRECT3D9 # define BGFX_CONFIG_RENDERER_DIRECT3D9 (0 \ @@ -43,6 +44,12 @@ ? 1 : 0) # endif // BGFX_CONFIG_RENDERER_DIRECT3D12 +# ifndef BGFX_CONFIG_RENDERER_GNM +# define BGFX_CONFIG_RENDERER_GNM (0 \ + || BX_PLATFORM_PS4 \ + ? 1 : 0) +# endif // BGFX_CONFIG_RENDERER_GNM + # ifndef BGFX_CONFIG_RENDERER_METAL # define BGFX_CONFIG_RENDERER_METAL (0 \ || (BX_PLATFORM_IOS && BX_CPU_ARM) \ @@ -50,6 +57,12 @@ ? 1 : 0) # endif // BGFX_CONFIG_RENDERER_METAL +# ifndef BGFX_CONFIG_RENDERER_NVN +# define BGFX_CONFIG_RENDERER_NVN (0 \ + || BX_PLATFORM_NX \ + ? 1 : 0) +# endif // BGFX_CONFIG_RENDERER_NVN + # ifndef BGFX_CONFIG_RENDERER_OPENGL # define BGFX_CONFIG_RENDERER_OPENGL (0 \ || BX_PLATFORM_BSD \ @@ -79,12 +92,6 @@ ? 1 : 0) # endif // BGFX_CONFIG_RENDERER_VULKAN -# ifndef BGFX_CONFIG_RENDERER_GNM -# define BGFX_CONFIG_RENDERER_GNM (0 \ - || BX_PLATFORM_PS4 \ - ? 1 : 0) -# endif // BGFX_CONFIG_RENDERER_GNM - #else # ifndef BGFX_CONFIG_RENDERER_DIRECT3D9 # define BGFX_CONFIG_RENDERER_DIRECT3D9 0 @@ -98,10 +105,18 @@ # define BGFX_CONFIG_RENDERER_DIRECT3D12 0 # endif // BGFX_CONFIG_RENDERER_DIRECT3D12 +# ifndef BGFX_CONFIG_RENDERER_GNM +# define BGFX_CONFIG_RENDERER_GNM 0 +# endif // BGFX_CONFIG_RENDERER_GNM + # ifndef BGFX_CONFIG_RENDERER_METAL # define BGFX_CONFIG_RENDERER_METAL 0 # endif // BGFX_CONFIG_RENDERER_METAL +# ifndef BGFX_CONFIG_RENDERER_NVN +# define BGFX_CONFIG_RENDERER_NVN 0 +# endif // BGFX_CONFIG_RENDERER_NVN + # ifndef BGFX_CONFIG_RENDERER_OPENGL # define BGFX_CONFIG_RENDERER_OPENGL 0 # endif // BGFX_CONFIG_RENDERER_OPENGL @@ -113,10 +128,6 @@ # ifndef BGFX_CONFIG_RENDERER_VULKAN # define BGFX_CONFIG_RENDERER_VULKAN 0 # endif // BGFX_CONFIG_RENDERER_VULKAN - -# ifndef BGFX_CONFIG_RENDERER_GNM -# define BGFX_CONFIG_RENDERER_GNM 0 -# endif // BGFX_CONFIG_RENDERER_GNM #endif // !defined... #if BGFX_CONFIG_RENDERER_OPENGL && BGFX_CONFIG_RENDERER_OPENGL < 21 diff --git a/src/renderer_nvn.cpp b/src/renderer_nvn.cpp new file mode 100644 index 000000000..11a968183 --- /dev/null +++ b/src/renderer_nvn.cpp @@ -0,0 +1,45 @@ +/* + * Copyright 2011-2019 Branimir Karadzic. All rights reserved. + * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause + */ + +#include "bgfx_p.h" + +namespace bgfx +{ + +#define BGFX_DECLARE_EMBEDDED_SHADER(_name) \ + extern const uint8_t* BX_CONCATENATE(_name, _nvn); \ + extern const uint32_t BX_CONCATENATE(_name, _nvn_size); \ + static const uint8_t BX_CONCATENATE(_name, _int_nvn)[] = { 0 }; \ + const uint8_t* BX_CONCATENATE(_name, _nvn) = &BX_CONCATENATE(_name, _int_nvn)[0]; \ + const uint32_t BX_CONCATENATE(_name, _nvn_size) = 1 + +BGFX_DECLARE_EMBEDDED_SHADER(vs_debugfont); +BGFX_DECLARE_EMBEDDED_SHADER(fs_debugfont); +BGFX_DECLARE_EMBEDDED_SHADER(vs_clear); +BGFX_DECLARE_EMBEDDED_SHADER(fs_clear0); +BGFX_DECLARE_EMBEDDED_SHADER(fs_clear1); +BGFX_DECLARE_EMBEDDED_SHADER(fs_clear2); +BGFX_DECLARE_EMBEDDED_SHADER(fs_clear3); +BGFX_DECLARE_EMBEDDED_SHADER(fs_clear4); +BGFX_DECLARE_EMBEDDED_SHADER(fs_clear5); +BGFX_DECLARE_EMBEDDED_SHADER(fs_clear6); +BGFX_DECLARE_EMBEDDED_SHADER(fs_clear7); + +#undef BGFX_DECLARE_EMBEDDED_SHADER + +} // namespace bgfx + +namespace bgfx { namespace nvn +{ + RendererContextI* rendererCreate(const Init& _init) + { + BX_UNUSED(_init); + return NULL; + } + + void rendererDestroy() + { + } +} /* namespace nvn */ } // namespace bgfx diff --git a/src/vertexdecl.cpp b/src/vertexdecl.cpp index 0767a6439..4a67b71c3 100644 --- a/src/vertexdecl.cpp +++ b/src/vertexdecl.cpp @@ -49,6 +49,7 @@ namespace bgfx &s_attribTypeSizeD3D1x, // Direct3D12 &s_attribTypeSizeD3D1x, // Gnm &s_attribTypeSizeGl, // Metal + &s_attribTypeSizeGl, // Nvn &s_attribTypeSizeGl, // OpenGLES &s_attribTypeSizeGl, // OpenGL &s_attribTypeSizeD3D1x, // Vulkan