diff options
Diffstat (limited to '3rdparty/bgfx/src/renderer_gl.cpp')
-rw-r--r-- | 3rdparty/bgfx/src/renderer_gl.cpp | 116 |
1 files changed, 79 insertions, 37 deletions
diff --git a/3rdparty/bgfx/src/renderer_gl.cpp b/3rdparty/bgfx/src/renderer_gl.cpp index 7fc65a3dbd8..43516be1919 100644 --- a/3rdparty/bgfx/src/renderer_gl.cpp +++ b/3rdparty/bgfx/src/renderer_gl.cpp @@ -534,6 +534,8 @@ namespace bgfx { namespace gl EXT_discard_framebuffer, EXT_disjoint_timer_query, EXT_draw_buffers, + EXT_draw_instanced, + EXT_instanced_arrays, EXT_frag_depth, EXT_framebuffer_blit, EXT_framebuffer_object, @@ -583,6 +585,7 @@ namespace bgfx { namespace gl MOZ_WEBGL_compressed_texture_s3tc, MOZ_WEBGL_depth_texture, + NV_conservative_raster, NV_copy_image, NV_draw_buffers, NV_occlusion_query, @@ -739,6 +742,8 @@ namespace bgfx { namespace gl { "EXT_discard_framebuffer", false, true }, // GLES2 extension. { "EXT_disjoint_timer_query", false, true }, // GLES2 extension. { "EXT_draw_buffers", false, true }, // GLES2 extension. + { "EXT_draw_instanced", false, true }, // GLES2 extension. + { "EXT_instanced_arrays", false, true }, // GLES2 extension. { "EXT_frag_depth", false, true }, // GLES2 extension. { "EXT_framebuffer_blit", BGFX_CONFIG_RENDERER_OPENGL >= 30, true }, { "EXT_framebuffer_object", BGFX_CONFIG_RENDERER_OPENGL >= 30, true }, @@ -788,6 +793,7 @@ namespace bgfx { namespace gl { "MOZ_WEBGL_compressed_texture_s3tc", false, true }, { "MOZ_WEBGL_depth_texture", false, true }, + { "NV_conservative_raster", false, true }, { "NV_copy_image", false, true }, { "NV_draw_buffers", false, true }, // GLES2 extension. { "NV_occlusion_query", false, true }, @@ -1273,6 +1279,8 @@ namespace bgfx { namespace gl , m_depthTextureSupport(false) , m_timerQuerySupport(false) , m_occlusionQuerySupport(false) + , m_atocSupport(false) + , m_conservativeRasterSupport(false) , m_flip(false) , m_hash( (BX_PLATFORM_WINDOWS<<1) | BX_ARCH_64BIT) , m_backBufferFbo(0) @@ -1866,19 +1874,15 @@ namespace bgfx { namespace gl && NULL != glEndQuery ; - g_caps.supported |= m_occlusionQuerySupport - ? BGFX_CAPS_OCCLUSION_QUERY - : 0 - ; - - g_caps.supported |= m_depthTextureSupport - ? BGFX_CAPS_TEXTURE_COMPARE_LEQUAL - : 0 - ; + m_atocSupport = s_extension[Extension::ARB_multisample].m_supported; + m_conservativeRasterSupport = s_extension[Extension::NV_conservative_raster].m_supported; - g_caps.supported |= computeSupport - ? BGFX_CAPS_COMPUTE - : 0 + g_caps.supported |= 0 + | (m_atocSupport ? BGFX_CAPS_ALPHA_TO_COVERAGE : 0) + | (m_conservativeRasterSupport ? BGFX_CAPS_CONSERVATIVE_RASTER : 0) + | (m_occlusionQuerySupport ? BGFX_CAPS_OCCLUSION_QUERY : 0) + | (m_depthTextureSupport ? BGFX_CAPS_TEXTURE_COMPARE_LEQUAL : 0) + | (computeSupport ? BGFX_CAPS_COMPUTE : 0) ; g_caps.supported |= m_glctx.getCaps(); @@ -1921,17 +1925,15 @@ namespace bgfx { namespace gl } else { - if (!BX_ENABLED(BX_PLATFORM_IOS) ) + if (s_extension[Extension::ANGLE_instanced_arrays].m_supported + || s_extension[Extension::ARB_instanced_arrays].m_supported + || s_extension[Extension::EXT_instanced_arrays].m_supported) { - if (s_extension[Extension::ARB_instanced_arrays].m_supported - || s_extension[Extension::ANGLE_instanced_arrays].m_supported) + if (NULL != glVertexAttribDivisor + && NULL != glDrawArraysInstanced + && NULL != glDrawElementsInstanced) { - if (NULL != glVertexAttribDivisor - && NULL != glDrawArraysInstanced - && NULL != glDrawElementsInstanced) - { - g_caps.supported |= BGFX_CAPS_INSTANCING; - } + g_caps.supported |= BGFX_CAPS_INSTANCING; } } @@ -2225,7 +2227,6 @@ namespace bgfx { namespace gl bx::write(&writer, magic); TextureCreate tc; - tc.m_flags = texture.m_flags; tc.m_width = _width; tc.m_height = _height; tc.m_sides = 0; @@ -2237,7 +2238,7 @@ namespace bgfx { namespace gl bx::write(&writer, tc); texture.destroy(); - texture.create(mem, tc.m_flags, 0); + texture.create(mem, texture.m_flags, 0); release(mem); } @@ -2456,7 +2457,12 @@ namespace bgfx { namespace gl } } - uint32_t flags = _resolution.m_flags & ~(BGFX_RESET_HMD_RECENTER | BGFX_RESET_MAXANISOTROPY | BGFX_RESET_DEPTH_CLAMP); + uint32_t flags = _resolution.m_flags & ~(0 + | BGFX_RESET_HMD_RECENTER + | BGFX_RESET_MAXANISOTROPY + | BGFX_RESET_DEPTH_CLAMP + | BGFX_RESET_SUSPEND + ); if (m_resolution.m_width != _resolution.m_width || m_resolution.m_height != _resolution.m_height @@ -2559,7 +2565,6 @@ namespace bgfx { namespace gl if (UINT16_MAX != frameBuffer.m_denseIdx) { m_glctx.makeCurrent(frameBuffer.m_swapChain); - GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, 0) ); } else { @@ -3301,6 +3306,8 @@ namespace bgfx { namespace gl bool m_depthTextureSupport; bool m_timerQuerySupport; bool m_occlusionQuerySupport; + bool m_atocSupport; + bool m_conservativeRasterSupport; bool m_flip; uint64_t m_hash; @@ -5377,13 +5384,13 @@ namespace bgfx { namespace gl if (0 < _render->m_iboffset) { TransientIndexBuffer* ib = _render->m_transientIb; - m_indexBuffers[ib->handle.idx].update(0, _render->m_iboffset, ib->data); + m_indexBuffers[ib->handle.idx].update(0, _render->m_iboffset, ib->data, true); } if (0 < _render->m_vboffset) { TransientVertexBuffer* vb = _render->m_transientVb; - m_vertexBuffers[vb->handle.idx].update(0, _render->m_vboffset, vb->data); + m_vertexBuffers[vb->handle.idx].update(0, _render->m_vboffset, vb->data, true); } _render->sort(); @@ -5862,6 +5869,8 @@ namespace bgfx { namespace gl | BGFX_STATE_PT_MASK | BGFX_STATE_POINT_SIZE_MASK | BGFX_STATE_MSAA + | BGFX_STATE_LINEAA + | BGFX_STATE_CONSERVATIVE_RASTER ) & changedFlags) { if (BGFX_STATE_CULL_MASK & changedFlags) @@ -5917,14 +5926,27 @@ namespace bgfx { namespace gl if (BGFX_STATE_MSAA & changedFlags) { - if (BGFX_STATE_MSAA & newFlags) - { - GL_CHECK(glEnable(GL_MULTISAMPLE) ); - } - else - { - GL_CHECK(glDisable(GL_MULTISAMPLE) ); - } + GL_CHECK(BGFX_STATE_MSAA & newFlags + ? glEnable(GL_MULTISAMPLE) + : glDisable(GL_MULTISAMPLE) + ); + } + + if (BGFX_STATE_LINEAA & changedFlags) + { + GL_CHECK(BGFX_STATE_LINEAA & newFlags + ? glEnable(GL_LINE_SMOOTH) + : glDisable(GL_LINE_SMOOTH) + ); + } + + if (m_conservativeRasterSupport + && BGFX_STATE_CONSERVATIVE_RASTER & changedFlags) + { + GL_CHECK(BGFX_STATE_CONSERVATIVE_RASTER & newFlags + ? glEnable(GL_CONSERVATIVE_RASTERIZATION_NV) + : glDisable(GL_CONSERVATIVE_RASTERIZATION_NV) + ); } #endif // BGFX_CONFIG_RENDERER_OPENGL @@ -5935,10 +5957,30 @@ namespace bgfx { namespace gl GL_CHECK(glColorMask(rgb, rgb, rgb, alpha) ); } - if ( (BGFX_STATE_BLEND_MASK|BGFX_STATE_BLEND_EQUATION_MASK|BGFX_STATE_BLEND_INDEPENDENT) & changedFlags + if ( ( (0 + | BGFX_STATE_BLEND_MASK + | BGFX_STATE_BLEND_EQUATION_MASK + | BGFX_STATE_BLEND_INDEPENDENT + | BGFX_STATE_BLEND_ALPHA_TO_COVERAGE + ) & changedFlags) || blendFactor != draw.m_rgba) { - if ( (BGFX_STATE_BLEND_MASK|BGFX_STATE_BLEND_EQUATION_MASK|BGFX_STATE_BLEND_INDEPENDENT) & newFlags + if (m_atocSupport) + { + if (BGFX_STATE_BLEND_ALPHA_TO_COVERAGE & newFlags) + { + GL_CHECK(glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE) ); + } + else + { + GL_CHECK(glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE) ); + } + } + + if ( ( (0 + | BGFX_STATE_BLEND_MASK + | BGFX_STATE_BLEND_EQUATION_MASK + | BGFX_STATE_BLEND_INDEPENDENT) & newFlags) || blendFactor != draw.m_rgba) { const bool enabled = !!(BGFX_STATE_BLEND_MASK & newFlags); |