mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-17 20:52:36 +01:00
Cleanup.
This commit is contained in:
@@ -760,7 +760,7 @@ Args::Args(int _argc, char** _argv)
|
||||
}
|
||||
else if (cmdLine.hasArg("noop") )
|
||||
{
|
||||
m_type = bgfx::RendererType::Null;
|
||||
m_type = bgfx::RendererType::Noop;
|
||||
}
|
||||
else if (BX_ENABLED(BX_PLATFORM_WINDOWS) )
|
||||
{
|
||||
|
||||
@@ -52,15 +52,15 @@ namespace bgfx
|
||||
/// Renderer types:
|
||||
enum Enum
|
||||
{
|
||||
Null, //!< No rendering.
|
||||
Noop, //!< No rendering.
|
||||
Direct3D9, //!< Direct3D 9.0
|
||||
Direct3D11, //!< Direct3D 11.0
|
||||
Direct3D12, //!< Direct3D 12.0
|
||||
Gnm, //!< GNM
|
||||
Metal, //!< Metal
|
||||
OpenGLES, //!< OpenGL ES 2.0+
|
||||
OpenGL, //!< OpenGL 2.1+
|
||||
Vulkan, //!< Vulkan
|
||||
GNM, //!< GNM
|
||||
|
||||
Count
|
||||
};
|
||||
@@ -722,7 +722,7 @@ namespace bgfx
|
||||
///
|
||||
/// @attention C99 equivalent is `bgfx_vertex_decl_begin`.
|
||||
///
|
||||
VertexDecl& begin(RendererType::Enum _renderer = RendererType::Null);
|
||||
VertexDecl& begin(RendererType::Enum _renderer = RendererType::Noop);
|
||||
|
||||
/// End VertexDecl.
|
||||
///
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#ifndef BGFX_DEFINES_H_HEADER_GUARD
|
||||
#define BGFX_DEFINES_H_HEADER_GUARD
|
||||
|
||||
#define BGFX_API_VERSION UINT32_C(22)
|
||||
#define BGFX_API_VERSION UINT32_C(23)
|
||||
|
||||
///
|
||||
#define BGFX_STATE_RGB_WRITE UINT64_C(0x0000000000000001) //!< Enable RGB write.
|
||||
|
||||
@@ -43,15 +43,15 @@
|
||||
|
||||
typedef enum bgfx_renderer_type
|
||||
{
|
||||
BGFX_RENDERER_TYPE_NULL,
|
||||
BGFX_RENDERER_TYPE_NOOP,
|
||||
BGFX_RENDERER_TYPE_DIRECT3D9,
|
||||
BGFX_RENDERER_TYPE_DIRECT3D11,
|
||||
BGFX_RENDERER_TYPE_DIRECT3D12,
|
||||
BGFX_RENDERER_TYPE_GNM,
|
||||
BGFX_RENDERER_TYPE_METAL,
|
||||
BGFX_RENDERER_TYPE_OPENGLES,
|
||||
BGFX_RENDERER_TYPE_OPENGL,
|
||||
BGFX_RENDERER_TYPE_VULKAN,
|
||||
BGFX_RENDERER_TYPE_GNM,
|
||||
|
||||
BGFX_RENDERER_TYPE_COUNT
|
||||
|
||||
|
||||
245
src/bgfx.cpp
245
src/bgfx.cpp
@@ -426,6 +426,87 @@ namespace bgfx
|
||||
va_end(argList);
|
||||
}
|
||||
|
||||
#include "vs_debugfont.bin.h"
|
||||
#include "fs_debugfont.bin.h"
|
||||
#include "vs_clear.bin.h"
|
||||
#include "fs_clear0.bin.h"
|
||||
#include "fs_clear1.bin.h"
|
||||
#include "fs_clear2.bin.h"
|
||||
#include "fs_clear3.bin.h"
|
||||
#include "fs_clear4.bin.h"
|
||||
#include "fs_clear5.bin.h"
|
||||
#include "fs_clear6.bin.h"
|
||||
#include "fs_clear7.bin.h"
|
||||
|
||||
struct EmbeddedShader
|
||||
{
|
||||
struct Data
|
||||
{
|
||||
bgfx::RendererType::Enum type;
|
||||
const uint8_t* data;
|
||||
uint32_t size;
|
||||
};
|
||||
|
||||
const char* name;
|
||||
Data data[RendererType::Count];
|
||||
};
|
||||
|
||||
#define BGFX_DECLARE_SHADER_EMBEDDED(_name) \
|
||||
{ \
|
||||
#_name, \
|
||||
{ \
|
||||
{ bgfx::RendererType::Direct3D9, BX_CONCATENATE(_name, _dx9 ), sizeof(BX_CONCATENATE(_name, _dx9 ) ) }, \
|
||||
{ bgfx::RendererType::Direct3D11, BX_CONCATENATE(_name, _dx11), sizeof(BX_CONCATENATE(_name, _dx11) ) }, \
|
||||
{ bgfx::RendererType::Direct3D12, BX_CONCATENATE(_name, _dx11), sizeof(BX_CONCATENATE(_name, _dx11) ) }, \
|
||||
{ bgfx::RendererType::Gnm, BX_CONCATENATE(_name, _glsl), sizeof(BX_CONCATENATE(_name, _glsl) ) }, \
|
||||
{ bgfx::RendererType::Metal, BX_CONCATENATE(_name, _mtl ), sizeof(BX_CONCATENATE(_name, _mtl ) ) }, \
|
||||
{ bgfx::RendererType::OpenGL, BX_CONCATENATE(_name, _glsl), sizeof(BX_CONCATENATE(_name, _glsl) ) }, \
|
||||
{ bgfx::RendererType::OpenGLES, BX_CONCATENATE(_name, _glsl), sizeof(BX_CONCATENATE(_name, _glsl) ) }, \
|
||||
{ bgfx::RendererType::Vulkan, BX_CONCATENATE(_name, _glsl), sizeof(BX_CONCATENATE(_name, _glsl) ) }, \
|
||||
{ bgfx::RendererType::Count, NULL, 0 }, \
|
||||
} \
|
||||
}
|
||||
|
||||
static const EmbeddedShader s_embeddedShaders[] =
|
||||
{
|
||||
BGFX_DECLARE_SHADER_EMBEDDED(vs_debugfont),
|
||||
BGFX_DECLARE_SHADER_EMBEDDED(fs_debugfont),
|
||||
|
||||
BGFX_DECLARE_SHADER_EMBEDDED(vs_clear),
|
||||
|
||||
BGFX_DECLARE_SHADER_EMBEDDED(fs_clear0),
|
||||
BGFX_DECLARE_SHADER_EMBEDDED(fs_clear1),
|
||||
BGFX_DECLARE_SHADER_EMBEDDED(fs_clear2),
|
||||
BGFX_DECLARE_SHADER_EMBEDDED(fs_clear3),
|
||||
BGFX_DECLARE_SHADER_EMBEDDED(fs_clear4),
|
||||
BGFX_DECLARE_SHADER_EMBEDDED(fs_clear5),
|
||||
BGFX_DECLARE_SHADER_EMBEDDED(fs_clear6),
|
||||
BGFX_DECLARE_SHADER_EMBEDDED(fs_clear7),
|
||||
|
||||
{ NULL, { bgfx::RendererType::Count, NULL, 0 } }
|
||||
};
|
||||
|
||||
static ShaderHandle createEmbeddedShader(RendererType::Enum _type, const char* _name)
|
||||
{
|
||||
for (const EmbeddedShader* es = s_embeddedShaders; NULL != es->name; ++es)
|
||||
{
|
||||
if (0 == strcmp(_name, es->name) )
|
||||
{
|
||||
for (const EmbeddedShader::Data* esd = es->data; RendererType::Count != esd->type; ++esd)
|
||||
{
|
||||
if (_type == esd->type)
|
||||
{
|
||||
return createShader(makeRef(esd->data, esd->size) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ShaderHandle handle = BGFX_INVALID_HANDLE;
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
||||
#include "charset.h"
|
||||
|
||||
void charsetFillTexture(const uint8_t* _charset, uint8_t* _rgba, uint32_t _height, uint32_t _pitch, uint32_t _bpp)
|
||||
@@ -481,49 +562,8 @@ namespace bgfx
|
||||
, mem
|
||||
);
|
||||
|
||||
switch (g_caps.rendererType)
|
||||
{
|
||||
case RendererType::Direct3D9:
|
||||
mem = makeRef(vs_debugfont_dx9, sizeof(vs_debugfont_dx9) );
|
||||
break;
|
||||
|
||||
case RendererType::Direct3D11:
|
||||
case RendererType::Direct3D12:
|
||||
mem = makeRef(vs_debugfont_dx11, sizeof(vs_debugfont_dx11) );
|
||||
break;
|
||||
|
||||
case RendererType::Metal:
|
||||
mem = makeRef(vs_debugfont_mtl, sizeof(vs_debugfont_mtl) );
|
||||
break;
|
||||
|
||||
default:
|
||||
mem = makeRef(vs_debugfont_glsl, sizeof(vs_debugfont_glsl) );
|
||||
break;
|
||||
}
|
||||
|
||||
ShaderHandle vsh = createShader(mem);
|
||||
|
||||
switch (g_caps.rendererType)
|
||||
{
|
||||
case RendererType::Direct3D9:
|
||||
mem = makeRef(fs_debugfont_dx9, sizeof(fs_debugfont_dx9) );
|
||||
break;
|
||||
|
||||
case RendererType::Direct3D11:
|
||||
case RendererType::Direct3D12:
|
||||
mem = makeRef(fs_debugfont_dx11, sizeof(fs_debugfont_dx11) );
|
||||
break;
|
||||
|
||||
case RendererType::Metal:
|
||||
mem = makeRef(fs_debugfont_mtl, sizeof(fs_debugfont_mtl) );
|
||||
break;
|
||||
|
||||
default:
|
||||
mem = makeRef(fs_debugfont_glsl, sizeof(fs_debugfont_glsl) );
|
||||
break;
|
||||
}
|
||||
|
||||
ShaderHandle fsh = createShader(mem);
|
||||
ShaderHandle vsh = createEmbeddedShader(g_caps.rendererType, "vs_debugfont");
|
||||
ShaderHandle fsh = createEmbeddedShader(g_caps.rendererType, "fs_debugfont");
|
||||
|
||||
m_program = createProgram(vsh, fsh, true);
|
||||
|
||||
@@ -651,124 +691,21 @@ namespace bgfx
|
||||
{
|
||||
BGFX_CHECK_MAIN_THREAD();
|
||||
|
||||
if (RendererType::Null != g_caps.rendererType)
|
||||
if (RendererType::Noop != g_caps.rendererType)
|
||||
{
|
||||
m_decl
|
||||
.begin()
|
||||
.add(Attrib::Position, 3, AttribType::Float)
|
||||
.end();
|
||||
|
||||
ShaderHandle vsh = BGFX_INVALID_HANDLE;
|
||||
|
||||
struct Mem
|
||||
{
|
||||
Mem(const void* _data, size_t _size)
|
||||
: data(_data)
|
||||
, size(_size)
|
||||
{
|
||||
}
|
||||
|
||||
const void* data;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
const Memory* fragMem[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS];
|
||||
if (RendererType::Direct3D9 == g_caps.rendererType)
|
||||
{
|
||||
vsh = createShader(makeRef(vs_clear_dx9, sizeof(vs_clear_dx9) ) );
|
||||
|
||||
const Mem mem[] =
|
||||
{
|
||||
Mem(fs_clear0_dx9, sizeof(fs_clear0_dx9) ),
|
||||
Mem(fs_clear1_dx9, sizeof(fs_clear1_dx9) ),
|
||||
Mem(fs_clear2_dx9, sizeof(fs_clear2_dx9) ),
|
||||
Mem(fs_clear3_dx9, sizeof(fs_clear3_dx9) ),
|
||||
Mem(fs_clear4_dx9, sizeof(fs_clear4_dx9) ),
|
||||
Mem(fs_clear5_dx9, sizeof(fs_clear5_dx9) ),
|
||||
Mem(fs_clear6_dx9, sizeof(fs_clear6_dx9) ),
|
||||
Mem(fs_clear7_dx9, sizeof(fs_clear7_dx9) ),
|
||||
};
|
||||
|
||||
for (uint32_t ii = 0, num = g_caps.limits.maxFBAttachments; ii < num; ++ii)
|
||||
{
|
||||
fragMem[ii] = makeRef(mem[ii].data, uint32_t(mem[ii].size) );
|
||||
}
|
||||
}
|
||||
else if (RendererType::Direct3D11 == g_caps.rendererType
|
||||
|| RendererType::Direct3D12 == g_caps.rendererType)
|
||||
{
|
||||
vsh = createShader(makeRef(vs_clear_dx11, sizeof(vs_clear_dx11) ) );
|
||||
|
||||
const Mem mem[] =
|
||||
{
|
||||
Mem(fs_clear0_dx11, sizeof(fs_clear0_dx11) ),
|
||||
Mem(fs_clear1_dx11, sizeof(fs_clear1_dx11) ),
|
||||
Mem(fs_clear2_dx11, sizeof(fs_clear2_dx11) ),
|
||||
Mem(fs_clear3_dx11, sizeof(fs_clear3_dx11) ),
|
||||
Mem(fs_clear4_dx11, sizeof(fs_clear4_dx11) ),
|
||||
Mem(fs_clear5_dx11, sizeof(fs_clear5_dx11) ),
|
||||
Mem(fs_clear6_dx11, sizeof(fs_clear6_dx11) ),
|
||||
Mem(fs_clear7_dx11, sizeof(fs_clear7_dx11) ),
|
||||
};
|
||||
|
||||
for (uint32_t ii = 0, num = g_caps.limits.maxFBAttachments; ii < num; ++ii)
|
||||
{
|
||||
fragMem[ii] = makeRef(mem[ii].data, uint32_t(mem[ii].size) );
|
||||
}
|
||||
}
|
||||
else if (RendererType::OpenGLES == g_caps.rendererType
|
||||
|| RendererType::OpenGL == g_caps.rendererType
|
||||
|| RendererType::Vulkan == g_caps.rendererType
|
||||
|| RendererType::GNM == g_caps.rendererType)
|
||||
{
|
||||
vsh = createShader(makeRef(vs_clear_glsl, sizeof(vs_clear_glsl) ) );
|
||||
|
||||
const Mem mem[] =
|
||||
{
|
||||
Mem(fs_clear0_glsl, sizeof(fs_clear0_glsl) ),
|
||||
Mem(fs_clear1_glsl, sizeof(fs_clear1_glsl) ),
|
||||
Mem(fs_clear2_glsl, sizeof(fs_clear2_glsl) ),
|
||||
Mem(fs_clear3_glsl, sizeof(fs_clear3_glsl) ),
|
||||
Mem(fs_clear4_glsl, sizeof(fs_clear4_glsl) ),
|
||||
Mem(fs_clear5_glsl, sizeof(fs_clear5_glsl) ),
|
||||
Mem(fs_clear6_glsl, sizeof(fs_clear6_glsl) ),
|
||||
Mem(fs_clear7_glsl, sizeof(fs_clear7_glsl) ),
|
||||
};
|
||||
|
||||
for (uint32_t ii = 0, num = g_caps.limits.maxFBAttachments; ii < num; ++ii)
|
||||
{
|
||||
fragMem[ii] = makeRef(mem[ii].data, uint32_t(mem[ii].size) );
|
||||
}
|
||||
}
|
||||
else if (RendererType::Metal == g_caps.rendererType)
|
||||
{
|
||||
vsh = createShader(makeRef(vs_clear_mtl, sizeof(vs_clear_mtl) ) );
|
||||
|
||||
const Mem mem[] =
|
||||
{
|
||||
Mem(fs_clear0_mtl, sizeof(fs_clear0_mtl) ),
|
||||
Mem(fs_clear1_mtl, sizeof(fs_clear1_mtl) ),
|
||||
Mem(fs_clear2_mtl, sizeof(fs_clear2_mtl) ),
|
||||
Mem(fs_clear3_mtl, sizeof(fs_clear3_mtl) ),
|
||||
Mem(fs_clear4_mtl, sizeof(fs_clear4_mtl) ),
|
||||
Mem(fs_clear5_mtl, sizeof(fs_clear5_mtl) ),
|
||||
Mem(fs_clear6_mtl, sizeof(fs_clear6_mtl) ),
|
||||
Mem(fs_clear7_mtl, sizeof(fs_clear7_mtl) ),
|
||||
};
|
||||
|
||||
for (uint32_t ii = 0, num = g_caps.limits.maxFBAttachments; ii < num; ++ii)
|
||||
{
|
||||
fragMem[ii] = makeRef(mem[ii].data, uint32_t(mem[ii].size) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
BGFX_FATAL(false, Fatal::UnableToInitialize, "Unknown renderer type %d", g_caps.rendererType);
|
||||
}
|
||||
ShaderHandle vsh = createEmbeddedShader(g_caps.rendererType, "vs_clear");
|
||||
|
||||
for (uint32_t ii = 0, num = g_caps.limits.maxFBAttachments; ii < num; ++ii)
|
||||
{
|
||||
ShaderHandle fsh = createShader(fragMem[ii]);
|
||||
char name[32];
|
||||
bx::snprintf(name, BX_COUNTOF(name), "fs_clear%d", ii);
|
||||
ShaderHandle fsh = createEmbeddedShader(g_caps.rendererType, name);
|
||||
|
||||
m_program[ii] = createProgram(vsh, fsh);
|
||||
BX_CHECK(isValid(m_program[ii]), "Failed to create clear quad program.");
|
||||
destroyShader(fsh);
|
||||
@@ -784,7 +721,7 @@ namespace bgfx
|
||||
{
|
||||
BGFX_CHECK_MAIN_THREAD();
|
||||
|
||||
if (RendererType::Null != g_caps.rendererType)
|
||||
if (RendererType::Noop != g_caps.rendererType)
|
||||
{
|
||||
for (uint32_t ii = 0, num = g_caps.limits.maxFBAttachments; ii < num; ++ii)
|
||||
{
|
||||
@@ -1849,7 +1786,7 @@ namespace bgfx
|
||||
score += 1000;
|
||||
}
|
||||
|
||||
score += RendererType::Null != renderer ? 1 : 0;
|
||||
score += RendererType::Noop != renderer ? 1 : 0;
|
||||
|
||||
if (BX_ENABLED(BX_PLATFORM_WINDOWS) )
|
||||
{
|
||||
|
||||
@@ -522,16 +522,3 @@ static const uint8_t vga8x16[256*16] =
|
||||
0x00, 0x00, 0x00, 0x00, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
#include "vs_debugfont.bin.h"
|
||||
#include "fs_debugfont.bin.h"
|
||||
|
||||
#include "vs_clear.bin.h"
|
||||
#include "fs_clear0.bin.h"
|
||||
#include "fs_clear1.bin.h"
|
||||
#include "fs_clear2.bin.h"
|
||||
#include "fs_clear3.bin.h"
|
||||
#include "fs_clear4.bin.h"
|
||||
#include "fs_clear5.bin.h"
|
||||
#include "fs_clear6.bin.h"
|
||||
#include "fs_clear7.bin.h"
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace bgfx { namespace noop
|
||||
|
||||
RendererType::Enum getRendererType() const BX_OVERRIDE
|
||||
{
|
||||
return RendererType::Null;
|
||||
return RendererType::Noop;
|
||||
}
|
||||
|
||||
const char* getRendererName() const BX_OVERRIDE
|
||||
|
||||
@@ -49,11 +49,11 @@ namespace bgfx
|
||||
&s_attribTypeSizeDx9, // Direct3D9
|
||||
&s_attribTypeSizeDx1x, // Direct3D11
|
||||
&s_attribTypeSizeDx1x, // Direct3D12
|
||||
&s_attribTypeSizeGl, // Gnm
|
||||
&s_attribTypeSizeGl, // Metal
|
||||
&s_attribTypeSizeGl, // OpenGLES
|
||||
&s_attribTypeSizeGl, // OpenGL
|
||||
&s_attribTypeSizeGl, // Vulkan
|
||||
&s_attribTypeSizeGl, // GNM
|
||||
&s_attribTypeSizeDx9, // Count
|
||||
};
|
||||
BX_STATIC_ASSERT(BX_COUNTOF(s_attribTypeSize) == RendererType::Count+1);
|
||||
|
||||
Reference in New Issue
Block a user