aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRainer Hochecker <fernetmenta@online.de>2016-10-03 16:03:28 +0200
committerRainer Hochecker <fernetmenta@online.de>2016-10-04 14:59:27 +0200
commitc9dc2d172d46c48f958a2aa96988081b8d6b895e (patch)
treea8d7c02bea9564beba952aadf9f88d0bf74dd367
parentf293c426ec20e192fb76d8efe1558a022fe9011e (diff)
VTB: release CVBuffer after it actually has been rendered
-rw-r--r--xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererVTBGL.cpp92
-rw-r--r--xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererVTBGL.h18
-rw-r--r--xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGL.cpp2
-rw-r--r--xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGL.h2
4 files changed, 86 insertions, 28 deletions
diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererVTBGL.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererVTBGL.cpp
index 9d5e9ddef9..19a32d6387 100644
--- a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererVTBGL.cpp
+++ b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererVTBGL.cpp
@@ -31,22 +31,43 @@
#include <OpenGL/CGLIOSurface.h>
#include "windowing/WindowingFactory.h"
-CRendererVTB::CRendererVTB()
+struct CVTBData
{
+ struct __CVBuffer* m_vtbbuf;
+ GLuint m_fence;
+};
+CRendererVTB::CRendererVTB()
+{
}
CRendererVTB::~CRendererVTB()
{
+ for (int i = 0; i < NUM_BUFFERS; ++i)
+ {
+ DeleteTexture(i);
+ }
+}
+CRenderInfo CRendererVTB::GetRenderInfo()
+{
+ CRenderInfo info;
+ info.formats = m_formats;
+ info.max_buffer_size = NUM_BUFFERS;
+ info.optimal_buffer_size = 5;
+ return info;
}
void CRendererVTB::AddVideoPictureHW(DVDVideoPicture &picture, int index)
{
YUVBUFFER &buf = m_buffers[index];
- if (buf.hwDec)
- CVBufferRelease((struct __CVBuffer *)buf.hwDec);
- buf.hwDec = picture.cvBufferRef;
+ CVTBData *vtbdata = (CVTBData*)buf.hwDec;
+ if (vtbdata->m_vtbbuf)
+ {
+ CVBufferRelease(vtbdata->m_vtbbuf);
+ }
+ vtbdata->m_vtbbuf = picture.cvBufferRef;
+
// retain another reference, this way VideoPlayer and renderer can issue releases.
CVBufferRetain(picture.cvBufferRef);
}
@@ -55,20 +76,25 @@ void CRendererVTB::ReleaseBuffer(int idx)
{
YUVBUFFER &buf = m_buffers[idx];
if (buf.hwDec)
- CVBufferRelease((struct __CVBuffer *)buf.hwDec);
- buf.hwDec = NULL;
-}
-
-
-bool CRendererVTB::Supports(EINTERLACEMETHOD method)
-{
- return false;
+ {
+ CVTBData *vtbdata = (CVTBData*)buf.hwDec;
+ if (vtbdata->m_vtbbuf)
+ {
+ CVBufferRelease(vtbdata->m_vtbbuf);
+ vtbdata->m_vtbbuf = nullptr;
+ }
+
+ if (vtbdata->m_fence && glIsFenceAPPLE(vtbdata->m_fence))
+ {
+ glDeleteFencesAPPLE(1, &vtbdata->m_fence);
+ vtbdata->m_fence = 0;
+ }
+ }
}
bool CRendererVTB::LoadShadersHook()
{
CLog::Log(LOGNOTICE, "GL: Using CVBREF render method");
- m_renderMethod = RENDER_CVREF;
m_textureTarget = GL_TEXTURE_RECTANGLE_ARB;
return false;
}
@@ -110,6 +136,11 @@ bool CRendererVTB::CreateTexture(int index)
planes[2].id = planes[1].id;
glDisable(m_textureTarget);
+ CVTBData *data = new CVTBData();
+ data->m_fence = 0;
+ data->m_vtbbuf = nullptr;
+ m_buffers[index].hwDec = data;
+
return true;
}
@@ -117,9 +148,9 @@ void CRendererVTB::DeleteTexture(int index)
{
YUVPLANES &planes = m_buffers[index].fields[0];
- if (m_buffers[index].hwDec)
- CVBufferRelease((struct __CVBuffer *)m_buffers[index].hwDec);
- m_buffers[index].hwDec = NULL;
+ ReleaseBuffer(index);
+ delete (CVTBData*)m_buffers[index].hwDec;
+ m_buffers[index].hwDec = nullptr;
if (planes[0].id && glIsTexture(planes[0].id))
{
@@ -139,8 +170,9 @@ bool CRendererVTB::UploadTexture(int index)
YUVBUFFER &buf = m_buffers[index];
YUVFIELDS &fields = buf.fields;
YUVPLANES &planes = fields[0];
+ CVTBData *vtbdata = (CVTBData*)m_buffers[index].hwDec;
- CVImageBufferRef cvBufferRef = (struct __CVBuffer *)m_buffers[index].hwDec;
+ CVImageBufferRef cvBufferRef = vtbdata->m_vtbbuf;
glEnable(m_textureTarget);
@@ -192,8 +224,32 @@ bool CRendererVTB::UploadTexture(int index)
CalculateTextureSourceRects(index, 3);
-
return true;
}
+void CRendererVTB::AfterRenderHook(int idx)
+{
+ CVTBData *vtbdata = (CVTBData*)m_buffers[idx].hwDec;
+ if (vtbdata->m_fence && glIsFenceAPPLE(vtbdata->m_fence))
+ {
+ glDeleteFencesAPPLE(1, &vtbdata->m_fence);
+ }
+ glGenFencesAPPLE(1, &vtbdata->m_fence);
+ glSetFenceAPPLE(vtbdata->m_fence);
+}
+
+bool CRendererVTB::NeedBuffer(int idx)
+{
+ CVTBData *vtbdata = (CVTBData*)m_buffers[idx].hwDec;
+ if (!vtbdata)
+ return false;
+
+ if (vtbdata->m_fence && glIsFenceAPPLE(vtbdata->m_fence))
+ {
+ if (glTestFenceAPPLE(vtbdata->m_fence))
+ return false;
+ }
+
+ return true;
+}
#endif
diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererVTBGL.h b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererVTBGL.h
index 713389882d..7294780229 100644
--- a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererVTBGL.h
+++ b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererVTBGL.h
@@ -33,19 +33,19 @@ public:
virtual ~CRendererVTB();
// Player functions
- virtual void AddVideoPictureHW(DVDVideoPicture &picture, int index);
- virtual void ReleaseBuffer(int idx);
-
- // Feature support
- virtual bool Supports(EINTERLACEMETHOD method);
+ virtual void AddVideoPictureHW(DVDVideoPicture &picture, int index) override;
+ virtual void ReleaseBuffer(int idx) override;
+ virtual bool NeedBuffer(int idx) override;
+ virtual CRenderInfo GetRenderInfo() override;
protected:
- virtual bool LoadShadersHook();
+ virtual bool LoadShadersHook() override;
+ virtual void AfterRenderHook(int idx) override;
// textures
- virtual bool UploadTexture(int index);
- virtual void DeleteTexture(int index);
- virtual bool CreateTexture(int index);
+ virtual bool UploadTexture(int index) override;
+ virtual void DeleteTexture(int index) override;
+ virtual bool CreateTexture(int index) override;
};
#endif
diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGL.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGL.cpp
index 71bb4af413..4e785f7688 100644
--- a/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGL.cpp
+++ b/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGL.cpp
@@ -1115,6 +1115,8 @@ void CLinuxRendererGL::Render(DWORD flags, int renderBuffer)
RenderSoftware(renderBuffer, m_currentField);
VerifyGLState();
}
+
+ AfterRenderHook(renderBuffer);
}
void CLinuxRendererGL::RenderSinglePass(int index, int field)
diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGL.h b/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGL.h
index 050c06798f..ce3afe985b 100644
--- a/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGL.h
+++ b/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGL.h
@@ -87,7 +87,6 @@ enum RenderMethod
RENDER_VDPAU=0x08,
RENDER_POT=0x10,
RENDER_VAAPI=0x20,
- RENDER_CVREF = 0x40,
};
enum RenderQuality
@@ -181,6 +180,7 @@ protected:
// hooks for HwDec Renderered
virtual bool LoadShadersHook() { return false; };
virtual bool RenderHook(int idx) { return false; };
+ virtual void AfterRenderHook(int idx) {};
struct
{