mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 18:45:54 -05:00
Cleanup.
This commit is contained in:
parent
fc3e657b40
commit
dea6567b5b
5 changed files with 500 additions and 475 deletions
|
@ -105,11 +105,6 @@
|
||||||
# define BGFX_CONFIG_DEBUG_PIX BGFX_CONFIG_DEBUG
|
# define BGFX_CONFIG_DEBUG_PIX BGFX_CONFIG_DEBUG
|
||||||
#endif // BGFX_CONFIG_DEBUG_PIX
|
#endif // BGFX_CONFIG_DEBUG_PIX
|
||||||
|
|
||||||
/// AMD gDEBugger markers
|
|
||||||
#ifndef BGFX_CONFIG_DEBUG_GREMEDY
|
|
||||||
# define BGFX_CONFIG_DEBUG_GREMEDY 0
|
|
||||||
#endif // BGFX_CONFIG_DEBUG_GREMEDY
|
|
||||||
|
|
||||||
/// DX11 object names
|
/// DX11 object names
|
||||||
#ifndef BGFX_CONFIG_DEBUG_OBJECT_NAME
|
#ifndef BGFX_CONFIG_DEBUG_OBJECT_NAME
|
||||||
# define BGFX_CONFIG_DEBUG_OBJECT_NAME BGFX_CONFIG_DEBUG
|
# define BGFX_CONFIG_DEBUG_OBJECT_NAME BGFX_CONFIG_DEBUG
|
||||||
|
|
|
@ -163,6 +163,10 @@ typedef void (GL_APIENTRYP PFNGLVIEWPORTPROC) (GLint x, GLint y, GLsiz
|
||||||
typedef void (GL_APIENTRYP PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC)(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source);
|
typedef void (GL_APIENTRYP PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC)(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source);
|
||||||
typedef void (GL_APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const void *string);
|
typedef void (GL_APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const void *string);
|
||||||
typedef void (GL_APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void);
|
typedef void (GL_APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void);
|
||||||
|
|
||||||
|
typedef void (GL_APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar *marker);
|
||||||
|
typedef void (GL_APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar *marker);
|
||||||
|
typedef void (GL_APIENTRYP PFNGLPOPGROUPMARKEREXTPROC) (void);
|
||||||
#endif // GL_IMPORT_TYPEDEFS
|
#endif // GL_IMPORT_TYPEDEFS
|
||||||
|
|
||||||
#if BGFX_USE_GL_DYNAMIC_LIB
|
#if BGFX_USE_GL_DYNAMIC_LIB
|
||||||
|
@ -316,10 +320,14 @@ GL_IMPORT_EXT__(true, PFNGLGENRENDERBUFFERSPROC, glGenRenderbu
|
||||||
GL_IMPORT_EXT__(true, PFNGLDELETERENDERBUFFERSPROC, glDeleteRenderbuffers);
|
GL_IMPORT_EXT__(true, PFNGLDELETERENDERBUFFERSPROC, glDeleteRenderbuffers);
|
||||||
GL_IMPORT_EXT__(true, PFNGLRENDERBUFFERSTORAGEPROC, glRenderbufferStorage);
|
GL_IMPORT_EXT__(true, PFNGLRENDERBUFFERSTORAGEPROC, glRenderbufferStorage);
|
||||||
GL_IMPORT_EXT__(true, PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC, glRenderbufferStorageMultisample);
|
GL_IMPORT_EXT__(true, PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC, glRenderbufferStorageMultisample);
|
||||||
|
|
||||||
# else // GLES
|
# else // GLES
|
||||||
GL_IMPORT______(false, PFNGLCLEARDEPTHFPROC, glClearDepthf);
|
GL_IMPORT______(false, PFNGLCLEARDEPTHFPROC, glClearDepthf);
|
||||||
# endif // BGFX_CONFIG_RENDERER_OPENGL
|
# endif // BGFX_CONFIG_RENDERER_OPENGL
|
||||||
|
|
||||||
|
GL_IMPORT______(true, PFNGLINSERTEVENTMARKEREXTPROC, glInsertEventMarker);
|
||||||
|
GL_IMPORT______(true, PFNGLPUSHGROUPMARKEREXTPROC, glPushGroupMarker);
|
||||||
|
GL_IMPORT______(true, PFNGLPOPGROUPMARKEREXTPROC, glPopGroupMarker);
|
||||||
#endif // BGFX_USE_GL_DYNAMIC_LIB
|
#endif // BGFX_USE_GL_DYNAMIC_LIB
|
||||||
|
|
||||||
GL_IMPORT______(true, PFNGLSTRINGMARKERGREMEDYPROC, glStringMarkerGREMEDY);
|
GL_IMPORT______(true, PFNGLSTRINGMARKERGREMEDYPROC, glStringMarkerGREMEDY);
|
||||||
|
@ -339,6 +347,10 @@ GL_IMPORT_OES__(true, PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC, glCompressedT
|
||||||
GL_IMPORT_EXT__(true, PFNGLTEXSTORAGE2DPROC, glTexStorage2D);
|
GL_IMPORT_EXT__(true, PFNGLTEXSTORAGE2DPROC, glTexStorage2D);
|
||||||
GL_IMPORT_EXT__(true, PFNGLTEXSTORAGE3DPROC, glTexStorage3D);
|
GL_IMPORT_EXT__(true, PFNGLTEXSTORAGE3DPROC, glTexStorage3D);
|
||||||
|
|
||||||
|
GL_IMPORT_EXT__(true, PFNGLINSERTEVENTMARKEREXTPROC, glInsertEventMarker);
|
||||||
|
GL_IMPORT_EXT__(true, PFNGLPUSHGROUPMARKEREXTPROC, glPushGroupMarker);
|
||||||
|
GL_IMPORT_EXT__(true, PFNGLPOPGROUPMARKEREXTPROC, glPopGroupMarker);
|
||||||
|
|
||||||
GL_IMPORT_OES__(true, PFNGLGETPROGRAMBINARYPROC, glGetProgramBinary);
|
GL_IMPORT_OES__(true, PFNGLGETPROGRAMBINARYPROC, glGetProgramBinary);
|
||||||
GL_IMPORT_OES__(true, PFNGLPROGRAMBINARYPROC, glProgramBinary);
|
GL_IMPORT_OES__(true, PFNGLPROGRAMBINARYPROC, glProgramBinary);
|
||||||
|
|
||||||
|
|
|
@ -326,16 +326,17 @@ namespace bgfx
|
||||||
template <typename Ty>
|
template <typename Ty>
|
||||||
static BX_NO_INLINE void setDebugObjectName(Ty* _interface, const char* _format, ...)
|
static BX_NO_INLINE void setDebugObjectName(Ty* _interface, const char* _format, ...)
|
||||||
{
|
{
|
||||||
#if BGFX_CONFIG_DEBUG_OBJECT_NAME
|
if (BX_ENABLED(BGFX_CONFIG_DEBUG_OBJECT_NAME) )
|
||||||
char temp[2048];
|
{
|
||||||
va_list argList;
|
char temp[2048];
|
||||||
va_start(argList, _format);
|
va_list argList;
|
||||||
int size = uint32_min(sizeof(temp)-1, vsnprintf(temp, sizeof(temp), _format, argList) );
|
va_start(argList, _format);
|
||||||
va_end(argList);
|
int size = bx::uint32_min(sizeof(temp)-1, vsnprintf(temp, sizeof(temp), _format, argList) );
|
||||||
temp[size] = '\0';
|
va_end(argList);
|
||||||
|
temp[size] = '\0';
|
||||||
|
|
||||||
_interface->SetPrivateData(WKPDID_D3DDebugObjectName, size, temp);
|
_interface->SetPrivateData(WKPDID_D3DDebugObjectName, size, temp);
|
||||||
#endif // BGFX_CONFIG_DEBUG_OBJECT_NAME
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct RendererContext
|
struct RendererContext
|
||||||
|
@ -357,21 +358,22 @@ namespace bgfx
|
||||||
m_d3d11dll = bx::dlopen("d3d11.dll");
|
m_d3d11dll = bx::dlopen("d3d11.dll");
|
||||||
BGFX_FATAL(NULL != m_d3d11dll, Fatal::UnableToInitialize, "Failed to load d3d11.dll.");
|
BGFX_FATAL(NULL != m_d3d11dll, Fatal::UnableToInitialize, "Failed to load d3d11.dll.");
|
||||||
|
|
||||||
#if BGFX_CONFIG_DEBUG_PIX
|
if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) )
|
||||||
// D3D11_1.h has ID3DUserDefinedAnnotation
|
{
|
||||||
// http://msdn.microsoft.com/en-us/library/windows/desktop/hh446881%28v=vs.85%29.aspx
|
// D3D11_1.h has ID3DUserDefinedAnnotation
|
||||||
m_d3d9dll = bx::dlopen("d3d9.dll");
|
// http://msdn.microsoft.com/en-us/library/windows/desktop/hh446881%28v=vs.85%29.aspx
|
||||||
BGFX_FATAL(NULL != m_d3d9dll, Fatal::UnableToInitialize, "Failed to load d3d9.dll.");
|
m_d3d9dll = bx::dlopen("d3d9.dll");
|
||||||
|
BGFX_FATAL(NULL != m_d3d9dll, Fatal::UnableToInitialize, "Failed to load d3d9.dll.");
|
||||||
|
|
||||||
m_D3DPERF_SetMarker = (D3DPERF_SetMarkerFunc)bx::dlsym(m_d3d9dll, "D3DPERF_SetMarker");
|
m_D3DPERF_SetMarker = (D3DPERF_SetMarkerFunc)bx::dlsym(m_d3d9dll, "D3DPERF_SetMarker");
|
||||||
m_D3DPERF_BeginEvent = (D3DPERF_BeginEventFunc)bx::dlsym(m_d3d9dll, "D3DPERF_BeginEvent");
|
m_D3DPERF_BeginEvent = (D3DPERF_BeginEventFunc)bx::dlsym(m_d3d9dll, "D3DPERF_BeginEvent");
|
||||||
m_D3DPERF_EndEvent = (D3DPERF_EndEventFunc)bx::dlsym(m_d3d9dll, "D3DPERF_EndEvent");
|
m_D3DPERF_EndEvent = (D3DPERF_EndEventFunc)bx::dlsym(m_d3d9dll, "D3DPERF_EndEvent");
|
||||||
BX_CHECK(NULL != m_D3DPERF_SetMarker
|
BX_CHECK(NULL != m_D3DPERF_SetMarker
|
||||||
&& NULL != m_D3DPERF_BeginEvent
|
&& NULL != m_D3DPERF_BeginEvent
|
||||||
&& NULL != m_D3DPERF_EndEvent
|
&& NULL != m_D3DPERF_EndEvent
|
||||||
, "Failed to initialize PIX events."
|
, "Failed to initialize PIX events."
|
||||||
);
|
);
|
||||||
#endif // BGFX_CONFIG_DEBUG_PIX
|
}
|
||||||
|
|
||||||
PFN_D3D11_CREATE_DEVICE d3D11CreateDevice = (PFN_D3D11_CREATE_DEVICE)bx::dlsym(m_d3d11dll, "D3D11CreateDevice");
|
PFN_D3D11_CREATE_DEVICE d3D11CreateDevice = (PFN_D3D11_CREATE_DEVICE)bx::dlsym(m_d3d11dll, "D3D11CreateDevice");
|
||||||
BGFX_FATAL(NULL != d3D11CreateDevice, Fatal::UnableToInitialize, "Function D3D11CreateDevice not found.");
|
BGFX_FATAL(NULL != d3D11CreateDevice, Fatal::UnableToInitialize, "Function D3D11CreateDevice not found.");
|
||||||
|
@ -415,13 +417,12 @@ namespace bgfx
|
||||||
, desc.SharedSystemMemory
|
, desc.SharedSystemMemory
|
||||||
);
|
);
|
||||||
|
|
||||||
#if BGFX_CONFIG_DEBUG_PERFHUD
|
if (BX_ENABLED(BGFX_CONFIG_DEBUG_PERFHUD)
|
||||||
if (0 != strstr(description, "PerfHUD") )
|
&& 0 != strstr(description, "PerfHUD") )
|
||||||
{
|
{
|
||||||
m_adapter = adapter;
|
m_adapter = adapter;
|
||||||
m_driverType = D3D_DRIVER_TYPE_REFERENCE;
|
m_driverType = D3D_DRIVER_TYPE_REFERENCE;
|
||||||
}
|
}
|
||||||
#endif // BGFX_CONFIG_DEBUG_PERFHUD
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DX_RELEASE(adapter, adapter == m_adapter ? 1 : 0);
|
DX_RELEASE(adapter, adapter == m_adapter ? 1 : 0);
|
||||||
|
@ -1271,6 +1272,8 @@ namespace bgfx
|
||||||
, &m_ptr
|
, &m_ptr
|
||||||
) );
|
) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setDebugObjectName(m_ptr, "IndexBuffer (dynamic %d)", m_dynamic);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IndexBuffer::update(uint32_t _offset, uint32_t _size, void* _data)
|
void IndexBuffer::update(uint32_t _offset, uint32_t _size, void* _data)
|
||||||
|
@ -2205,13 +2208,13 @@ namespace bgfx
|
||||||
|
|
||||||
void Context::rendererSetMarker(const char* _marker, uint32_t _size)
|
void Context::rendererSetMarker(const char* _marker, uint32_t _size)
|
||||||
{
|
{
|
||||||
#if BGFX_CONFIG_DEBUG_PIX
|
if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) )
|
||||||
uint32_t size = _size*sizeof(wchar_t);
|
{
|
||||||
wchar_t* name = (wchar_t*)alloca(size);
|
uint32_t size = _size*sizeof(wchar_t);
|
||||||
mbstowcs(name, _marker, size-2);
|
wchar_t* name = (wchar_t*)alloca(size);
|
||||||
PIX_SETMARKER(D3DCOLOR_RGBA(0xff, 0xff, 0xff, 0xff), name);
|
mbstowcs(name, _marker, size-2);
|
||||||
#endif // BGFX_CONFIG_DEBUG_PIX
|
PIX_SETMARKER(D3DCOLOR_RGBA(0xff, 0xff, 0xff, 0xff), name);
|
||||||
BX_UNUSED(_marker, _size);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Context::rendererSubmit()
|
void Context::rendererSubmit()
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -307,10 +307,6 @@ typedef uint64_t GLuint64;
|
||||||
# include "glcontext_eagl.h"
|
# include "glcontext_eagl.h"
|
||||||
#endif // BX_PLATFORM_
|
#endif // BX_PLATFORM_
|
||||||
|
|
||||||
#if BGFX_CONFIG_DEBUG_GREMEDY && (BX_PLATFORM_WINDOWS || BX_PLATFORM_LINUX)
|
|
||||||
# include <gl/GRemedyGLExtensions.h>
|
|
||||||
#endif // BGFX_CONFIG_DEBUG_GREMEDY && (BX_PLATFORM_WINDOWS || BX_PLATFORM_LINUX)
|
|
||||||
|
|
||||||
#if BGFX_USE_WGL
|
#if BGFX_USE_WGL
|
||||||
# include "glcontext_wgl.h"
|
# include "glcontext_wgl.h"
|
||||||
#endif // BGFX_USE_WGL
|
#endif // BGFX_USE_WGL
|
||||||
|
@ -343,17 +339,6 @@ namespace bgfx
|
||||||
# define GL_CHECK(_call) _call
|
# define GL_CHECK(_call) _call
|
||||||
#endif // BGFX_CONFIG_DEBUG
|
#endif // BGFX_CONFIG_DEBUG
|
||||||
|
|
||||||
#if BGFX_CONFIG_DEBUG_GREMEDY
|
|
||||||
# define _GREMEDY_SETMARKER(_string) glStringMarkerGREMEDY(0, _string)
|
|
||||||
# define _GREMEDY_FRAMETERMINATOR() glFrameTerminatorGREMEDY()
|
|
||||||
#else
|
|
||||||
# define _GREMEDY_SETMARKER(_string) do { BX_UNUSED(_string); } while(0)
|
|
||||||
# define _GREMEDY_FRAMETERMINATOR() do {} while(0)
|
|
||||||
#endif // BGFX_CONFIG_DEBUG_GREMEDY
|
|
||||||
|
|
||||||
#define GREMEDY_SETMARKER(_string) _GREMEDY_SETMARKER(_string)
|
|
||||||
#define GREMEDY_FRAMETERMINATOR() _GREMEDY_FRAMETERMINATOR()
|
|
||||||
|
|
||||||
#define GL_IMPORT_TYPEDEFS 1
|
#define GL_IMPORT_TYPEDEFS 1
|
||||||
#define GL_IMPORT(_optional, _proto, _func, _import) extern _proto _func
|
#define GL_IMPORT(_optional, _proto, _func, _import) extern _proto _func
|
||||||
#include "glimports.h"
|
#include "glimports.h"
|
||||||
|
|
Loading…
Reference in a new issue