Report HiDPI display support thru caps.

This commit is contained in:
Branimir Karadžić 2015-08-17 18:07:00 -07:00
parent 5f7b891b52
commit 05f94f44be
14 changed files with 52 additions and 44 deletions

View file

@ -181,12 +181,7 @@ namespace bgfx
return bx::alignedRealloc(this, _ptr, _size, _align, _file, _line);
}
void checkLeaks()
{
#if BGFX_CONFIG_MEMORY_TRACKING
BX_WARN(0 == m_numBlocks, "MEMORY LEAK: %d (max: %d)", m_numBlocks, m_maxBlocks);
#endif // BGFX_CONFIG_MEMORY_TRACKING
}
void checkLeaks();
protected:
#if BGFX_CONFIG_MEMORY_TRACKING
@ -196,7 +191,7 @@ namespace bgfx
#endif // BGFX_CONFIG_MEMORY_TRACKING
};
static CallbackStub* s_callbackStub = NULL;
static CallbackStub* s_callbackStub = NULL;
static AllocatorStub* s_allocatorStub = NULL;
static bool s_graphicsDebuggerPresent = false;
@ -210,6 +205,19 @@ namespace bgfx
static bool s_renderFrameCalled = false;
PlatformData g_platformData;
void AllocatorStub::checkLeaks()
{
#if BGFX_CONFIG_MEMORY_TRACKING
// BK - CallbackStub will be deleted after printing this info, so there is always one
// leak if CallbackStub is used.
BX_WARN( (NULL != s_callbackStub ? 1 : 0) == m_numBlocks
, "MEMORY LEAK: %d (max: %d)"
, m_numBlocks
, m_maxBlocks
);
#endif // BGFX_CONFIG_MEMORY_TRACKING
}
void setPlatformData(const PlatformData& _pd)
{
if (NULL != s_ctx)
@ -333,7 +341,7 @@ namespace bgfx
case RendererType::Metal:
mem = makeRef(vs_debugfont_mtl, sizeof(vs_debugfont_mtl) );
break;
default:
mem = makeRef(vs_debugfont_glsl, sizeof(vs_debugfont_glsl) );
break;
@ -355,7 +363,7 @@ namespace bgfx
case RendererType::Metal:
mem = makeRef(fs_debugfont_mtl, sizeof(fs_debugfont_mtl) );
break;
default:
mem = makeRef(fs_debugfont_glsl, sizeof(fs_debugfont_glsl) );
break;
@ -579,7 +587,7 @@ namespace bgfx
else if (RendererType::Metal == g_caps.rendererType)
{
vsh = createShader(makeRef(vs_clear_mtl, sizeof(vs_clear_mtl) ) );
const Mem mem[] =
{
Mem(fs_clear0_mtl, sizeof(fs_clear0_mtl) ),
@ -591,7 +599,7 @@ namespace bgfx
Mem(fs_clear6_mtl, sizeof(fs_clear6_mtl) ),
Mem(fs_clear7_mtl, sizeof(fs_clear7_mtl) ),
};
for (uint32_t ii = 0, num = g_caps.maxFBAttachments; ii < num; ++ii)
{
fragMem[ii] = makeRef(mem[ii].data, uint32_t(mem[ii].size) );
@ -882,6 +890,7 @@ namespace bgfx
CAPS_FLAGS(BGFX_CAPS_HMD),
CAPS_FLAGS(BGFX_CAPS_INDEX32),
CAPS_FLAGS(BGFX_CAPS_DRAW_INDIRECT),
CAPS_FLAGS(BGFX_CAPS_HIDPI),
#undef CAPS_FLAGS
};
@ -1525,8 +1534,7 @@ again:
_type = RendererType::Null;
}
}
else if (BX_ENABLED(0
|| BX_PLATFORM_IOS ) )
else if (BX_ENABLED(BX_PLATFORM_IOS) )
{
if (s_rendererCreator[RendererType::Metal].supported)
{
@ -1536,7 +1544,6 @@ again:
{
_type = RendererType::OpenGLES;
}
}
else if (BX_ENABLED(0
|| BX_PLATFORM_ANDROID
@ -2153,8 +2160,6 @@ again:
if (NULL != s_allocatorStub)
{
// s_allocatorStub->checkLeaks();
bx::CrtAllocator allocator;
BX_DELETE(&allocator, s_allocatorStub);
s_allocatorStub = NULL;

View file

@ -23,7 +23,7 @@ namespace bgfx { namespace gl
void destroy();
void resize(uint32_t _width, uint32_t _height, uint32_t _flags);
static bool isSwapChainSupported();
uint64_t getCaps() const;
SwapChainGL* createSwapChain(void* _nwh);
void destroySwapChain(SwapChainGL* _swapChain);
void swap(SwapChainGL* _swapChain = NULL);

View file

@ -16,12 +16,12 @@ namespace bgfx { namespace gl
# include "glimports.h"
static void* s_opengles = NULL;
void GlContext::create(uint32_t _width, uint32_t _height)
{
s_opengles = bx::dlopen("/System/Library/Frameworks/OpenGLES.framework/OpenGLES");
BX_CHECK(NULL != s_opengles, "OpenGLES dynamic library is not found!");
BX_UNUSED(_width, _height);
CAEAGLLayer* layer = (CAEAGLLayer*)g_platformData.nwh;
layer.opaque = true;
@ -64,7 +64,7 @@ namespace bgfx { namespace gl
, "glCheckFramebufferStatus failed 0x%08x"
, glCheckFramebufferStatus(GL_FRAMEBUFFER)
);
import();
}
@ -90,7 +90,7 @@ namespace bgfx { namespace gl
EAGLContext* context = (EAGLContext*)m_context;
[context release];
bx::dlclose(s_opengles);
}
@ -144,9 +144,9 @@ namespace bgfx { namespace gl
);
}
bool GlContext::isSwapChainSupported()
uint64_t GlContext::getCaps() const
{
return false;
return 0;
}
SwapChainGL* GlContext::createSwapChain(void* /*_nwh*/)

View file

@ -355,12 +355,15 @@ EGL_IMPORT
}
}
bool GlContext::isSwapChainSupported()
uint64_t GlContext::getCaps() const
{
return BX_ENABLED(0
| BX_PLATFORM_LINUX
| BX_PLATFORM_WINDOWS
);
)
? BGFX_CAPS_SWAP_CHAIN
: 0
;
}
SwapChainGL* GlContext::createSwapChain(void* _nwh)

View file

@ -29,7 +29,7 @@ namespace bgfx { namespace gl
void destroy();
void resize(uint32_t _width, uint32_t _height, uint32_t _flags);
static bool isSwapChainSupported();
uint64_t getCaps() const;
SwapChainGL* createSwapChain(void* _nwh);
void destroySwapChain(SwapChainGL* _swapChain);
void swap(SwapChainGL* _swapChain = NULL);

View file

@ -244,9 +244,9 @@ namespace bgfx { namespace gl
}
}
bool GlContext::isSwapChainSupported()
uint64_t GlContext::getCaps() const
{
return true;
return BGFX_CAPS_SWAP_CHAIN;
}
SwapChainGL* GlContext::createSwapChain(void* _nwh)

View file

@ -28,7 +28,7 @@ namespace bgfx { namespace gl
void destroy();
void resize(uint32_t _width, uint32_t _height, uint32_t _flags);
static bool isSwapChainSupported();
uint64_t getCaps() const;
SwapChainGL* createSwapChain(void* _nwh);
void destroySwapChain(SwapChainGL* _swapChain);
void swap(SwapChainGL* _swapChain = NULL);

View file

@ -23,7 +23,7 @@ namespace bgfx { namespace gl
void destroy();
void resize(uint32_t _width, uint32_t _height, uint32_t _flags);
static bool isSwapChainSupported();
uint64_t getCaps() const;
SwapChainGL* createSwapChain(void* _nwh);
void destroySwapChain(SwapChainGL* _swapChain);
void swap(SwapChainGL* _swapChain = NULL);

View file

@ -114,8 +114,6 @@ namespace bgfx { namespace gl
m_context = glContext;
}
// float x = [nsWindow backingScaleFactor];
import();
}
@ -147,9 +145,14 @@ namespace bgfx { namespace gl
[glContext update];
}
bool GlContext::isSwapChainSupported()
uint64_t GlContext::getCaps() const
{
return false;
NSWindow* nsWindow = (NSWindow*)g_platformData.nwh;
uint64_t caps = 1.0f < [nsWindow backingScaleFactor]
? BGFX_CAPS_HIDPI
: 0
;
return caps;
}
SwapChainGL* GlContext::createSwapChain(void* _nwh)

View file

@ -153,9 +153,9 @@ namespace bgfx { namespace gl
s_ppapi.resize(_width, _height, _flags);
}
bool GlContext::isSwapChainSupported()
uint64_t GlContext::getCaps() const
{
return false;
return 0;
}
SwapChainGL* GlContext::createSwapChain(void* /*_nwh*/)

View file

@ -27,7 +27,7 @@ namespace bgfx { namespace gl
void destroy();
void resize(uint32_t _width, uint32_t _height, uint32_t _flags);
static bool isSwapChainSupported();
uint64_t getCaps() const;
SwapChainGL* createSwapChain(void* _nwh);
void destroySwapChain(SwapChainGL* _swapChain);
void swap(SwapChainGL* _swapChain = NULL);

View file

@ -296,9 +296,9 @@ namespace bgfx { namespace gl
}
}
bool GlContext::isSwapChainSupported()
uint64_t GlContext::getCaps() const
{
return true;
return BGFX_CAPS_SWAP_CHAIN;
}
SwapChainGL* GlContext::createSwapChain(void* _nwh)

View file

@ -72,7 +72,7 @@ typedef void (APIENTRYP PFNGLSTENCILOPPROC) (GLenum fail, GLenum zfail, GLenum z
void destroy();
void resize(uint32_t _width, uint32_t _height, uint32_t _flags);
static bool isSwapChainSupported();
uint64_t getCaps() const;
SwapChainGL* createSwapChain(void* _nwh);
void destroySwapChain(SwapChainGL* _swapChain);
void swap(SwapChainGL* _swapChain = NULL);

View file

@ -1654,10 +1654,7 @@ namespace bgfx { namespace gl
: 0
;
g_caps.supported |= GlContext::isSwapChainSupported()
? BGFX_CAPS_SWAP_CHAIN
: 0
;
g_caps.supported |= m_glctx.getCaps();
if (s_extension[Extension::EXT_texture_filter_anisotropic].m_supported)
{