mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 00:58:30 -05:00
Fixed detection of instanced_array extension.
This commit is contained in:
parent
ba55084ad8
commit
dae6768c43
5 changed files with 99 additions and 53 deletions
|
@ -17,6 +17,7 @@
|
||||||
#include <android/looper.h>
|
#include <android/looper.h>
|
||||||
#include <android/window.h>
|
#include <android/window.h>
|
||||||
#include <android_native_app_glue.h>
|
#include <android_native_app_glue.h>
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
#include <android_native_app_glue.c>
|
#include <android_native_app_glue.c>
|
||||||
|
@ -37,6 +38,7 @@ namespace entry
|
||||||
struct Context
|
struct Context
|
||||||
{
|
{
|
||||||
Context()
|
Context()
|
||||||
|
: m_window(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,15 +49,9 @@ namespace entry
|
||||||
m_app->onAppCmd = onAppCmdCB;
|
m_app->onAppCmd = onAppCmdCB;
|
||||||
m_app->onInputEvent = onInputEventCB;
|
m_app->onInputEvent = onInputEventCB;
|
||||||
|
|
||||||
bgfx::androidSetWindow(m_app->window);
|
|
||||||
|
|
||||||
const char* argv[1] = { "android.so" };
|
const char* argv[1] = { "android.so" };
|
||||||
MainThreadEntry mte;
|
m_mte.m_argc = 1;
|
||||||
mte.m_argc = 1;
|
m_mte.m_argv = const_cast<char**>(argv);
|
||||||
mte.m_argv = const_cast<char**>(argv);
|
|
||||||
|
|
||||||
bx::Thread thread;
|
|
||||||
thread.init(mte.threadFunc, &mte);
|
|
||||||
|
|
||||||
while (0 == m_app->destroyRequested)
|
while (0 == m_app->destroyRequested)
|
||||||
{
|
{
|
||||||
|
@ -69,7 +65,7 @@ namespace entry
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
thread.shutdown();
|
m_thread.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
void onAppCmd(int32_t _cmd)
|
void onAppCmd(int32_t _cmd)
|
||||||
|
@ -86,6 +82,12 @@ namespace entry
|
||||||
// Command from main thread: a new ANativeWindow is ready for use. Upon
|
// Command from main thread: a new ANativeWindow is ready for use. Upon
|
||||||
// receiving this command, android_app->window will contain the new window
|
// receiving this command, android_app->window will contain the new window
|
||||||
// surface.
|
// surface.
|
||||||
|
if (m_window == NULL)
|
||||||
|
{
|
||||||
|
m_window = m_app->window;
|
||||||
|
bgfx::androidSetWindow(m_app->window);
|
||||||
|
m_thread.init(MainThreadEntry::threadFunc, &m_mte);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case APP_CMD_TERM_WINDOW:
|
case APP_CMD_TERM_WINDOW:
|
||||||
|
@ -180,7 +182,12 @@ namespace entry
|
||||||
return self->onInputEvent(_event);
|
return self->onInputEvent(_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MainThreadEntry m_mte;
|
||||||
|
bx::Thread m_thread;
|
||||||
|
|
||||||
EventQueue m_eventQueue;
|
EventQueue m_eventQueue;
|
||||||
|
|
||||||
|
ANativeWindow* m_window;
|
||||||
android_app* m_app;
|
android_app* m_app;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -222,9 +229,7 @@ extern int _main_(int _argc, char** _argv);
|
||||||
|
|
||||||
extern "C" void android_main(android_app* _app)
|
extern "C" void android_main(android_app* _app)
|
||||||
{
|
{
|
||||||
DBG("entry_android");
|
|
||||||
using namespace entry;
|
using namespace entry;
|
||||||
app_dummy();
|
|
||||||
s_ctx.run(_app);
|
s_ctx.run(_app);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,12 +78,6 @@ function exampleProject(_name, _uuid)
|
||||||
"pthread",
|
"pthread",
|
||||||
}
|
}
|
||||||
|
|
||||||
configuration { "nacl", "Release" }
|
|
||||||
postbuildcommands {
|
|
||||||
"@echo Stripping symbols.",
|
|
||||||
"@$(NACL)/bin/x86_64-nacl-strip -s \"$(TARGET)\""
|
|
||||||
}
|
|
||||||
|
|
||||||
configuration { "linux" }
|
configuration { "linux" }
|
||||||
links {
|
links {
|
||||||
"GL",
|
"GL",
|
||||||
|
@ -105,6 +99,10 @@ function exampleProject(_name, _uuid)
|
||||||
"EGL",
|
"EGL",
|
||||||
"GLESv2",
|
"GLESv2",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
configuration {}
|
||||||
|
|
||||||
|
strip()
|
||||||
end
|
end
|
||||||
|
|
||||||
dofile "bgfx.lua"
|
dofile "bgfx.lua"
|
||||||
|
|
|
@ -1471,8 +1471,10 @@ namespace bgfx
|
||||||
|
|
||||||
static int32_t renderThread(void* _userData)
|
static int32_t renderThread(void* _userData)
|
||||||
{
|
{
|
||||||
|
BX_TRACE("render thread start");
|
||||||
Context* ctx = (Context*)_userData;
|
Context* ctx = (Context*)_userData;
|
||||||
while (!ctx->renderFrame() );
|
while (!ctx->renderFrame() );
|
||||||
|
BX_TRACE("render thread exit");
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
src/config.h
10
src/config.h
|
@ -103,7 +103,15 @@
|
||||||
#endif // BGFX_CONFIG_DEBUG_OBJECT_NAME
|
#endif // BGFX_CONFIG_DEBUG_OBJECT_NAME
|
||||||
|
|
||||||
#ifndef BGFX_CONFIG_MULTITHREADED
|
#ifndef BGFX_CONFIG_MULTITHREADED
|
||||||
# define BGFX_CONFIG_MULTITHREADED ( (BX_PLATFORM_WINDOWS|BX_PLATFORM_XBOX360|BX_PLATFORM_NACL)&(!BGFX_CONFIG_RENDERER_NULL) )
|
# define BGFX_CONFIG_MULTITHREADED ( (!BGFX_CONFIG_RENDERER_NULL)&(0 \
|
||||||
|
| BX_PLATFORM_ANDROID \
|
||||||
|
| BX_PLATFORM_IOS \
|
||||||
|
| BX_PLATFORM_NACL \
|
||||||
|
| BX_PLATFORM_OSX \
|
||||||
|
| BX_PLATFORM_QNX \
|
||||||
|
| BX_PLATFORM_WINDOWS \
|
||||||
|
| BX_PLATFORM_XBOX360 \
|
||||||
|
) )
|
||||||
#endif // BGFX_CONFIG_MULTITHREADED
|
#endif // BGFX_CONFIG_MULTITHREADED
|
||||||
|
|
||||||
#ifndef BGFX_CONFIG_MAX_DRAW_CALLS
|
#ifndef BGFX_CONFIG_MAX_DRAW_CALLS
|
||||||
|
|
|
@ -162,8 +162,32 @@ namespace bgfx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char* getGLString(GLenum _name)
|
||||||
|
{
|
||||||
|
const char* str = (const char*)glGetString(_name);
|
||||||
|
glGetError(); // ignore error if glGetString returns NULL.
|
||||||
|
if (NULL != str)
|
||||||
|
{
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "<unknown>";
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint32_t getGLStringHash(GLenum _name)
|
||||||
|
{
|
||||||
|
const char* str = (const char*)glGetString(_name);
|
||||||
|
glGetError(); // ignore error if glGetString returns NULL.
|
||||||
|
if (NULL != str)
|
||||||
|
{
|
||||||
|
return bx::hashMurmur2A(str, strlen(str) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#if BGFX_CONFIG_RENDERER_OPENGL
|
#if BGFX_CONFIG_RENDERER_OPENGL
|
||||||
static const char* toString(GLenum _enum)
|
const char* toString(GLenum _enum)
|
||||||
{
|
{
|
||||||
switch (_enum)
|
switch (_enum)
|
||||||
{
|
{
|
||||||
|
@ -454,6 +478,11 @@ namespace bgfx
|
||||||
{
|
{
|
||||||
m_glctx.create(BGFX_DEFAULT_WIDTH, BGFX_DEFAULT_HEIGHT);
|
m_glctx.create(BGFX_DEFAULT_WIDTH, BGFX_DEFAULT_HEIGHT);
|
||||||
|
|
||||||
|
m_vendor = getGLString(GL_VENDOR);
|
||||||
|
m_renderer = getGLString(GL_RENDERER);
|
||||||
|
m_version = getGLString(GL_VERSION);
|
||||||
|
m_glslVersion = getGLString(GL_SHADING_LANGUAGE_VERSION);
|
||||||
|
|
||||||
#if BGFX_CONFIG_RENDERER_OPENGL
|
#if BGFX_CONFIG_RENDERER_OPENGL
|
||||||
m_queries.create();
|
m_queries.create();
|
||||||
#endif // BGFX_CONFIG_RENDERER_OPENGL
|
#endif // BGFX_CONFIG_RENDERER_OPENGL
|
||||||
|
@ -511,6 +540,11 @@ namespace bgfx
|
||||||
GLuint m_backBufferFbo;
|
GLuint m_backBufferFbo;
|
||||||
GLuint m_backBufferRbos[2];
|
GLuint m_backBufferRbos[2];
|
||||||
GlContext m_glctx;
|
GlContext m_glctx;
|
||||||
|
|
||||||
|
const char* m_vendor;
|
||||||
|
const char* m_renderer;
|
||||||
|
const char* m_version;
|
||||||
|
const char* m_glslVersion;
|
||||||
};
|
};
|
||||||
|
|
||||||
RendererContext s_renderCtx;
|
RendererContext s_renderCtx;
|
||||||
|
@ -2128,18 +2162,6 @@ namespace bgfx
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t glGetStringHash(GLenum _name)
|
|
||||||
{
|
|
||||||
const char* str = (const char*)glGetString(_name);
|
|
||||||
glGetError(); // ignore error if glGetString returns NULL.
|
|
||||||
if (NULL != str)
|
|
||||||
{
|
|
||||||
return bx::hashMurmur2A(str, strlen(str) );
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Context::rendererInit()
|
void Context::rendererInit()
|
||||||
{
|
{
|
||||||
s_renderCtx.init();
|
s_renderCtx.init();
|
||||||
|
@ -2180,16 +2202,17 @@ namespace bgfx
|
||||||
GL_GET(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, 0);
|
GL_GET(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, 0);
|
||||||
GL_GET(GL_MAX_RENDERBUFFER_SIZE, 1);
|
GL_GET(GL_MAX_RENDERBUFFER_SIZE, 1);
|
||||||
|
|
||||||
const char* version = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION);
|
BX_TRACE(" Vendor: %s", s_renderCtx.m_vendor);
|
||||||
GL_CHECK(;); // check if error is generated by glGetString.
|
BX_TRACE(" Renderer: %s", s_renderCtx.m_renderer);
|
||||||
BX_TRACE("GLSL version: %s", version);
|
BX_TRACE(" Version: %s", s_renderCtx.m_version);
|
||||||
|
BX_TRACE("GLSL version: %s", s_renderCtx.m_glslVersion);
|
||||||
#endif // BGFX_CONFIG_DEBUG
|
#endif // BGFX_CONFIG_DEBUG
|
||||||
|
|
||||||
// Initial binary shader hash depends on driver version.
|
// Initial binary shader hash depends on driver version.
|
||||||
s_renderCtx.m_hash = ( (BX_PLATFORM_WINDOWS<<1) | BX_ARCH_64BIT)
|
s_renderCtx.m_hash = ( (BX_PLATFORM_WINDOWS<<1) | BX_ARCH_64BIT)
|
||||||
^ (uint64_t(glGetStringHash(GL_VENDOR ) )<<32)
|
^ (uint64_t(getGLStringHash(GL_VENDOR ) )<<32)
|
||||||
^ (uint64_t(glGetStringHash(GL_RENDERER) )<<0 )
|
^ (uint64_t(getGLStringHash(GL_RENDERER) )<<0 )
|
||||||
^ (uint64_t(glGetStringHash(GL_VERSION ) )<<16)
|
^ (uint64_t(getGLStringHash(GL_VERSION ) )<<16)
|
||||||
;
|
;
|
||||||
|
|
||||||
const char* extensions = (const char*)glGetString(GL_EXTENSIONS);
|
const char* extensions = (const char*)glGetString(GL_EXTENSIONS);
|
||||||
|
@ -2314,19 +2337,23 @@ namespace bgfx
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !BGFX_CONFIG_RENDERER_OPENGLES3
|
#if !BGFX_CONFIG_RENDERER_OPENGLES3
|
||||||
if (NULL != glVertexAttribDivisor
|
if (s_extension[Extension::ARB_instanced_arrays].m_supported
|
||||||
&& NULL != glDrawArraysInstanced
|
&& s_extension[Extension::ANGLE_instanced_arrays].m_supported)
|
||||||
&& NULL != glDrawElementsInstanced)
|
|
||||||
{
|
{
|
||||||
s_vertexAttribDivisor = glVertexAttribDivisor;
|
if (NULL != glVertexAttribDivisor
|
||||||
s_drawArraysInstanced = glDrawArraysInstanced;
|
&& NULL != glDrawArraysInstanced
|
||||||
s_drawElementsInstanced = glDrawElementsInstanced;
|
&& NULL != glDrawElementsInstanced)
|
||||||
}
|
{
|
||||||
else
|
s_vertexAttribDivisor = glVertexAttribDivisor;
|
||||||
{
|
s_drawArraysInstanced = glDrawArraysInstanced;
|
||||||
s_vertexAttribDivisor = stubVertexAttribDivisor;
|
s_drawElementsInstanced = glDrawElementsInstanced;
|
||||||
s_drawArraysInstanced = stubDrawArraysInstanced;
|
}
|
||||||
s_drawElementsInstanced = stubDrawElementsInstanced;
|
else
|
||||||
|
{
|
||||||
|
s_vertexAttribDivisor = stubVertexAttribDivisor;
|
||||||
|
s_drawArraysInstanced = stubDrawArraysInstanced;
|
||||||
|
s_drawElementsInstanced = stubDrawElementsInstanced;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif // !BGFX_CONFIG_RENDERER_OPENGLES3
|
#endif // !BGFX_CONFIG_RENDERER_OPENGLES3
|
||||||
|
|
||||||
|
@ -3250,8 +3277,14 @@ namespace bgfx
|
||||||
double toMs = 1000.0/freq;
|
double toMs = 1000.0/freq;
|
||||||
|
|
||||||
tvm.clear();
|
tvm.clear();
|
||||||
uint16_t pos = 10;
|
uint16_t pos = 0;
|
||||||
tvm.printf(0, 0, BGFX_CONFIG_DEBUG ? 0x89 : 0x8f, " " BGFX_RENDERER_NAME " ");
|
tvm.printf(0, pos++, BGFX_CONFIG_DEBUG ? 0x89 : 0x8f, " " BGFX_RENDERER_NAME " ");
|
||||||
|
tvm.printf(0, pos++, 0x0f, " Vendor: %s", s_renderCtx.m_vendor);
|
||||||
|
tvm.printf(0, pos++, 0x0f, " Renderer: %s", s_renderCtx.m_renderer);
|
||||||
|
tvm.printf(0, pos++, 0x0f, " Version: %s", s_renderCtx.m_version);
|
||||||
|
tvm.printf(0, pos++, 0x0f, "GLSL version: %s", s_renderCtx.m_glslVersion);
|
||||||
|
|
||||||
|
pos = 10;
|
||||||
tvm.printf(10, pos++, 0x8e, " Frame CPU: %7.3f, % 7.3f \x1f, % 7.3f \x1e [ms] / % 6.2f FPS"
|
tvm.printf(10, pos++, 0x8e, " Frame CPU: %7.3f, % 7.3f \x1f, % 7.3f \x1e [ms] / % 6.2f FPS"
|
||||||
, double(frameTime)*toMs
|
, double(frameTime)*toMs
|
||||||
, double(min)*toMs
|
, double(min)*toMs
|
||||||
|
|
Loading…
Reference in a new issue