mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 18:45:54 -05:00
NaCl: Added occlusion query interface.
This commit is contained in:
parent
aaea5f93ec
commit
43f37a001d
4 changed files with 69 additions and 8 deletions
|
@ -36,6 +36,10 @@ void* load(bx::FileReaderI* _reader, bx::AllocatorI* _allocator, const char* _fi
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DBG("Failed to open: %s.", _filePath);
|
||||||
|
}
|
||||||
|
|
||||||
if (NULL != _size)
|
if (NULL != _size)
|
||||||
{
|
{
|
||||||
|
@ -66,6 +70,7 @@ static const bgfx::Memory* loadMem(bx::FileReaderI* _reader, const char* _filePa
|
||||||
return mem;
|
return mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DBG("Failed to load %s.", _filePath);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,6 +90,7 @@ static void* loadMem(bx::FileReaderI* _reader, bx::AllocatorI* _allocator, const
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DBG("Failed to load %s.", _filePath);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
14
src/bgfx.cpp
14
src/bgfx.cpp
|
@ -339,13 +339,17 @@ namespace bgfx
|
||||||
|
|
||||||
void trace(const char* _filePath, uint16_t _line, const char* _format, ...)
|
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;
|
dbgPrintfVargs(_format, argList);
|
||||||
va_start(argList, _format);
|
|
||||||
g_callback->traceVargs(_filePath, _line, _format, argList);
|
|
||||||
va_end(argList);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_callback->traceVargs(_filePath, _line, _format, argList);
|
||||||
|
}
|
||||||
|
va_end(argList);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "charset.h"
|
#include "charset.h"
|
||||||
|
|
|
@ -31,6 +31,7 @@ namespace bgfx { namespace gl
|
||||||
, m_instInterface(NULL)
|
, m_instInterface(NULL)
|
||||||
, m_graphicsInterface(NULL)
|
, m_graphicsInterface(NULL)
|
||||||
, m_instancedArrays(NULL)
|
, m_instancedArrays(NULL)
|
||||||
|
, m_query(NULL)
|
||||||
, m_postSwapBuffers(NULL)
|
, m_postSwapBuffers(NULL)
|
||||||
, m_forceSwap(true)
|
, m_forceSwap(true)
|
||||||
{
|
{
|
||||||
|
@ -59,6 +60,7 @@ namespace bgfx { namespace gl
|
||||||
const PPB_Instance* m_instInterface;
|
const PPB_Instance* m_instInterface;
|
||||||
const PPB_Graphics3D* m_graphicsInterface;
|
const PPB_Graphics3D* m_graphicsInterface;
|
||||||
const PPB_OpenGLES2InstancedArrays* m_instancedArrays;
|
const PPB_OpenGLES2InstancedArrays* m_instancedArrays;
|
||||||
|
const PPB_OpenGLES2Query* m_query;
|
||||||
PostSwapBuffersFn m_postSwapBuffers;
|
PostSwapBuffersFn m_postSwapBuffers;
|
||||||
bool m_forceSwap;
|
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);
|
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)
|
bool Ppapi::setInterfaces(PP_Instance _instance, const PPB_Instance* _instInterface, const PPB_Graphics3D* _graphicsInterface, PostSwapBuffersFn _postSwapBuffers)
|
||||||
{
|
{
|
||||||
BX_TRACE("PPAPI Interfaces");
|
BX_TRACE("PPAPI Interfaces");
|
||||||
|
@ -103,6 +139,7 @@ namespace bgfx { namespace gl
|
||||||
m_instInterface = _instInterface;
|
m_instInterface = _instInterface;
|
||||||
m_graphicsInterface = _graphicsInterface;
|
m_graphicsInterface = _graphicsInterface;
|
||||||
m_instancedArrays = glGetInstancedArraysInterfacePPAPI();
|
m_instancedArrays = glGetInstancedArraysInterfacePPAPI();
|
||||||
|
m_query = glGetQueryInterfacePPAPI();
|
||||||
m_postSwapBuffers = _postSwapBuffers;
|
m_postSwapBuffers = _postSwapBuffers;
|
||||||
|
|
||||||
int32_t attribs[] =
|
int32_t attribs[] =
|
||||||
|
@ -128,9 +165,22 @@ namespace bgfx { namespace gl
|
||||||
glSetCurrentContextPPAPI(m_context);
|
glSetCurrentContextPPAPI(m_context);
|
||||||
m_graphicsInterface->SwapBuffers(m_context, naclSwapComplete);
|
m_graphicsInterface->SwapBuffers(m_context, naclSwapComplete);
|
||||||
|
|
||||||
glVertexAttribDivisor = naclVertexAttribDivisor;
|
if (NULL != m_instancedArrays)
|
||||||
glDrawArraysInstanced = naclDrawArraysInstanced;
|
{
|
||||||
glDrawElementsInstanced = naclDrawElementsInstanced;
|
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.
|
// Prevent render thread creation.
|
||||||
RenderFrame::Enum result = renderFrame();
|
RenderFrame::Enum result = renderFrame();
|
||||||
|
|
|
@ -1816,6 +1816,7 @@ namespace bgfx { namespace gl
|
||||||
;
|
;
|
||||||
|
|
||||||
m_timerQuerySupport &= true
|
m_timerQuerySupport &= true
|
||||||
|
&& NULL != glQueryCounter
|
||||||
&& NULL != glGetQueryObjectiv
|
&& NULL != glGetQueryObjectiv
|
||||||
&& NULL != glGetQueryObjectui64v
|
&& NULL != glGetQueryObjectui64v
|
||||||
;
|
;
|
||||||
|
|
Loading…
Reference in a new issue