mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 00:58:30 -05:00
Added swap chain caps.
This commit is contained in:
parent
dd5492c29a
commit
f4c7f69ed7
19 changed files with 117 additions and 52 deletions
|
@ -94,8 +94,6 @@ static const InputBinding s_bindings[] =
|
|||
|
||||
int _main_(int /*_argc*/, char** /*_argv*/)
|
||||
{
|
||||
inputAddBindings("22-windows", s_bindings);
|
||||
|
||||
uint32_t width = 1280;
|
||||
uint32_t height = 720;
|
||||
uint32_t debug = BGFX_DEBUG_TEXT;
|
||||
|
@ -104,6 +102,14 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
|||
bgfx::init();
|
||||
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.
|
||||
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, 2, 0x6f, "Description: Rendering into multiple windows.");
|
||||
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.");
|
||||
}
|
||||
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;
|
||||
|
||||
|
|
|
@ -277,6 +277,7 @@ namespace entry
|
|||
clear(hwnd);
|
||||
|
||||
m_hwnd[_wparam] = hwnd;
|
||||
m_flags[_wparam] = msg->m_flags;
|
||||
WindowHandle handle = { (uint16_t)_wparam };
|
||||
m_eventQueue.postSizeEvent(handle, msg->m_width, msg->m_height);
|
||||
m_eventQueue.postWindowEvent(handle, hwnd);
|
||||
|
|
|
@ -275,5 +275,6 @@
|
|||
#define BGFX_CAPS_BLEND_INDEPENDENT UINT64_C(0x0000000000000080)
|
||||
#define BGFX_CAPS_COMPUTE UINT64_C(0x0000000000000100)
|
||||
#define BGFX_CAPS_FRAGMENT_ORDERING UINT64_C(0x0000000000000200)
|
||||
#define BGFX_CAPS_SWAP_CHAIN UINT64_C(0x0000000000000400)
|
||||
|
||||
#endif // BGFX_DEFINES_H_HEADER_GUARD
|
||||
|
|
|
@ -23,6 +23,7 @@ namespace bgfx
|
|||
void destroy();
|
||||
void resize(uint32_t _width, uint32_t _height, bool _vsync);
|
||||
|
||||
static bool isSwapChainSupported();
|
||||
SwapChainGL* createSwapChain(void* _nwh);
|
||||
void destorySwapChain(SwapChainGL* _swapChain);
|
||||
void swap(SwapChainGL* _swapChain = NULL);
|
||||
|
|
|
@ -91,6 +91,11 @@ namespace bgfx
|
|||
BX_TRACE("resize context");
|
||||
}
|
||||
|
||||
bool GlContext::isSwapChainSupported()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
SwapChainGL* GlContext::createSwapChain(void* /*_nwh*/)
|
||||
{
|
||||
BX_CHECK(false, "Shouldn't be called!");
|
||||
|
|
|
@ -237,6 +237,11 @@ EGL_IMPORT
|
|||
eglSwapInterval(m_display, _vsync ? 1 : 0);
|
||||
}
|
||||
|
||||
bool GlContext::isSwapChainSupported()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
SwapChainGL* GlContext::createSwapChain(void* /*_nwh*/)
|
||||
{
|
||||
BX_CHECK(false, "Shouldn't be called!");
|
||||
|
|
|
@ -27,6 +27,7 @@ namespace bgfx
|
|||
void destroy();
|
||||
void resize(uint32_t _width, uint32_t _height, bool _vsync);
|
||||
|
||||
static bool isSwapChainSupported();
|
||||
SwapChainGL* createSwapChain(void* _nwh);
|
||||
void destorySwapChain(SwapChainGL* _swapChain);
|
||||
void swap(SwapChainGL* _swapChain = NULL);
|
||||
|
|
|
@ -212,6 +212,11 @@ namespace bgfx
|
|||
}
|
||||
}
|
||||
|
||||
bool GlContext::isSwapChainSupported()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
SwapChainGL* GlContext::createSwapChain(void* /*_nwh*/)
|
||||
{
|
||||
BX_CHECK(false, "Shouldn't be called!");
|
||||
|
|
|
@ -26,6 +26,7 @@ namespace bgfx
|
|||
void destroy();
|
||||
void resize(uint32_t _width, uint32_t _height, bool _vsync);
|
||||
|
||||
static bool isSwapChainSupported();
|
||||
SwapChainGL* createSwapChain(void* _nwh);
|
||||
void destorySwapChain(SwapChainGL* _swapChain);
|
||||
void swap(SwapChainGL* _swapChain = NULL);
|
||||
|
|
|
@ -23,6 +23,7 @@ namespace bgfx
|
|||
void destroy();
|
||||
void resize(uint32_t _width, uint32_t _height, bool _vsync);
|
||||
|
||||
static bool isSwapChainSupported();
|
||||
SwapChainGL* createSwapChain(void* _nwh);
|
||||
void destorySwapChain(SwapChainGL* _swapChain);
|
||||
void swap(SwapChainGL* _swapChain = NULL);
|
||||
|
|
|
@ -88,6 +88,11 @@ namespace bgfx
|
|||
[glContext setValues:&interval forParameter:NSOpenGLCPSwapInterval];
|
||||
}
|
||||
|
||||
bool GlContext::isSwapChainSupported()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
SwapChainGL* GlContext::createSwapChain(void* /*_nwh*/)
|
||||
{
|
||||
BX_CHECK(false, "Shouldn't be called!");
|
||||
|
|
|
@ -158,6 +158,11 @@ namespace bgfx
|
|||
s_ppapi.resize(_width, _height, _vsync);
|
||||
}
|
||||
|
||||
bool GlContext::isSwapChainSupported()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
SwapChainGL* GlContext::createSwapChain(void* /*_nwh*/)
|
||||
{
|
||||
BX_CHECK(false, "Shouldn't be called!");
|
||||
|
|
|
@ -27,6 +27,7 @@ namespace bgfx
|
|||
void destroy();
|
||||
void resize(uint32_t _width, uint32_t _height, bool _vsync);
|
||||
|
||||
static bool isSwapChainSupported();
|
||||
SwapChainGL* createSwapChain(void* _nwh);
|
||||
void destorySwapChain(SwapChainGL* _swapChain);
|
||||
void swap(SwapChainGL* _swapChain = NULL);
|
||||
|
|
|
@ -292,6 +292,11 @@ namespace bgfx
|
|||
}
|
||||
}
|
||||
|
||||
bool GlContext::isSwapChainSupported()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
SwapChainGL* GlContext::createSwapChain(void* _nwh)
|
||||
{
|
||||
SwapChainGL* swapChain = BX_NEW(g_allocator, SwapChainGL)(_nwh);
|
||||
|
|
|
@ -71,6 +71,7 @@ typedef void (APIENTRYP PFNGLSTENCILOPPROC) (GLenum fail, GLenum zfail, GLenum z
|
|||
void destroy();
|
||||
void resize(uint32_t _width, uint32_t _height, bool _vsync);
|
||||
|
||||
static bool isSwapChainSupported();
|
||||
SwapChainGL* createSwapChain(void* _nwh);
|
||||
void destorySwapChain(SwapChainGL* _swapChain);
|
||||
void swap(SwapChainGL* _swapChain = NULL);
|
||||
|
|
|
@ -611,6 +611,7 @@ namespace bgfx
|
|||
| BGFX_CAPS_BLEND_INDEPENDENT
|
||||
| BGFX_CAPS_COMPUTE
|
||||
| (getIntelExtensions(m_device) ? BGFX_CAPS_FRAGMENT_ORDERING : 0)
|
||||
| BGFX_CAPS_SWAP_CHAIN
|
||||
);
|
||||
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);
|
||||
|
|
|
@ -432,13 +432,15 @@ namespace bgfx
|
|||
| BGFX_CAPS_TEXTURE_COMPARE_LEQUAL
|
||||
| BGFX_CAPS_VERTEX_ATTRIB_HALF
|
||||
| BGFX_CAPS_FRAGMENT_DEPTH
|
||||
| BGFX_CAPS_SWAP_CHAIN
|
||||
);
|
||||
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);
|
||||
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:");
|
||||
for (uint32_t ii = 0; ii < ExtendedFormat::Count; ++ii)
|
||||
{
|
||||
|
@ -456,8 +458,7 @@ namespace bgfx
|
|||
|
||||
if (m_amd
|
||||
&& s_extendedFormats[ExtendedFormat::Inst].m_supported)
|
||||
{
|
||||
// AMD only
|
||||
{ // AMD only
|
||||
m_device->SetRenderState(D3DRS_POINTSIZE, D3DFMT_INST);
|
||||
}
|
||||
|
||||
|
@ -482,7 +483,7 @@ namespace bgfx
|
|||
, s_textureFormat[ii].m_fmt
|
||||
) ) ? 1 : 0;
|
||||
}
|
||||
#endif // BGFX_CONFIG_RENDERER_USE_EXTENSIONS
|
||||
}
|
||||
|
||||
uint32_t index = 1;
|
||||
for (const D3DFORMAT* fmt = &s_checkColorFormats[index]; *fmt != D3DFMT_UNKNOWN; ++fmt, ++index)
|
||||
|
|
|
@ -1187,6 +1187,8 @@ namespace bgfx
|
|||
|| s_extension[Extension::OES_vertex_array_object].m_supported
|
||||
;
|
||||
|
||||
m_vaoSupport &= false;
|
||||
|
||||
if (BX_ENABLED(BX_PLATFORM_NACL) )
|
||||
{
|
||||
m_vaoSupport &= NULL != glGenVertexArrays
|
||||
|
@ -1240,6 +1242,11 @@ namespace bgfx
|
|||
: 0
|
||||
;
|
||||
|
||||
g_caps.supported |= GlContext::isSwapChainSupported()
|
||||
? BGFX_CAPS_SWAP_CHAIN
|
||||
: 0
|
||||
;
|
||||
|
||||
if (s_extension[Extension::EXT_texture_filter_anisotropic].m_supported)
|
||||
{
|
||||
GL_CHECK(glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &m_maxAnisotropy) );
|
||||
|
@ -3870,10 +3877,13 @@ namespace bgfx
|
|||
}
|
||||
|
||||
uint16_t FrameBufferGL::destroy()
|
||||
{
|
||||
if (0 != m_num)
|
||||
{
|
||||
GL_CHECK(glDeleteFramebuffers(0 == m_fbo[1] ? 1 : 2, m_fbo) );
|
||||
memset(m_fbo, 0, sizeof(m_fbo) );
|
||||
m_num = 0;
|
||||
}
|
||||
|
||||
if (NULL != m_swapChain)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue