Added swap chain caps.

This commit is contained in:
Branimir Karadžić 2014-09-23 20:35:39 -07:00
parent dd5492c29a
commit f4c7f69ed7
19 changed files with 117 additions and 52 deletions

View file

@ -94,8 +94,6 @@ static const InputBinding s_bindings[] =
int _main_(int /*_argc*/, char** /*_argv*/) int _main_(int /*_argc*/, char** /*_argv*/)
{ {
inputAddBindings("22-windows", s_bindings);
uint32_t width = 1280; uint32_t width = 1280;
uint32_t height = 720; uint32_t height = 720;
uint32_t debug = BGFX_DEBUG_TEXT; uint32_t debug = BGFX_DEBUG_TEXT;
@ -104,6 +102,14 @@ int _main_(int /*_argc*/, char** /*_argv*/)
bgfx::init(); bgfx::init();
bgfx::reset(width, height, reset); bgfx::reset(width, height, reset);
const bgfx::Caps* caps = bgfx::getCaps();
bool swapChainSupported = 0 != (caps->supported & BGFX_CAPS_SWAP_CHAIN);
if (swapChainSupported)
{
inputAddBindings("22-windows", s_bindings);
}
// Enable debug text. // Enable debug text.
bgfx::setDebug(debug); bgfx::setDebug(debug);
@ -234,7 +240,16 @@ int _main_(int /*_argc*/, char** /*_argv*/)
bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/22-windows"); bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/22-windows");
bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Rendering into multiple windows."); bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Rendering into multiple windows.");
bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs); bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs);
if (swapChainSupported)
{
bgfx::dbgTextPrintf(0, 5, 0x2f, "Press 'c' to create or 'd' to destroy window."); bgfx::dbgTextPrintf(0, 5, 0x2f, "Press 'c' to create or 'd' to destroy window.");
}
else
{
bool blink = uint32_t(time*3.0f)&1;
bgfx::dbgTextPrintf(0, 5, blink ? 0x1f : 0x01, " Multiple windows is not supported by `%s` renderer. ", bgfx::getRendererName(caps->rendererType) );
}
uint32_t count = 0; uint32_t count = 0;

View file

@ -277,6 +277,7 @@ namespace entry
clear(hwnd); clear(hwnd);
m_hwnd[_wparam] = hwnd; m_hwnd[_wparam] = hwnd;
m_flags[_wparam] = msg->m_flags;
WindowHandle handle = { (uint16_t)_wparam }; WindowHandle handle = { (uint16_t)_wparam };
m_eventQueue.postSizeEvent(handle, msg->m_width, msg->m_height); m_eventQueue.postSizeEvent(handle, msg->m_width, msg->m_height);
m_eventQueue.postWindowEvent(handle, hwnd); m_eventQueue.postWindowEvent(handle, hwnd);

View file

@ -275,5 +275,6 @@
#define BGFX_CAPS_BLEND_INDEPENDENT UINT64_C(0x0000000000000080) #define BGFX_CAPS_BLEND_INDEPENDENT UINT64_C(0x0000000000000080)
#define BGFX_CAPS_COMPUTE UINT64_C(0x0000000000000100) #define BGFX_CAPS_COMPUTE UINT64_C(0x0000000000000100)
#define BGFX_CAPS_FRAGMENT_ORDERING UINT64_C(0x0000000000000200) #define BGFX_CAPS_FRAGMENT_ORDERING UINT64_C(0x0000000000000200)
#define BGFX_CAPS_SWAP_CHAIN UINT64_C(0x0000000000000400)
#endif // BGFX_DEFINES_H_HEADER_GUARD #endif // BGFX_DEFINES_H_HEADER_GUARD

View file

@ -23,6 +23,7 @@ namespace bgfx
void destroy(); void destroy();
void resize(uint32_t _width, uint32_t _height, bool _vsync); void resize(uint32_t _width, uint32_t _height, bool _vsync);
static bool isSwapChainSupported();
SwapChainGL* createSwapChain(void* _nwh); SwapChainGL* createSwapChain(void* _nwh);
void destorySwapChain(SwapChainGL* _swapChain); void destorySwapChain(SwapChainGL* _swapChain);
void swap(SwapChainGL* _swapChain = NULL); void swap(SwapChainGL* _swapChain = NULL);

View file

@ -91,6 +91,11 @@ namespace bgfx
BX_TRACE("resize context"); BX_TRACE("resize context");
} }
bool GlContext::isSwapChainSupported()
{
return false;
}
SwapChainGL* GlContext::createSwapChain(void* /*_nwh*/) SwapChainGL* GlContext::createSwapChain(void* /*_nwh*/)
{ {
BX_CHECK(false, "Shouldn't be called!"); BX_CHECK(false, "Shouldn't be called!");

View file

@ -237,6 +237,11 @@ EGL_IMPORT
eglSwapInterval(m_display, _vsync ? 1 : 0); eglSwapInterval(m_display, _vsync ? 1 : 0);
} }
bool GlContext::isSwapChainSupported()
{
return false;
}
SwapChainGL* GlContext::createSwapChain(void* /*_nwh*/) SwapChainGL* GlContext::createSwapChain(void* /*_nwh*/)
{ {
BX_CHECK(false, "Shouldn't be called!"); BX_CHECK(false, "Shouldn't be called!");

View file

@ -27,6 +27,7 @@ namespace bgfx
void destroy(); void destroy();
void resize(uint32_t _width, uint32_t _height, bool _vsync); void resize(uint32_t _width, uint32_t _height, bool _vsync);
static bool isSwapChainSupported();
SwapChainGL* createSwapChain(void* _nwh); SwapChainGL* createSwapChain(void* _nwh);
void destorySwapChain(SwapChainGL* _swapChain); void destorySwapChain(SwapChainGL* _swapChain);
void swap(SwapChainGL* _swapChain = NULL); void swap(SwapChainGL* _swapChain = NULL);

View file

@ -212,6 +212,11 @@ namespace bgfx
} }
} }
bool GlContext::isSwapChainSupported()
{
return false;
}
SwapChainGL* GlContext::createSwapChain(void* /*_nwh*/) SwapChainGL* GlContext::createSwapChain(void* /*_nwh*/)
{ {
BX_CHECK(false, "Shouldn't be called!"); BX_CHECK(false, "Shouldn't be called!");

View file

@ -26,6 +26,7 @@ namespace bgfx
void destroy(); void destroy();
void resize(uint32_t _width, uint32_t _height, bool _vsync); void resize(uint32_t _width, uint32_t _height, bool _vsync);
static bool isSwapChainSupported();
SwapChainGL* createSwapChain(void* _nwh); SwapChainGL* createSwapChain(void* _nwh);
void destorySwapChain(SwapChainGL* _swapChain); void destorySwapChain(SwapChainGL* _swapChain);
void swap(SwapChainGL* _swapChain = NULL); void swap(SwapChainGL* _swapChain = NULL);

View file

@ -23,6 +23,7 @@ namespace bgfx
void destroy(); void destroy();
void resize(uint32_t _width, uint32_t _height, bool _vsync); void resize(uint32_t _width, uint32_t _height, bool _vsync);
static bool isSwapChainSupported();
SwapChainGL* createSwapChain(void* _nwh); SwapChainGL* createSwapChain(void* _nwh);
void destorySwapChain(SwapChainGL* _swapChain); void destorySwapChain(SwapChainGL* _swapChain);
void swap(SwapChainGL* _swapChain = NULL); void swap(SwapChainGL* _swapChain = NULL);

View file

@ -88,6 +88,11 @@ namespace bgfx
[glContext setValues:&interval forParameter:NSOpenGLCPSwapInterval]; [glContext setValues:&interval forParameter:NSOpenGLCPSwapInterval];
} }
bool GlContext::isSwapChainSupported()
{
return false;
}
SwapChainGL* GlContext::createSwapChain(void* /*_nwh*/) SwapChainGL* GlContext::createSwapChain(void* /*_nwh*/)
{ {
BX_CHECK(false, "Shouldn't be called!"); BX_CHECK(false, "Shouldn't be called!");

View file

@ -158,6 +158,11 @@ namespace bgfx
s_ppapi.resize(_width, _height, _vsync); s_ppapi.resize(_width, _height, _vsync);
} }
bool GlContext::isSwapChainSupported()
{
return false;
}
SwapChainGL* GlContext::createSwapChain(void* /*_nwh*/) SwapChainGL* GlContext::createSwapChain(void* /*_nwh*/)
{ {
BX_CHECK(false, "Shouldn't be called!"); BX_CHECK(false, "Shouldn't be called!");

View file

@ -27,6 +27,7 @@ namespace bgfx
void destroy(); void destroy();
void resize(uint32_t _width, uint32_t _height, bool _vsync); void resize(uint32_t _width, uint32_t _height, bool _vsync);
static bool isSwapChainSupported();
SwapChainGL* createSwapChain(void* _nwh); SwapChainGL* createSwapChain(void* _nwh);
void destorySwapChain(SwapChainGL* _swapChain); void destorySwapChain(SwapChainGL* _swapChain);
void swap(SwapChainGL* _swapChain = NULL); void swap(SwapChainGL* _swapChain = NULL);

View file

@ -292,6 +292,11 @@ namespace bgfx
} }
} }
bool GlContext::isSwapChainSupported()
{
return true;
}
SwapChainGL* GlContext::createSwapChain(void* _nwh) SwapChainGL* GlContext::createSwapChain(void* _nwh)
{ {
SwapChainGL* swapChain = BX_NEW(g_allocator, SwapChainGL)(_nwh); SwapChainGL* swapChain = BX_NEW(g_allocator, SwapChainGL)(_nwh);

View file

@ -71,6 +71,7 @@ typedef void (APIENTRYP PFNGLSTENCILOPPROC) (GLenum fail, GLenum zfail, GLenum z
void destroy(); void destroy();
void resize(uint32_t _width, uint32_t _height, bool _vsync); void resize(uint32_t _width, uint32_t _height, bool _vsync);
static bool isSwapChainSupported();
SwapChainGL* createSwapChain(void* _nwh); SwapChainGL* createSwapChain(void* _nwh);
void destorySwapChain(SwapChainGL* _swapChain); void destorySwapChain(SwapChainGL* _swapChain);
void swap(SwapChainGL* _swapChain = NULL); void swap(SwapChainGL* _swapChain = NULL);

View file

@ -611,6 +611,7 @@ namespace bgfx
| BGFX_CAPS_BLEND_INDEPENDENT | BGFX_CAPS_BLEND_INDEPENDENT
| BGFX_CAPS_COMPUTE | BGFX_CAPS_COMPUTE
| (getIntelExtensions(m_device) ? BGFX_CAPS_FRAGMENT_ORDERING : 0) | (getIntelExtensions(m_device) ? BGFX_CAPS_FRAGMENT_ORDERING : 0)
| BGFX_CAPS_SWAP_CHAIN
); );
g_caps.maxTextureSize = D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION; g_caps.maxTextureSize = D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION;
g_caps.maxFBAttachments = bx::uint32_min(D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT, BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS); g_caps.maxFBAttachments = bx::uint32_min(D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT, BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS);

View file

@ -432,13 +432,15 @@ namespace bgfx
| BGFX_CAPS_TEXTURE_COMPARE_LEQUAL | BGFX_CAPS_TEXTURE_COMPARE_LEQUAL
| BGFX_CAPS_VERTEX_ATTRIB_HALF | BGFX_CAPS_VERTEX_ATTRIB_HALF
| BGFX_CAPS_FRAGMENT_DEPTH | BGFX_CAPS_FRAGMENT_DEPTH
| BGFX_CAPS_SWAP_CHAIN
); );
g_caps.maxTextureSize = bx::uint32_min(m_caps.MaxTextureWidth, m_caps.MaxTextureHeight); g_caps.maxTextureSize = bx::uint32_min(m_caps.MaxTextureWidth, m_caps.MaxTextureHeight);
m_caps.NumSimultaneousRTs = bx::uint32_min(m_caps.NumSimultaneousRTs, BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS); m_caps.NumSimultaneousRTs = bx::uint32_min(m_caps.NumSimultaneousRTs, BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS);
g_caps.maxFBAttachments = (uint8_t)m_caps.NumSimultaneousRTs; g_caps.maxFBAttachments = (uint8_t)m_caps.NumSimultaneousRTs;
#if BGFX_CONFIG_RENDERER_USE_EXTENSIONS if (BX_ENABLED(BGFX_CONFIG_RENDERER_USE_EXTENSIONS) )
{
BX_TRACE("Extended formats:"); BX_TRACE("Extended formats:");
for (uint32_t ii = 0; ii < ExtendedFormat::Count; ++ii) for (uint32_t ii = 0; ii < ExtendedFormat::Count; ++ii)
{ {
@ -456,8 +458,7 @@ namespace bgfx
if (m_amd if (m_amd
&& s_extendedFormats[ExtendedFormat::Inst].m_supported) && s_extendedFormats[ExtendedFormat::Inst].m_supported)
{ { // AMD only
// AMD only
m_device->SetRenderState(D3DRS_POINTSIZE, D3DFMT_INST); m_device->SetRenderState(D3DRS_POINTSIZE, D3DFMT_INST);
} }
@ -482,7 +483,7 @@ namespace bgfx
, s_textureFormat[ii].m_fmt , s_textureFormat[ii].m_fmt
) ) ? 1 : 0; ) ) ? 1 : 0;
} }
#endif // BGFX_CONFIG_RENDERER_USE_EXTENSIONS }
uint32_t index = 1; uint32_t index = 1;
for (const D3DFORMAT* fmt = &s_checkColorFormats[index]; *fmt != D3DFMT_UNKNOWN; ++fmt, ++index) for (const D3DFORMAT* fmt = &s_checkColorFormats[index]; *fmt != D3DFMT_UNKNOWN; ++fmt, ++index)

View file

@ -1187,6 +1187,8 @@ namespace bgfx
|| s_extension[Extension::OES_vertex_array_object].m_supported || s_extension[Extension::OES_vertex_array_object].m_supported
; ;
m_vaoSupport &= false;
if (BX_ENABLED(BX_PLATFORM_NACL) ) if (BX_ENABLED(BX_PLATFORM_NACL) )
{ {
m_vaoSupport &= NULL != glGenVertexArrays m_vaoSupport &= NULL != glGenVertexArrays
@ -1240,6 +1242,11 @@ namespace bgfx
: 0 : 0
; ;
g_caps.supported |= GlContext::isSwapChainSupported()
? BGFX_CAPS_SWAP_CHAIN
: 0
;
if (s_extension[Extension::EXT_texture_filter_anisotropic].m_supported) if (s_extension[Extension::EXT_texture_filter_anisotropic].m_supported)
{ {
GL_CHECK(glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &m_maxAnisotropy) ); GL_CHECK(glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &m_maxAnisotropy) );
@ -3870,10 +3877,13 @@ namespace bgfx
} }
uint16_t FrameBufferGL::destroy() uint16_t FrameBufferGL::destroy()
{
if (0 != m_num)
{ {
GL_CHECK(glDeleteFramebuffers(0 == m_fbo[1] ? 1 : 2, m_fbo) ); GL_CHECK(glDeleteFramebuffers(0 == m_fbo[1] ? 1 : 2, m_fbo) );
memset(m_fbo, 0, sizeof(m_fbo) ); memset(m_fbo, 0, sizeof(m_fbo) );
m_num = 0; m_num = 0;
}
if (NULL != m_swapChain) if (NULL != m_swapChain)
{ {