Added DX12 stub.

This commit is contained in:
Branimir Karadžić 2014-10-11 11:24:37 -07:00
parent e9860f1637
commit 9126ca8fd7
8 changed files with 82 additions and 30 deletions

View file

@ -19,7 +19,7 @@ typedef enum bgfx_renderer_type
BGFX_RENDERER_TYPE_NULL,
BGFX_RENDERER_TYPE_DIRECT3D9,
BGFX_RENDERER_TYPE_DIRECT3D11,
BGFX_RENDERER_TYPE_OPENGLES,
BGFX_RENDERER_TYPE_OPENGLES = 4,
BGFX_RENDERER_TYPE_OPENGL,
BGFX_RENDERER_TYPE_COUNT

View file

@ -46,7 +46,7 @@ namespace bgfx
Null, //< No rendering.
Direct3D9, //< Direct3D 9.0
Direct3D11, //< Direct3D 11.0
OpenGLES, //< OpenGL ES 2.0+
OpenGLES = 4, //< OpenGL ES 2.0+
OpenGL, //< OpenGL 2.1+
Count

View file

@ -11,12 +11,15 @@ project "geometryc"
BX_DIR .. "include",
BGFX_DIR .. "include",
BGFX_DIR .. "3rdparty/forsyth-too",
BGFX_DIR .. "3rdparty/ib-compress",
BGFX_DIR .. "examples/common",
}
files {
BGFX_DIR .. "3rdparty/forsyth-too/**.cpp",
BGFX_DIR .. "3rdparty/forsyth-too/**.h",
BGFX_DIR .. "3rdparty/ib-compress/**.cpp",
BGFX_DIR .. "3rdparty/ib-compress/**.h",
BGFX_DIR .. "src/vertexdecl.**",
BGFX_DIR .. "tools/geometryc/**.cpp",
BGFX_DIR .. "tools/geometryc/**.h",

View file

@ -1300,6 +1300,9 @@ namespace bgfx
extern RendererContextI* rendererCreateD3D11();
extern void rendererDestroyD3D11();
extern RendererContextI* rendererCreateD3D12();
extern void rendererDestroyD3D12();
struct RendererCreator
{
RendererCreateFn createFn;
@ -1308,35 +1311,37 @@ namespace bgfx
bool supported;
};
static const RendererCreator s_rendererCreator[RendererType::Count] =
static const RendererCreator s_rendererCreator[] =
{
{ rendererCreateNULL, rendererDestroyNULL, BGFX_RENDERER_NULL_NAME, !!BGFX_CONFIG_RENDERER_NULL }, // Null
{ rendererCreateD3D9, rendererDestroyD3D9, BGFX_RENDERER_DIRECT3D9_NAME, !!BGFX_CONFIG_RENDERER_DIRECT3D9 }, // Direct3D9
{ rendererCreateD3D11, rendererDestroyD3D11, BGFX_RENDERER_DIRECT3D11_NAME, !!BGFX_CONFIG_RENDERER_DIRECT3D11 }, // Direct3D11
{ 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
};
BX_STATIC_ASSERT(BX_COUNTOF(s_rendererCreator) == RendererType::Count);
uint32_t getWindowsVersion()
static RendererDestroyFn s_rendererDestroyFn;
bool windowsVersionIsOrAbove(uint32_t _winver)
{
#if BX_PLATFORM_WINDOWS
OSVERSIONINFOEXA ovi;
memset(&ovi, 0, sizeof(ovi) );
ovi.dwOSVersionInfoSize = sizeof(ovi);
if (!GetVersionExA( (LPOSVERSIONINFOA)&ovi) )
{
return 0x0501; // _WIN32_WINNT_WINXP
}
// _WIN32_WINNT_WINBLUE 0x0602
// _WIN32_WINNT_WINBLUE 0x0603
// _WIN32_WINNT_WIN8 0x0602
// _WIN32_WINNT_WIN7 0x0601
// _WIN32_WINNT_VISTA 0x0600
return (ovi.dwMajorVersion<<8)
| ovi.dwMinorVersion
;
ovi.dwMajorVersion = HIBYTE(_winver);
ovi.dwMinorVersion = LOBYTE(_winver);
DWORDLONG cond = 0;
VER_SET_CONDITION(cond, VER_MAJORVERSION, VER_GREATER_EQUAL);
VER_SET_CONDITION(cond, VER_MINORVERSION, VER_GREATER_EQUAL);
return !!VerifyVersionInfoA(&ovi, VER_MAJORVERSION | VER_MINORVERSION, cond);
#else
return 0;
return false;
#endif // BX_PLATFORM_WINDOWS
}
@ -1349,7 +1354,12 @@ again:
{
RendererType::Enum first = RendererType::Direct3D9;
RendererType::Enum second = RendererType::Direct3D11;
if (0x601 <= getWindowsVersion() )
if (windowsVersionIsOrAbove(0x0603) )
{
first = RendererType::Direct3D11 /* Direct3D12 */;
second = RendererType::Direct3D11;
}
else if (windowsVersionIsOrAbove(0x0601) )
{
first = RendererType::Direct3D11;
second = RendererType::Direct3D9;
@ -1400,13 +1410,14 @@ again:
goto again;
}
s_rendererDestroyFn = s_rendererCreator[_type].destroyFn;
return renderCtx;
}
void rendererDestroy()
{
const RendererType::Enum type = getRendererType();
s_rendererCreator[type].destroyFn();
s_rendererDestroyFn();
}
void Context::rendererExecCommands(CommandBuffer& _cmdbuf)

View file

@ -139,6 +139,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_NULL_NAME "NULL"
#if BGFX_CONFIG_RENDERER_OPENGL

View file

@ -14,6 +14,7 @@
#if !defined(BGFX_CONFIG_RENDERER_DIRECT3D9) \
&& !defined(BGFX_CONFIG_RENDERER_DIRECT3D11) \
&& !defined(BGFX_CONFIG_RENDERER_DIRECT3D12) \
&& !defined(BGFX_CONFIG_RENDERER_OPENGL) \
&& !defined(BGFX_CONFIG_RENDERER_OPENGLES) \
&& !defined(BGFX_CONFIG_RENDERER_NULL)
@ -31,6 +32,12 @@
? 1 : 0)
# endif // BGFX_CONFIG_RENDERER_DIRECT3D11
# ifndef BGFX_CONFIG_RENDERER_DIRECT3D12
# define BGFX_CONFIG_RENDERER_DIRECT3D12 (0 \
|| (BX_PLATFORM_WINDOWS && BX_PLATFORM_WINDOWS >= 0x0603 /*_WIN32_WINNT_WINBLUE*/) \
? 1 : 0)
# endif // BGFX_CONFIG_RENDERER_DIRECT3D12
# ifndef BGFX_CONFIG_RENDERER_OPENGL
# define BGFX_CONFIG_RENDERER_OPENGL (0 \
|| BX_PLATFORM_WINDOWS \
@ -55,6 +62,7 @@
# define BGFX_CONFIG_RENDERER_NULL (!(0 \
|| BGFX_CONFIG_RENDERER_DIRECT3D9 \
|| BGFX_CONFIG_RENDERER_DIRECT3D11 \
|| BGFX_CONFIG_RENDERER_DIRECT3D12 \
|| BGFX_CONFIG_RENDERER_OPENGL \
|| BGFX_CONFIG_RENDERER_OPENGLES \
? 1 : 0) )
@ -68,6 +76,10 @@
# define BGFX_CONFIG_RENDERER_DIRECT3D11 0
# endif // BGFX_CONFIG_RENDERER_DIRECT3D11
# ifndef BGFX_CONFIG_RENDERER_DIRECT3D12
# define BGFX_CONFIG_RENDERER_DIRECT3D12 0
# endif // BGFX_CONFIG_RENDERER_DIRECT3D12
# ifndef BGFX_CONFIG_RENDERER_OPENGL
# define BGFX_CONFIG_RENDERER_OPENGL 0
# endif // BGFX_CONFIG_RENDERER_OPENGL

23
src/renderer_d3d12.cpp Normal file
View file

@ -0,0 +1,23 @@
/*
* Copyright 2011-2014 Branimir Karadzic. All rights reserved.
* License: http://www.opensource.org/licenses/BSD-2-Clause
*/
#include "bgfx_p.h"
#if BGFX_CONFIG_RENDERER_DIRECT3D12
#else
namespace bgfx
{
RendererContextI* rendererCreateD3D12()
{
return NULL;
}
void rendererDestroyD3D12()
{
}
} // namespace bgfx
#endif // BGFX_CONFIG_RENDERER_DIRECT3D12

View file

@ -23,7 +23,7 @@ namespace bgfx
{ 4, 8, 12, 16 },
};
static const uint8_t s_attribTypeSizeDx11[AttribType::Count][4] =
static const uint8_t s_attribTypeSizeDx1x[AttribType::Count][4] =
{
{ 1, 2, 4, 4 },
{ 2, 4, 8, 8 },
@ -39,22 +39,24 @@ namespace bgfx
{ 4, 8, 12, 16 },
};
static const uint8_t (*s_attribTypeSize[RendererType::Count])[AttribType::Count][4] =
static const uint8_t (*s_attribTypeSize[])[AttribType::Count][4] =
{
#if BGFX_CONFIG_RENDERER_DIRECT3D9
&s_attribTypeSizeDx9,
#elif BGFX_CONFIG_RENDERER_DIRECT3D11
&s_attribTypeSizeDx11,
#elif BGFX_CONFIG_RENDERER_DIRECT3D11 || BGFX_CONFIG_RENDERER_DIRECT3D12
&s_attribTypeSizeDx1x,
#elif BGFX_CONFIG_RENDERER_OPENGL || BGFX_CONFIG_RENDERER_OPENGLES
&s_attribTypeSizeGl,
#else
&s_attribTypeSizeDx9,
#endif // BGFX_CONFIG_RENDERER_
&s_attribTypeSizeDx9,
&s_attribTypeSizeDx11,
&s_attribTypeSizeGl,
&s_attribTypeSizeGl,
&s_attribTypeSizeDx9, // Direct3D9
&s_attribTypeSizeDx1x, // Direct3D11
&s_attribTypeSizeDx1x, // Direct3D12
&s_attribTypeSizeGl, // OpenGLES
&s_attribTypeSizeGl, // OpenGL
};
BX_STATIC_ASSERT(BX_COUNTOF(s_attribTypeSize) == bgfx::RendererType::Count);
void initAttribTypeSizeTable(RendererType::Enum _type)
{