diff --git a/examples/common/bgfx_utils.cpp b/examples/common/bgfx_utils.cpp index 78dd0bbd..0da00c34 100644 --- a/examples/common/bgfx_utils.cpp +++ b/examples/common/bgfx_utils.cpp @@ -36,6 +36,10 @@ void* load(bx::FileReaderI* _reader, bx::AllocatorI* _allocator, const char* _fi } return data; } + else + { + DBG("Failed to open: %s.", _filePath); + } if (NULL != _size) { @@ -66,6 +70,7 @@ static const bgfx::Memory* loadMem(bx::FileReaderI* _reader, const char* _filePa return mem; } + DBG("Failed to load %s.", _filePath); return NULL; } @@ -85,6 +90,7 @@ static void* loadMem(bx::FileReaderI* _reader, bx::AllocatorI* _allocator, const return data; } + DBG("Failed to load %s.", _filePath); return NULL; } diff --git a/src/bgfx.cpp b/src/bgfx.cpp index 590aa9bb..549dfcce 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -339,13 +339,17 @@ namespace bgfx void trace(const char* _filePath, uint16_t _line, const char* _format, ...) { - if (NULL != g_callback) + va_list argList; + va_start(argList, _format); + if (NULL == g_callback) { - va_list argList; - va_start(argList, _format); - g_callback->traceVargs(_filePath, _line, _format, argList); - va_end(argList); + dbgPrintfVargs(_format, argList); } + else + { + g_callback->traceVargs(_filePath, _line, _format, argList); + } + va_end(argList); } #include "charset.h" diff --git a/src/glcontext_ppapi.cpp b/src/glcontext_ppapi.cpp index fb17a11f..dac5c0d6 100644 --- a/src/glcontext_ppapi.cpp +++ b/src/glcontext_ppapi.cpp @@ -31,6 +31,7 @@ namespace bgfx { namespace gl , m_instInterface(NULL) , m_graphicsInterface(NULL) , m_instancedArrays(NULL) + , m_query(NULL) , m_postSwapBuffers(NULL) , m_forceSwap(true) { @@ -59,6 +60,7 @@ namespace bgfx { namespace gl const PPB_Instance* m_instInterface; const PPB_Graphics3D* m_graphicsInterface; const PPB_OpenGLES2InstancedArrays* m_instancedArrays; + const PPB_OpenGLES2Query* m_query; PostSwapBuffersFn m_postSwapBuffers; bool m_forceSwap; }; @@ -95,6 +97,40 @@ namespace bgfx { namespace gl s_ppapi.m_instancedArrays->DrawElementsInstancedANGLE(s_ppapi.m_context, _mode, _count, _type, _indices, _primcount); } + static void GL_APIENTRY naclGenQueries(GLsizei _n, GLuint* _queries) + { + s_ppapi.m_query->GenQueriesEXT(s_ppapi.m_context, _n, _queries); + } + + static void GL_APIENTRY naclDeleteQueries(GLsizei _n, const GLuint* _queries) + { + s_ppapi.m_query->DeleteQueriesEXT(s_ppapi.m_context, _n, _queries); + } + + static void GL_APIENTRY naclBeginQuery(GLenum _target, GLuint _id) + { + BX_UNUSED(_target); + s_ppapi.m_query->BeginQueryEXT(s_ppapi.m_context, GL_ANY_SAMPLES_PASSED_EXT, _id); + } + + static void GL_APIENTRY naclEndQuery(GLenum _target) + { + BX_UNUSED(_target); + s_ppapi.m_query->EndQueryEXT(s_ppapi.m_context, GL_ANY_SAMPLES_PASSED_EXT); + } + + static void GL_APIENTRY naclGetQueryObjectiv(GLuint _id, GLenum _pname, GLint* _params) + { + s_ppapi.m_query->GetQueryivEXT(s_ppapi.m_context, GL_ANY_SAMPLES_PASSED_EXT, GL_CURRENT_QUERY_EXT, _params); + } + + static void GL_APIENTRY naclGetQueryObjectui64v(GLuint _id, GLenum _pname, GLuint64* _params) + { + GLint params; + s_ppapi.m_query->GetQueryivEXT(s_ppapi.m_context, GL_ANY_SAMPLES_PASSED_EXT, GL_CURRENT_QUERY_EXT, ¶ms); + *_params = params; + } + bool Ppapi::setInterfaces(PP_Instance _instance, const PPB_Instance* _instInterface, const PPB_Graphics3D* _graphicsInterface, PostSwapBuffersFn _postSwapBuffers) { BX_TRACE("PPAPI Interfaces"); @@ -103,6 +139,7 @@ namespace bgfx { namespace gl m_instInterface = _instInterface; m_graphicsInterface = _graphicsInterface; m_instancedArrays = glGetInstancedArraysInterfacePPAPI(); + m_query = glGetQueryInterfacePPAPI(); m_postSwapBuffers = _postSwapBuffers; int32_t attribs[] = @@ -128,9 +165,22 @@ namespace bgfx { namespace gl glSetCurrentContextPPAPI(m_context); m_graphicsInterface->SwapBuffers(m_context, naclSwapComplete); - glVertexAttribDivisor = naclVertexAttribDivisor; - glDrawArraysInstanced = naclDrawArraysInstanced; - glDrawElementsInstanced = naclDrawElementsInstanced; + if (NULL != m_instancedArrays) + { + glVertexAttribDivisor = naclVertexAttribDivisor; + glDrawArraysInstanced = naclDrawArraysInstanced; + glDrawElementsInstanced = naclDrawElementsInstanced; + } + + if (NULL != m_query) + { + glGenQueries = naclGenQueries; + glDeleteQueries = naclDeleteQueries; + glBeginQuery = naclBeginQuery; + glEndQuery = naclEndQuery; + glGetQueryObjectiv = naclGetQueryObjectiv; + glGetQueryObjectui64v = naclGetQueryObjectui64v; + } // Prevent render thread creation. RenderFrame::Enum result = renderFrame(); diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index daf1aadf..5330657e 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -1816,6 +1816,7 @@ namespace bgfx { namespace gl ; m_timerQuerySupport &= true + && NULL != glQueryCounter && NULL != glGetQueryObjectiv && NULL != glGetQueryObjectui64v ;