Using renderFrame to setup thread creation behavior.

This commit is contained in:
bkaradzic 2014-01-19 14:58:05 -08:00
parent 9d1deb534a
commit e8075dc367
7 changed files with 26 additions and 15 deletions

View File

@ -36,6 +36,9 @@ namespace entry
m_eventQueue.postSizeEvent(768, 1024);
// Prevent render thread creation.
bgfx::renderFrame();
m_thread.init(MainThreadEntry::threadFunc, &m_mte);
}

View File

@ -93,7 +93,7 @@ namespace entry
m_mte.m_argc = 1;
m_mte.m_argv = const_cast<char**>(argv);
bgfx::naclSetIntefraces(g_instance, g_instInterface, g_graphicsInterface, NULL);
bgfx::naclSetInterfaces(g_instance, g_instInterface, g_graphicsInterface, NULL);
m_thread.init(MainThreadEntry::threadFunc, &m_mte);
}

View File

@ -27,8 +27,8 @@ namespace bgfx
};
/// WARNING: This call should be only used on platforms that don't
/// allow creating separate rendering thread. Proper use requires
/// changes inside lib.
/// allow creating separate rendering thread. If it is called before
/// to bgfx::init, render thread won't be created by bgfx::init call.
RenderFrame::Enum renderFrame();
}
@ -69,7 +69,7 @@ namespace bgfx
typedef void (*PostSwapBuffersFn)(uint32_t _width, uint32_t _height);
///
void naclSetIntefraces(::PP_Instance, const ::PPB_Instance*, const ::PPB_Graphics3D*, PostSwapBuffersFn);
void naclSetInterfaces(::PP_Instance, const ::PPB_Instance*, const ::PPB_Graphics3D*, PostSwapBuffersFn);
} // namespace bgfx

View File

@ -209,6 +209,7 @@ namespace bgfx
static BX_THREAD uint32_t s_threadIndex = 0;
static Context* s_ctx = NULL;
static bool s_renderFrame = false;
void setGraphicsDebuggerPresent(bool _present)
{
@ -733,8 +734,9 @@ namespace bgfx
s_ctx = BX_NEW(g_allocator, Context);
// On NaCl and iOS renderer is on the main thread.
s_ctx->init(!BX_PLATFORM_NACL && !BX_PLATFORM_IOS && !BX_PLATFORM_OSX);
// When bgfx::renderFrame is called before init render thread
// should not be created.
s_ctx->init(!s_renderFrame);
const uint64_t emulatedCaps = 0
| BGFX_CAPS_TEXTURE_FORMAT_BC1
@ -819,6 +821,7 @@ namespace bgfx
{
if (NULL == s_ctx)
{
s_renderFrame = true;
return RenderFrame::NoContext;
}

View File

@ -642,8 +642,8 @@ namespace bgfx
{
union
{
bx::float4x4_t f4x4;
float val[16];
bx::float4x4_t f4x4;
} un;
void setIdentity()

View File

@ -37,7 +37,7 @@ namespace bgfx
{
}
void setIntefraces(PP_Instance _instance, const PPB_Instance* _instInterface, const PPB_Graphics3D* _graphicsInterface, PostSwapBuffersFn _postSwapBuffers);
void setInterfaces(PP_Instance _instance, const PPB_Instance* _instInterface, const PPB_Graphics3D* _graphicsInterface, PostSwapBuffersFn _postSwapBuffers);
void resize(uint32_t _width, uint32_t _height, bool /*_vsync*/)
{
@ -96,14 +96,18 @@ namespace bgfx
s_ppapi.m_instancedArrays->DrawElementsInstancedANGLE(s_ppapi.m_context, _mode, _count, _type, _indices, _primcount);
}
void naclSetIntefraces(PP_Instance _instance, const PPB_Instance* _instInterface, const PPB_Graphics3D* _graphicsInterface, PostSwapBuffersFn _postSwapBuffers)
void naclSetInterfaces(PP_Instance _instance, const PPB_Instance* _instInterface, const PPB_Graphics3D* _graphicsInterface, PostSwapBuffersFn _postSwapBuffers)
{
s_ppapi.setIntefraces( _instance, _instInterface, _graphicsInterface, _postSwapBuffers);
s_ppapi.setInterfaces( _instance, _instInterface, _graphicsInterface, _postSwapBuffers);
}
void Ppapi::setIntefraces(PP_Instance _instance, const PPB_Instance* _instInterface, const PPB_Graphics3D* _graphicsInterface, PostSwapBuffersFn _postSwapBuffers)
void Ppapi::setInterfaces(PP_Instance _instance, const PPB_Instance* _instInterface, const PPB_Graphics3D* _graphicsInterface, PostSwapBuffersFn _postSwapBuffers)
{
BX_TRACE("PPAPI Interfaces");
// Prevent render thread creation.
renderFrame();
m_instance = _instance;
m_instInterface = _instInterface;
m_graphicsInterface = _graphicsInterface;

View File

@ -243,12 +243,12 @@ namespace bgfx
};
static const Matrix4 s_bias =
{
{{{
0.5f, 0.0f, 0.0f, 0.0f,
0.0f, 0.5f, 0.0f, 0.0f,
0.0f, 0.0f, 0.5f, 0.0f,
0.5f, 0.5f, 0.5f, 1.0f,
};
}}};
struct Extension
{
@ -2486,7 +2486,7 @@ namespace bgfx
GLint glGet(GLenum _pname)
{
GLint result;
GLint result = 0;
glGetIntegerv(_pname, &result);
GLenum err = glGetError();
BX_WARN(0 == err, "glGetIntegerv(0x%04x, ...) failed with GL error: 0x%04x.", _pname, err);
@ -2498,7 +2498,7 @@ namespace bgfx
s_renderCtx = BX_NEW(g_allocator, RendererContext);
s_renderCtx->init();
GLint numCmpFormats;
GLint numCmpFormats = 0;
GL_CHECK(glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numCmpFormats) );
BX_TRACE("GL_NUM_COMPRESSED_TEXTURE_FORMATS %d", numCmpFormats);
@ -2506,6 +2506,7 @@ namespace bgfx
if (0 < numCmpFormats)
{
numCmpFormats = numCmpFormats > 256 ? 256 : numCmpFormats;
cmpFormat = (GLint*)alloca(sizeof(GLint)*numCmpFormats);
GL_CHECK(glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, cmpFormat) );