|
@@ -322,6 +322,7 @@ namespace bgfx
|
|
|
ARB_half_float_pixel,
|
|
ARB_half_float_pixel,
|
|
|
ARB_half_float_vertex,
|
|
ARB_half_float_vertex,
|
|
|
ARB_instanced_arrays,
|
|
ARB_instanced_arrays,
|
|
|
|
|
+ ARB_invalidate_subdata,
|
|
|
ARB_map_buffer_range,
|
|
ARB_map_buffer_range,
|
|
|
ARB_multisample,
|
|
ARB_multisample,
|
|
|
ARB_occlusion_query,
|
|
ARB_occlusion_query,
|
|
@@ -363,6 +364,7 @@ namespace bgfx
|
|
|
EXT_compressed_ETC1_RGB8_sub_texture,
|
|
EXT_compressed_ETC1_RGB8_sub_texture,
|
|
|
EXT_debug_label,
|
|
EXT_debug_label,
|
|
|
EXT_debug_marker,
|
|
EXT_debug_marker,
|
|
|
|
|
+ EXT_discard_framebuffer,
|
|
|
EXT_draw_buffers,
|
|
EXT_draw_buffers,
|
|
|
EXT_frag_depth,
|
|
EXT_frag_depth,
|
|
|
EXT_framebuffer_blit,
|
|
EXT_framebuffer_blit,
|
|
@@ -480,6 +482,7 @@ namespace bgfx
|
|
|
{ "ARB_half_float_pixel", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
|
|
{ "ARB_half_float_pixel", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
|
|
|
{ "ARB_half_float_vertex", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
|
|
{ "ARB_half_float_vertex", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
|
|
|
{ "ARB_instanced_arrays", BGFX_CONFIG_RENDERER_OPENGL >= 33, true },
|
|
{ "ARB_instanced_arrays", BGFX_CONFIG_RENDERER_OPENGL >= 33, true },
|
|
|
|
|
+ { "ARB_invalidate_subdata", BGFX_CONFIG_RENDERER_OPENGL >= 43, true },
|
|
|
{ "ARB_map_buffer_range", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
|
|
{ "ARB_map_buffer_range", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
|
|
|
{ "ARB_multisample", false, true },
|
|
{ "ARB_multisample", false, true },
|
|
|
{ "ARB_occlusion_query", BGFX_CONFIG_RENDERER_OPENGL >= 33, true },
|
|
{ "ARB_occlusion_query", BGFX_CONFIG_RENDERER_OPENGL >= 33, true },
|
|
@@ -521,6 +524,7 @@ namespace bgfx
|
|
|
{ "EXT_compressed_ETC1_RGB8_sub_texture", false, true }, // GLES2 extension.
|
|
{ "EXT_compressed_ETC1_RGB8_sub_texture", false, true }, // GLES2 extension.
|
|
|
{ "EXT_debug_label", false, true },
|
|
{ "EXT_debug_label", false, true },
|
|
|
{ "EXT_debug_marker", false, true },
|
|
{ "EXT_debug_marker", false, true },
|
|
|
|
|
+ { "EXT_discard_framebuffer", false, true }, // GLES2 extension.
|
|
|
{ "EXT_draw_buffers", false, true }, // GLES2 extension.
|
|
{ "EXT_draw_buffers", false, true }, // GLES2 extension.
|
|
|
{ "EXT_frag_depth", false, true }, // GLES2 extension.
|
|
{ "EXT_frag_depth", false, true }, // GLES2 extension.
|
|
|
{ "EXT_framebuffer_blit", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
|
|
{ "EXT_framebuffer_blit", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
|
|
@@ -691,6 +695,10 @@ namespace bgfx
|
|
|
{
|
|
{
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ static void GL_APIENTRY stubInvalidateFramebuffer(GLenum /*_target*/, GLsizei /*_numAttachments*/, const GLenum* /*_attachments*/)
|
|
|
|
|
+ {
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
typedef void (*PostSwapBuffersFn)(uint32_t _width, uint32_t _height);
|
|
typedef void (*PostSwapBuffersFn)(uint32_t _width, uint32_t _height);
|
|
|
|
|
|
|
|
static const char* getGLString(GLenum _name)
|
|
static const char* getGLString(GLenum _name)
|
|
@@ -843,6 +851,7 @@ namespace bgfx
|
|
|
RendererContextGL()
|
|
RendererContextGL()
|
|
|
: m_numWindows(1)
|
|
: m_numWindows(1)
|
|
|
, m_rtMsaa(false)
|
|
, m_rtMsaa(false)
|
|
|
|
|
+ , m_fbDiscard(BGFX_CLEAR_NONE)
|
|
|
, m_capture(NULL)
|
|
, m_capture(NULL)
|
|
|
, m_captureSize(0)
|
|
, m_captureSize(0)
|
|
|
, m_maxAnisotropy(0.0f)
|
|
, m_maxAnisotropy(0.0f)
|
|
@@ -1364,6 +1373,11 @@ namespace bgfx
|
|
|
glObjectLabel = stubObjectLabel;
|
|
glObjectLabel = stubObjectLabel;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if (NULL == glInvalidateFramebuffer)
|
|
|
|
|
+ {
|
|
|
|
|
+ glInvalidateFramebuffer = stubInvalidateFramebuffer;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) )
|
|
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) )
|
|
|
{
|
|
{
|
|
|
m_queries.create();
|
|
m_queries.create();
|
|
@@ -1756,14 +1770,24 @@ namespace bgfx
|
|
|
) );
|
|
) );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- uint32_t setFrameBuffer(FrameBufferHandle _fbh, uint32_t _height, bool _msaa = true)
|
|
|
|
|
|
|
+ uint32_t setFrameBuffer(FrameBufferHandle _fbh, uint32_t _height, uint8_t _discard = BGFX_CLEAR_NONE, bool _msaa = true)
|
|
|
{
|
|
{
|
|
|
if (isValid(m_fbh)
|
|
if (isValid(m_fbh)
|
|
|
&& m_fbh.idx != _fbh.idx
|
|
&& m_fbh.idx != _fbh.idx
|
|
|
- && m_rtMsaa)
|
|
|
|
|
|
|
+ && (BGFX_CLEAR_NONE != m_fbDiscard || m_rtMsaa) )
|
|
|
{
|
|
{
|
|
|
FrameBufferGL& frameBuffer = m_frameBuffers[m_fbh.idx];
|
|
FrameBufferGL& frameBuffer = m_frameBuffers[m_fbh.idx];
|
|
|
- frameBuffer.resolve();
|
|
|
|
|
|
|
+ if (m_rtMsaa)
|
|
|
|
|
+ {
|
|
|
|
|
+ frameBuffer.resolve();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (BGFX_CLEAR_NONE != m_fbDiscard)
|
|
|
|
|
+ {
|
|
|
|
|
+ frameBuffer.discard(m_fbDiscard);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ m_fbDiscard = BGFX_CLEAR_NONE;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
m_glctx.makeCurrent(NULL);
|
|
m_glctx.makeCurrent(NULL);
|
|
@@ -1788,8 +1812,9 @@ namespace bgfx
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- m_fbh = _fbh;
|
|
|
|
|
- m_rtMsaa = _msaa;
|
|
|
|
|
|
|
+ m_fbh = _fbh;
|
|
|
|
|
+ m_fbDiscard = _discard;
|
|
|
|
|
+ m_rtMsaa = _msaa;
|
|
|
|
|
|
|
|
return _height;
|
|
return _height;
|
|
|
}
|
|
}
|
|
@@ -2258,7 +2283,7 @@ namespace bgfx
|
|
|
GLuint flags = 0;
|
|
GLuint flags = 0;
|
|
|
if (BGFX_CLEAR_COLOR & _clear.m_flags)
|
|
if (BGFX_CLEAR_COLOR & _clear.m_flags)
|
|
|
{
|
|
{
|
|
|
- if (BGFX_CLEAR_COLOR_USE_PALETTE_BIT & _clear.m_flags)
|
|
|
|
|
|
|
+ if (BGFX_CLEAR_COLOR_USE_PALETTE & _clear.m_flags)
|
|
|
{
|
|
{
|
|
|
uint8_t index = (uint8_t)bx::uint32_min(BGFX_CONFIG_MAX_CLEAR_COLOR_PALETTE-1, _clear.m_index[0]);
|
|
uint8_t index = (uint8_t)bx::uint32_min(BGFX_CONFIG_MAX_CLEAR_COLOR_PALETTE-1, _clear.m_index[0]);
|
|
|
const float* rgba = _palette[index];
|
|
const float* rgba = _palette[index];
|
|
@@ -2380,7 +2405,7 @@ namespace bgfx
|
|
|
GL_CHECK(glUseProgram(program.m_id) );
|
|
GL_CHECK(glUseProgram(program.m_id) );
|
|
|
program.bindAttributes(vertexDecl, 0);
|
|
program.bindAttributes(vertexDecl, 0);
|
|
|
|
|
|
|
|
- if (BGFX_CLEAR_COLOR_USE_PALETTE_BIT & _clear.m_flags)
|
|
|
|
|
|
|
+ if (BGFX_CLEAR_COLOR_USE_PALETTE & _clear.m_flags)
|
|
|
{
|
|
{
|
|
|
float mrtClear[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS][4];
|
|
float mrtClear[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS][4];
|
|
|
for (uint32_t ii = 0; ii < numMrt; ++ii)
|
|
for (uint32_t ii = 0; ii < numMrt; ++ii)
|
|
@@ -2433,6 +2458,7 @@ namespace bgfx
|
|
|
bool m_rtMsaa;
|
|
bool m_rtMsaa;
|
|
|
|
|
|
|
|
FrameBufferHandle m_fbh;
|
|
FrameBufferHandle m_fbh;
|
|
|
|
|
+ uint32_t m_fbDiscard;
|
|
|
|
|
|
|
|
Resolution m_resolution;
|
|
Resolution m_resolution;
|
|
|
void* m_capture;
|
|
void* m_capture;
|
|
@@ -4100,6 +4126,42 @@ namespace bgfx
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ void FrameBufferGL::discard(uint8_t _flags)
|
|
|
|
|
+ {
|
|
|
|
|
+ GLenum buffers[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS+2];
|
|
|
|
|
+ uint32_t idx = 0;
|
|
|
|
|
+
|
|
|
|
|
+ if (BGFX_CLEAR_NONE != (_flags & BGFX_CLEAR_DISCARD_COLOR_MASK) )
|
|
|
|
|
+ {
|
|
|
|
|
+ for (uint32_t ii = 0, num = m_num; ii < num; ++ii)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (BGFX_CLEAR_NONE != (_flags & (BGFX_CLEAR_DISCARD_COLOR_0<<ii) ) )
|
|
|
|
|
+ {
|
|
|
|
|
+ buffers[idx++] = GL_COLOR_ATTACHMENT0 + ii;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ uint32_t dsFlags = _flags & (BGFX_CLEAR_DISCARD_DEPTH|BGFX_CLEAR_DISCARD_STENCIL);
|
|
|
|
|
+ if (BGFX_CLEAR_NONE != dsFlags)
|
|
|
|
|
+ {
|
|
|
|
|
+ if ( (BGFX_CLEAR_DISCARD_DEPTH|BGFX_CLEAR_DISCARD_STENCIL) == dsFlags)
|
|
|
|
|
+ {
|
|
|
|
|
+ buffers[idx++] = GL_DEPTH_STENCIL_ATTACHMENT;
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (BGFX_CLEAR_DISCARD_DEPTH == dsFlags)
|
|
|
|
|
+ {
|
|
|
|
|
+ buffers[idx++] = GL_DEPTH_ATTACHMENT;
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (BGFX_CLEAR_DISCARD_STENCIL == dsFlags)
|
|
|
|
|
+ {
|
|
|
|
|
+ buffers[idx++] = GL_STENCIL_ATTACHMENT;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ GL_CHECK(glInvalidateFramebuffer(GL_FRAMEBUFFER, idx, buffers) );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
void RendererContextGL::submit(Frame* _render, ClearQuad& _clearQuad, TextVideoMemBlitter& _textVideoMemBlitter)
|
|
void RendererContextGL::submit(Frame* _render, ClearQuad& _clearQuad, TextVideoMemBlitter& _textVideoMemBlitter)
|
|
|
{
|
|
{
|
|
|
if (1 < m_numWindows
|
|
if (1 < m_numWindows
|
|
@@ -4182,6 +4244,7 @@ namespace bgfx
|
|
|
bool viewHasScissor = false;
|
|
bool viewHasScissor = false;
|
|
|
Rect viewScissorRect;
|
|
Rect viewScissorRect;
|
|
|
viewScissorRect.clear();
|
|
viewScissorRect.clear();
|
|
|
|
|
+ uint8_t discardFlags = BGFX_CLEAR_NONE;
|
|
|
|
|
|
|
|
const bool blendIndependentSupported = s_extension[Extension::ARB_draw_buffers_blend].m_supported;
|
|
const bool blendIndependentSupported = s_extension[Extension::ARB_draw_buffers_blend].m_supported;
|
|
|
const bool computeSupported = (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) && s_extension[Extension::ARB_compute_shader].m_supported)
|
|
const bool computeSupported = (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) && s_extension[Extension::ARB_compute_shader].m_supported)
|
|
@@ -4235,7 +4298,7 @@ namespace bgfx
|
|
|
? _render->m_hmd.height
|
|
? _render->m_hmd.height
|
|
|
: _render->m_resolution.m_height
|
|
: _render->m_resolution.m_height
|
|
|
;
|
|
;
|
|
|
- height = setFrameBuffer(fbh, height);
|
|
|
|
|
|
|
+ height = setFrameBuffer(fbh, height, discardFlags);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
viewRestart = ( (BGFX_VIEW_STEREO == (_render->m_viewFlags[view] & BGFX_VIEW_STEREO) ) );
|
|
viewRestart = ( (BGFX_VIEW_STEREO == (_render->m_viewFlags[view] & BGFX_VIEW_STEREO) ) );
|
|
@@ -4284,8 +4347,9 @@ namespace bgfx
|
|
|
) );
|
|
) );
|
|
|
|
|
|
|
|
Clear& clear = _render->m_clear[view];
|
|
Clear& clear = _render->m_clear[view];
|
|
|
|
|
+ discardFlags = clear.m_flags & BGFX_CLEAR_DISCARD_MASK;
|
|
|
|
|
|
|
|
- if (BGFX_CLEAR_NONE != clear.m_flags)
|
|
|
|
|
|
|
+ if (BGFX_CLEAR_NONE != (clear.m_flags & BGFX_CLEAR_MASK) )
|
|
|
{
|
|
{
|
|
|
clearQuad(_clearQuad, viewState.m_rect, clear, height, _render->m_clearColor);
|
|
clearQuad(_clearQuad, viewState.m_rect, clear, height, _render->m_clearColor);
|
|
|
}
|
|
}
|