Skip to content

Commit

Permalink
MythRenderOpenGL: Remove framebuffer discard support
Browse files Browse the repository at this point in the history
- this is not working as intended and further digging suggests it is not
appropriate for our prospective use case
  • Loading branch information
mark-kendall committed Mar 11, 2019
1 parent 47df3ef commit a599277
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 69 deletions.
20 changes: 0 additions & 20 deletions mythtv/libs/libmythtv/openglvideo.cpp
Expand Up @@ -64,15 +64,6 @@ OpenGLVideo::OpenGLVideo(MythRenderOpenGL *Render, VideoColourSpace *ColourSpace
m_features = m_render->GetFeatures();
m_extraFeatures = m_render->GetExtraFeatures();

// Enable/Disable certain features based on settings
if (m_render->isOpenGLES())
{
if ((m_extraFeatures & kGLExtFBDiscard) && gCoreContext->GetBoolSetting("OpenGLDiscardFB", false))
LOG(VB_GENERAL, LOG_INFO, LOC + "Enabling Framebuffer discards");
else
m_extraFeatures &= ~kGLExtFBDiscard;
}

// Create initial input texture. Hardware textures are created on demand.
MythGLTexture *texture = nullptr;
if (kGLInterop != m_frameType)
Expand Down Expand Up @@ -678,8 +669,6 @@ void OpenGLVideo::PrepareFrame(VideoFrame *Frame, bool TopFieldFirst, FrameScanT
LOG(VB_PLAYBACK, LOG_INFO, LOC + "Enabled resizing");
}

bool discardframebuffer = false;

if (resize)
{
// render to texture stage
Expand Down Expand Up @@ -729,7 +718,6 @@ void OpenGLVideo::PrepareFrame(VideoFrame *Frame, bool TopFieldFirst, FrameScanT
inputtextures.clear();
inputtextures.push_back(m_frameBufferTexture);
program = Default;
discardframebuffer = true;
deinterlacing = false;
}

Expand Down Expand Up @@ -775,14 +763,6 @@ void OpenGLVideo::PrepareFrame(VideoFrame *Frame, bool TopFieldFirst, FrameScanT
// draw
m_render->DrawBitmap(textures, numtextures, nullptr, trect, m_displayVideoRect, m_shaders[program]);

// discard
if (m_extraFeatures & kGLExtFBDiscard)
{
if (discardframebuffer && m_frameBuffer)
m_render->DiscardFramebuffer(m_frameBuffer);
m_render->DiscardFramebuffer(nullptr);
}

if (VERBOSE_LEVEL_CHECK(VB_GPU, LOG_INFO))
m_render->logDebugMarker(LOC + "PREP_FRAME_END");
}
Expand Down
20 changes: 0 additions & 20 deletions mythtv/libs/libmythui/mythrender_opengl.cpp
Expand Up @@ -142,7 +142,6 @@ MythRenderOpenGL::MythRenderOpenGL(const QSurfaceFormat& Format, QPaintDevice* D
m_glDeleteFencesAPPLE(nullptr),
m_glSetFenceAPPLE(nullptr),
m_glFinishFenceAPPLE(nullptr),
m_glDiscardFramebuffer(nullptr),
m_openglDebugger(nullptr),
m_window(nullptr)
{
Expand Down Expand Up @@ -289,10 +288,6 @@ bool MythRenderOpenGL::Init(void)
m_glSetFenceAPPLE && m_glFinishFenceAPPLE)
m_extraFeatures |= kGLAppleFence;

// Framebuffer discard - GLES only
if (isOpenGLES() && hasExtension("GL_EXT_discard_framebuffer") && m_glDiscardFramebuffer)
m_extraFeatures |= kGLExtFBDiscard;

// Rectangular textures
if (!isOpenGLES() && (hasExtension("GL_NV_texture_rectangle") ||
hasExtension("GL_ARB_texture_rectangle") ||
Expand Down Expand Up @@ -345,7 +340,6 @@ void MythRenderOpenGL::DebugFeatures(void)
LOG(VB_GENERAL, LOG_INFO, LOC + QString("RGBA16 textures : %1").arg(GLYesNo(m_extraFeatures & kGLExtRGBA16)));
LOG(VB_GENERAL, LOG_INFO, LOC + QString("Buffer mapping : %1").arg(GLYesNo(m_extraFeatures & kGLBufferMap)));
LOG(VB_GENERAL, LOG_INFO, LOC + QString("Framebuffer objects : %1").arg(GLYesNo(m_features & Framebuffers)));
LOG(VB_GENERAL, LOG_INFO, LOC + QString("Framebuffer discard : %1").arg(GLYesNo(m_extraFeatures & kGLExtFBDiscard)));
LOG(VB_GENERAL, LOG_INFO, LOC + QString("Fence : %1")
.arg(GLYesNo((m_extraFeatures & kGLAppleFence) || (m_extraFeatures & kGLNVFence))));

Expand Down Expand Up @@ -874,19 +868,6 @@ void MythRenderOpenGL::ClearFramebuffer(void)
doneCurrent();
}

void MythRenderOpenGL::DiscardFramebuffer(QOpenGLFramebufferObject *Framebuffer)
{
if (!(m_extraFeaturesUsed & kGLExtFBDiscard))
return;

makeCurrent();
static const GLenum fbdiscards[] = { GL_COLOR_ATTACHMENT0 };
static const GLenum dfdiscards[] = { GL_COLOR_EXT };
BindFramebuffer(Framebuffer);
m_glDiscardFramebuffer(GL_FRAMEBUFFER, 1, (Framebuffer ? true : defaultFramebufferObject()) ? fbdiscards : dfdiscards);
doneCurrent();
}

void MythRenderOpenGL::DrawBitmap(MythGLTexture *Texture, QOpenGLFramebufferObject *Target,
const QRect &Source, const QRect &Destination,
QOpenGLShaderProgram *Program, int Alpha,
Expand Down Expand Up @@ -1251,7 +1232,6 @@ void MythRenderOpenGL::InitProcs(void)
m_glDeleteFencesAPPLE = reinterpret_cast<MYTH_GLDELETEFENCESAPPLEPROC>(GetProcAddress("glDeleteFencesAPPLE"));
m_glSetFenceAPPLE = reinterpret_cast<MYTH_GLSETFENCEAPPLEPROC>(GetProcAddress("glSetFenceAPPLE"));
m_glFinishFenceAPPLE = reinterpret_cast<MYTH_GLFINISHFENCEAPPLEPROC>(GetProcAddress("glFinishFenceAPPLE"));
m_glDiscardFramebuffer = reinterpret_cast<MYTH_GLDISCARDFRAMEBUFFER>(GetProcAddress("glDiscardFramebufferEXT"));
}

QFunctionPointer MythRenderOpenGL::GetProcAddress(const QString &Proc) const
Expand Down
14 changes: 5 additions & 9 deletions mythtv/libs/libmythui/mythrender_opengl.h
Expand Up @@ -29,12 +29,11 @@
typedef enum
{
kGLFeatNone = 0x0000,
kGLExtFBDiscard= 0x0001,
kGLNVFence = 0x0002,
kGLAppleFence = 0x0004,
kGLBufferMap = 0x0008,
kGLExtRects = 0x0010,
kGLExtRGBA16 = 0x0020
kGLNVFence = 0x0001,
kGLAppleFence = 0x0002,
kGLBufferMap = 0x0004,
kGLExtRects = 0x0008,
kGLExtRGBA16 = 0x0010
} GLFeatures;

#define TEX_OFFSET 8
Expand Down Expand Up @@ -142,7 +141,6 @@ class MUI_PUBLIC MythRenderOpenGL : public QOpenGLContext, public QOpenGLFunctio
void DeleteFramebuffer(QOpenGLFramebufferObject *Framebuffer);
void BindFramebuffer(QOpenGLFramebufferObject *Framebuffer);
void ClearFramebuffer(void);
void DiscardFramebuffer(QOpenGLFramebufferObject *Framebuffer);

QOpenGLShaderProgram* CreateShaderProgram(const QString &Vertex, const QString &Fragment);
void DeleteShaderProgram(QOpenGLShaderProgram* Program);
Expand Down Expand Up @@ -247,8 +245,6 @@ class MUI_PUBLIC MythRenderOpenGL : public QOpenGLContext, public QOpenGLFunctio
MYTH_GLDELETEFENCESAPPLEPROC m_glDeleteFencesAPPLE;
MYTH_GLSETFENCEAPPLEPROC m_glSetFenceAPPLE;
MYTH_GLFINISHFENCEAPPLEPROC m_glFinishFenceAPPLE;
// Framebuffer discard
MYTH_GLDISCARDFRAMEBUFFER m_glDiscardFramebuffer;

private:
void DebugFeatures (void);
Expand Down
20 changes: 0 additions & 20 deletions mythtv/programs/mythfrontend/globalsettings.cpp
Expand Up @@ -130,16 +130,6 @@ static HostCheckBoxSetting *OpenGLExtraStage()

return gc;
}

static HostCheckBoxSetting *OpenGLDiscardFB()
{
HostCheckBoxSetting *gc = new HostCheckBoxSetting("OpenGLDiscardFB");
gc->setLabel(PlaybackSettings::tr("Discard OpenGL Framebuffers"));
gc->setHelpText(PlaybackSettings::tr(
"Enable to improve performance on some OpenGL ES GPU implementations (e.g. ARM Mali, Qualcomm Adreno) EXPERIMENTAL."));
gc->setValue(false);
return gc;
}
#endif

#if CONFIG_DEBUGTYPE
Expand Down Expand Up @@ -4262,17 +4252,7 @@ void PlaybackSettings::Load(void)
avsync2->addTargetedChild("1",AVSync2AdjustMS());

#ifdef USE_OPENGL_PAINTER
bool isOpenGLES = false;
MythMainWindow* main = static_cast<MythMainWindow*>(gCoreContext->GetGUIObject());
if (main)
{
MythRenderOpenGL* render = static_cast<MythRenderOpenGL*>(main->GetRenderDevice());
if (render)
isOpenGLES = render->isOpenGLES();
}
advanced->addChild(OpenGLExtraStage());
if (isOpenGLES)
advanced->addChild(OpenGLDiscardFB());
#endif
addChild(advanced);

Expand Down

0 comments on commit a599277

Please sign in to comment.