mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 18:45:54 -05:00
Cleanup.
This commit is contained in:
parent
3bc15318fd
commit
ceffc24f17
3 changed files with 119 additions and 93 deletions
|
@ -26,7 +26,9 @@
|
|||
#define GL_IMPORT_ANGLE(_optional, _proto, _func) GL_EXTENSION(_optional, _proto, _func, _func ## ANGLE)
|
||||
#define GL_IMPORT_ARB__(_optional, _proto, _func) GL_EXTENSION(_optional, _proto, _func, _func ## ARB)
|
||||
#define GL_IMPORT_EXT__(_optional, _proto, _func) GL_EXTENSION(_optional, _proto, _func, _func ## EXT)
|
||||
#define GL_IMPORT_NV___(_optional, _proto, _func) GL_EXTENSION(_optional, _proto, _func, _func ## NV)
|
||||
#define GL_IMPORT_OES__(_optional, _proto, _func) GL_EXTENSION(_optional, _proto, _func, _func ## OES)
|
||||
#define GL_IMPORT_____x(_optional, _proto, _func) GL_EXTENSION(_optional, _proto, _func, _func ## XXXXX)
|
||||
|
||||
#if GL_IMPORT_TYPEDEFS
|
||||
typedef void (GL_APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture);
|
||||
|
@ -155,6 +157,8 @@ typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index
|
|||
typedef void (GL_APIENTRYP PFNGLVIEWPORTPROC) (GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
|
||||
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 PFNGLFRAMETERMINATORGREMEDYPROC) (void);
|
||||
#endif // GL_IMPORT_TYPEDEFS
|
||||
|
||||
#if BGFX_USE_GL_DYNAMIC_LIB
|
||||
|
@ -310,10 +314,8 @@ GL_IMPORT______(false, PFNGLCLEARDEPTHFPROC, glClearDepthf
|
|||
|
||||
#endif // BGFX_USE_GL_DYNAMIC_LIB
|
||||
|
||||
#if BGFX_CONFIG_DEBUG_GREMEDY
|
||||
GL_IMPORT______(true, PFNGLSTRINGMARKERGREMEDYPROC, glStringMarkerGREMEDY);
|
||||
GL_IMPORT______(true, PFNGLFRAMETERMINATORGREMEDYPROC, glFrameTerminatorGREMEDY);
|
||||
#endif // BGFX_CONFIG_DEBUG_GREMEDY
|
||||
|
||||
#if !BGFX_CONFIG_RENDERER_OPENGL
|
||||
GL_IMPORT______(true, PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC, glGetTranslatedShaderSourceANGLE);
|
||||
|
@ -336,6 +338,19 @@ GL_IMPORT_OES__(true, PFNGLDRAWELEMENTSINSTANCEDPROC, glDrawElement
|
|||
GL_IMPORT_OES__(true, PFNGLBINDVERTEXARRAYPROC, glBindVertexArray);
|
||||
GL_IMPORT_OES__(true, PFNGLDELETEVERTEXARRAYSPROC, glDeleteVertexArrays);
|
||||
GL_IMPORT_OES__(true, PFNGLGENVERTEXARRAYSPROC, glGenVertexArrays);
|
||||
|
||||
GL_IMPORT_____x(true, PFNGLGENSAMPLERSPROC, glGenSamplers);
|
||||
GL_IMPORT_____x(true, PFNGLDELETESAMPLERSPROC, glDeleteSamplers);
|
||||
GL_IMPORT_____x(true, PFNGLBINDSAMPLERPROC, glBindSampler);
|
||||
GL_IMPORT_____x(true, PFNGLSAMPLERPARAMETERFPROC, glSamplerParameterf);
|
||||
GL_IMPORT_____x(true, PFNGLSAMPLERPARAMETERIPROC, glSamplerParameteri);
|
||||
|
||||
GL_IMPORT_NV___(true, PFNGLGENQUERIESPROC, glGenQueries);
|
||||
GL_IMPORT_NV___(true, PFNGLDELETEQUERIESPROC, glDeleteQueries);
|
||||
GL_IMPORT_NV___(true, PFNGLBEGINQUERYPROC, glBeginQuery);
|
||||
GL_IMPORT_NV___(true, PFNGLENDQUERYPROC, glEndQuery);
|
||||
GL_IMPORT_NV___(true, PFNGLGETQUERYOBJECTUI64VPROC, glGetQueryObjectui64v);
|
||||
|
||||
# endif // BGFX_CONFIG_RENDERER_OPENGLES2
|
||||
#endif // !BGFX_CONFIG_RENDERER_OPENGL
|
||||
|
||||
|
@ -345,4 +360,6 @@ GL_IMPORT_OES__(true, PFNGLGENVERTEXARRAYSPROC, glGenVertexAr
|
|||
#undef GL_IMPORT______
|
||||
#undef GL_IMPORT_ARB__
|
||||
#undef GL_IMPORT_EXT__
|
||||
#undef GL_IMPORT_NV___
|
||||
#undef GL_IMPORT_OES__
|
||||
#undef GL_IMPORT_____x
|
||||
|
|
|
@ -492,7 +492,6 @@ namespace bgfx
|
|||
static PFNGLDRAWELEMENTSINSTANCEDPROC s_drawElementsInstanced = stubDrawElementsInstanced;
|
||||
#endif // BGFX_CONFIG_RENDERER_OPENGLES3
|
||||
|
||||
#if BGFX_CONFIG_DEBUG_GREMEDY
|
||||
static void GL_APIENTRY stubStringMarkerGREMEDY(GLsizei /*_len*/, const GLvoid* /*_string*/)
|
||||
{
|
||||
}
|
||||
|
@ -500,7 +499,6 @@ namespace bgfx
|
|||
static void GL_APIENTRY stubFrameTerminatorGREMEDY()
|
||||
{
|
||||
}
|
||||
#endif // BGFX_CONFIG_DEBUG_GREMEDY
|
||||
|
||||
typedef void (*PostSwapBuffersFn)(uint32_t _width, uint32_t _height);
|
||||
|
||||
|
@ -736,6 +734,7 @@ namespace bgfx
|
|||
if (!m_glctx.isValid() )
|
||||
{
|
||||
m_glctx.create(_width, _height);
|
||||
|
||||
#if BX_PLATFORM_IOS
|
||||
// BK - Temp, need to figure out how to deal with FBO created by context.
|
||||
m_backBufferFbo = m_glctx.m_fbo;
|
||||
|
@ -770,19 +769,17 @@ namespace bgfx
|
|||
m_vaoStateCache.invalidate();
|
||||
}
|
||||
|
||||
#if !BGFX_CONFIG_RENDERER_OPENGLES2
|
||||
if (m_samplerObjectSupport)
|
||||
if (BX_ENABLED(!BGFX_CONFIG_RENDERER_OPENGLES2)
|
||||
&& m_samplerObjectSupport)
|
||||
{
|
||||
m_samplerStateCache.invalidate();
|
||||
}
|
||||
#endif // !BGFX_CONFIG_RENDERER_OPENGLES2
|
||||
}
|
||||
|
||||
void setSamplerState(uint32_t _stage, uint32_t _numMips, uint32_t _flags)
|
||||
{
|
||||
#if BGFX_CONFIG_RENDERER_OPENGLES2
|
||||
BX_UNUSED(_stage, _numMips, _flags);
|
||||
#else
|
||||
if (BX_ENABLED(!BGFX_CONFIG_RENDERER_OPENGLES2) )
|
||||
{
|
||||
if (0 == (BGFX_SAMPLER_DEFAULT_FLAGS & _flags) )
|
||||
{
|
||||
_flags = (_flags&(~BGFX_TEXTURE_RESERVED_MASK) ) | (_numMips<<BGFX_TEXTURE_RESERVED_SHIFT);
|
||||
|
@ -815,7 +812,7 @@ namespace bgfx
|
|||
{
|
||||
GL_CHECK(glBindSampler(_stage, 0) );
|
||||
}
|
||||
#endif // BGFX_CONFIG_RENDERER_OPENGLES2
|
||||
}
|
||||
}
|
||||
|
||||
void updateCapture()
|
||||
|
@ -902,18 +899,20 @@ namespace bgfx
|
|||
m_version = getGLString(GL_VERSION);
|
||||
m_glslVersion = getGLString(GL_SHADING_LANGUAGE_VERSION);
|
||||
|
||||
#if BGFX_CONFIG_DEBUG_GREMEDY
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG_GREMEDY) )
|
||||
{
|
||||
if (NULL == glStringMarkerGREMEDY
|
||||
|| NULL == glFrameTerminatorGREMEDY)
|
||||
{
|
||||
glStringMarkerGREMEDY = stubStringMarkerGREMEDY;
|
||||
glFrameTerminatorGREMEDY = stubFrameTerminatorGREMEDY;
|
||||
}
|
||||
#endif // BGFX_CONFIG_DEBUG_GREMEDY
|
||||
}
|
||||
|
||||
#if BGFX_CONFIG_RENDERER_OPENGL
|
||||
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) )
|
||||
{
|
||||
m_queries.create();
|
||||
#endif // BGFX_CONFIG_RENDERER_OPENGL
|
||||
}
|
||||
}
|
||||
|
||||
void shutdown()
|
||||
|
@ -922,9 +921,10 @@ namespace bgfx
|
|||
|
||||
invalidateCache();
|
||||
|
||||
#if BGFX_CONFIG_RENDERER_OPENGL
|
||||
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) )
|
||||
{
|
||||
m_queries.destroy();
|
||||
#endif // BGFX_CONFIG_RENDERER_OPENGL
|
||||
}
|
||||
|
||||
destroyMsaaFbo();
|
||||
m_glctx.destroy();
|
||||
|
@ -942,14 +942,10 @@ namespace bgfx
|
|||
FrameBuffer m_frameBuffers[BGFX_CONFIG_MAX_FRAME_BUFFERS];
|
||||
UniformRegistry m_uniformReg;
|
||||
void* m_uniforms[BGFX_CONFIG_MAX_UNIFORMS];
|
||||
#if BGFX_CONFIG_RENDERER_OPENGL
|
||||
Queries m_queries;
|
||||
#endif // BGFX_CONFIG_RENDERER_OPENGL
|
||||
|
||||
VaoStateCache m_vaoStateCache;
|
||||
#if !BGFX_CONFIG_RENDERER_OPENGLES2
|
||||
SamplerStateCache m_samplerStateCache;
|
||||
#endif // !BGFX_CONFIG_RENDERER_OPENGLES2
|
||||
|
||||
TextVideoMem m_textVideoMem;
|
||||
bool m_rtMsaa;
|
||||
|
@ -1375,9 +1371,10 @@ namespace bgfx
|
|||
|
||||
static void texImage(GLenum _target, GLint _level, GLint _internalFormat, GLsizei _width, GLsizei _height, GLsizei _depth, GLint _border, GLenum _format, GLenum _type, const GLvoid* _data)
|
||||
{
|
||||
#if !BGFX_CONFIG_RENDERER_OPENGL
|
||||
if (BX_ENABLED(!BGFX_CONFIG_RENDERER_OPENGL) )
|
||||
{
|
||||
_internalFormat = _format; // GLES wants internal format to match format...
|
||||
#endif // !BGFX_CONFIG_RENDERER_OPENGL
|
||||
}
|
||||
|
||||
if (_target == GL_TEXTURE_3D)
|
||||
{
|
||||
|
@ -1498,8 +1495,7 @@ namespace bgfx
|
|||
, _height
|
||||
) );
|
||||
}
|
||||
#if BGFX_CONFIG_RENDERER_OPENGL|BGFX_CONFIG_RENDERER_OPENGLES3
|
||||
else
|
||||
else if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL|BGFX_CONFIG_RENDERER_OPENGLES3) )
|
||||
{
|
||||
GL_CHECK(glRenderbufferStorageMultisample(GL_RENDERBUFFER
|
||||
, msaaQuality
|
||||
|
@ -1508,7 +1504,6 @@ namespace bgfx
|
|||
, _height
|
||||
) );
|
||||
}
|
||||
#endif // BGFX_CONFIG_RENDERER_OPENGL|BGFX_CONFIG_RENDERER_OPENGLES3
|
||||
|
||||
GL_CHECK(glBindRenderbuffer(GL_RENDERBUFFER, 0) );
|
||||
|
||||
|
@ -1852,10 +1847,13 @@ namespace bgfx
|
|||
GL_CHECK(glActiveTexture(GL_TEXTURE0+_stage) );
|
||||
GL_CHECK(glBindTexture(m_target, m_id) );
|
||||
|
||||
#if BGFX_CONFIG_RENDERER_OPENGLES2
|
||||
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES2) )
|
||||
{
|
||||
// GLES2 doesn't have support for sampler object.
|
||||
setSamplerState(_flags);
|
||||
#elif BGFX_CONFIG_RENDERER_OPENGL < 31
|
||||
}
|
||||
else if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL < 31) )
|
||||
{
|
||||
// In case that GL 2.1 sampler object is supported via extension.
|
||||
if (s_renderCtx->m_samplerObjectSupport)
|
||||
{
|
||||
|
@ -1865,10 +1863,12 @@ namespace bgfx
|
|||
{
|
||||
setSamplerState(_flags);
|
||||
}
|
||||
#else
|
||||
}
|
||||
else
|
||||
{
|
||||
// Everything else has sampler object.
|
||||
s_renderCtx->setSamplerState(_stage, m_numMips, _flags);
|
||||
#endif // BGFX_CONFIG_RENDERER_*
|
||||
}
|
||||
}
|
||||
|
||||
void writeString(bx::WriterI* _writer, const char* _str)
|
||||
|
@ -2368,8 +2368,8 @@ namespace bgfx
|
|||
|
||||
void ClearQuad::clear(const Rect& _rect, const Clear& _clear, uint32_t _height)
|
||||
{
|
||||
#if BGFX_CONFIG_CLEAR_QUAD
|
||||
if (s_renderCtx->m_useClearQuad)
|
||||
if (BX_ENABLED(BGFX_CONFIG_CLEAR_QUAD)
|
||||
&& s_renderCtx->m_useClearQuad)
|
||||
{
|
||||
const GLuint defaultVao = s_renderCtx->m_vao;
|
||||
if (0 != defaultVao)
|
||||
|
@ -2461,7 +2461,6 @@ namespace bgfx
|
|||
) );
|
||||
}
|
||||
else
|
||||
#endif // BGFX_CONFIG_CLEAR_QUAD
|
||||
{
|
||||
GLuint flags = 0;
|
||||
if (BGFX_CLEAR_COLOR_BIT & _clear.m_flags)
|
||||
|
@ -2745,21 +2744,23 @@ namespace bgfx
|
|||
;
|
||||
g_caps.maxTextureSize = glGet(GL_MAX_TEXTURE_SIZE);
|
||||
|
||||
#if !BGFX_CONFIG_RENDERER_OPENGLES2
|
||||
if (BX_ENABLED(!BGFX_CONFIG_RENDERER_OPENGLES2) )
|
||||
{
|
||||
g_caps.maxFBAttachments = bx::uint32_min(glGet(GL_MAX_COLOR_ATTACHMENTS), BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS);
|
||||
#endif // !BGFX_CONFIG_RENDERER_OPENGLES2
|
||||
}
|
||||
|
||||
s_renderCtx->m_vaoSupport = !!BGFX_CONFIG_RENDERER_OPENGLES3
|
||||
|| s_extension[Extension::ARB_vertex_array_object].m_supported
|
||||
|| s_extension[Extension::OES_vertex_array_object].m_supported
|
||||
;
|
||||
|
||||
#if BX_PLATFORM_NACL
|
||||
if (BX_ENABLED(BX_PLATFORM_NACL) )
|
||||
{
|
||||
s_renderCtx->m_vaoSupport &= NULL != glGenVertexArrays
|
||||
&& NULL != glDeleteVertexArrays
|
||||
&& NULL != glBindVertexArray
|
||||
;
|
||||
#endif // BX_PLATFORM_NACL
|
||||
}
|
||||
|
||||
if (s_renderCtx->m_vaoSupport)
|
||||
{
|
||||
|
@ -2815,9 +2816,10 @@ namespace bgfx
|
|||
|| s_extension[Extension::IMG_texture_format_BGRA8888].m_supported
|
||||
|| s_extension[Extension::APPLE_texture_format_BGRA8888].m_supported)
|
||||
{
|
||||
#if BGFX_CONFIG_RENDERER_OPENGL
|
||||
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) )
|
||||
{
|
||||
s_renderCtx->m_readPixelsFmt = GL_BGRA_EXT;
|
||||
#endif // BGFX_CONFIG_RENDERER_OPENGL
|
||||
}
|
||||
|
||||
s_textureFormat[TextureFormat::BGRA8].m_fmt = GL_BGRA_EXT;
|
||||
|
||||
|
@ -3080,12 +3082,11 @@ namespace bgfx
|
|||
int64_t elapsed = -bx::getHPCounter();
|
||||
int64_t captureElapsed = 0;
|
||||
|
||||
#if BGFX_CONFIG_RENDERER_OPENGL
|
||||
if (m_render->m_debug & (BGFX_DEBUG_IFH|BGFX_DEBUG_STATS) )
|
||||
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL)
|
||||
&& (m_render->m_debug & (BGFX_DEBUG_IFH|BGFX_DEBUG_STATS) ) )
|
||||
{
|
||||
s_renderCtx->m_queries.begin(0, GL_TIME_ELAPSED);
|
||||
}
|
||||
#endif // BGFX_CONFIG_RENDERER_OPENGL
|
||||
|
||||
if (0 < m_render->m_iboffset)
|
||||
{
|
||||
|
|
|
@ -206,6 +206,14 @@ typedef uint64_t GLuint64;
|
|||
# define GL_MAX_SAMPLES 0x8D57
|
||||
#endif // GL_MAX_SAMPLES
|
||||
|
||||
#ifndef GL_MAX_COLOR_ATTACHMENTS
|
||||
# define GL_MAX_COLOR_ATTACHMENTS 0x8CDF
|
||||
#endif // GL_MAX_COLOR_ATTACHMENTS
|
||||
|
||||
#ifndef GL_QUERY_RESULT
|
||||
# define GL_QUERY_RESULT 0x8866
|
||||
#endif // GL_QUERY_RESULT
|
||||
|
||||
#ifndef GL_READ_FRAMEBUFFER
|
||||
# define GL_READ_FRAMEBUFFER 0x8CA8
|
||||
#endif /// GL_READ_FRAMEBUFFER
|
||||
|
@ -214,6 +222,10 @@ typedef uint64_t GLuint64;
|
|||
# define GL_DRAW_FRAMEBUFFER 0x8CA9
|
||||
#endif // GL_DRAW_FRAMEBUFFER
|
||||
|
||||
#ifndef GL_TIME_ELAPSED
|
||||
# define GL_TIME_ELAPSED 0x88BF
|
||||
#endif // GL_TIME_ELAPSED
|
||||
|
||||
#ifndef GL_VBO_FREE_MEMORY_ATI
|
||||
# define GL_VBO_FREE_MEMORY_ATI 0x87FB
|
||||
#endif // GL_VBO_FREE_MEMORY_ATI
|
||||
|
@ -410,7 +422,6 @@ namespace bgfx
|
|||
VaoSet m_vaoSet;
|
||||
};
|
||||
|
||||
#if !BGFX_CONFIG_RENDERER_OPENGLES2
|
||||
class SamplerStateCache
|
||||
{
|
||||
public:
|
||||
|
@ -460,7 +471,6 @@ namespace bgfx
|
|||
typedef stl::unordered_map<uint32_t, GLuint> HashMap;
|
||||
HashMap m_hashMap;
|
||||
};
|
||||
#endif // !BGFX_CONFIG_RENDERER_OPENGLES2
|
||||
|
||||
struct IndexBuffer
|
||||
{
|
||||
|
@ -654,7 +664,6 @@ namespace bgfx
|
|||
VaoCacheRef m_vcref;
|
||||
};
|
||||
|
||||
#if BGFX_CONFIG_RENDERER_OPENGL
|
||||
struct Queries
|
||||
{
|
||||
void create()
|
||||
|
@ -686,7 +695,6 @@ namespace bgfx
|
|||
|
||||
GLuint m_queries[64];
|
||||
};
|
||||
#endif // BGFX_CONFIG_RENDERER_OPENGL
|
||||
|
||||
} // namespace bgfx
|
||||
|
||||
|
|
Loading…
Reference in a new issue