]> git.sesse.net Git - mlt/commitdiff
Prevent sharing FBOs between contexts.
authorDan Dennedy <dan@dennedy.org>
Wed, 1 Jan 2014 07:35:16 +0000 (23:35 -0800)
committerDan Dennedy <dan@dennedy.org>
Wed, 1 Jan 2014 07:35:16 +0000 (23:35 -0800)
Based on patch by Steinar Gunderson.

src/modules/opengl/filter_glsl_manager.cpp
src/modules/opengl/glsl_manager.h

index 468e3b0422ef409facf577eadf5357a0f4e000c7..28bd13fb675320addb458ad7dddce4c5019a46b9 100644 (file)
@@ -33,6 +33,14 @@ extern "C" {
 #include <framework/mlt_factory.h>
 }
 
+#if defined(__DARWIN__)
+#include <OpenGL/OpenGL.h>
+#elif defined(WIN32)
+#include <wingdi.h>
+#else
+#include <GL/glx.h>
+#endif
+
 void deleteManager(GlslManager *p)
 {
        delete p;
@@ -73,10 +81,18 @@ GlslManager* GlslManager::get_instance()
 
 glsl_fbo GlslManager::get_fbo(int width, int height)
 {
+#if defined(__DARWIN__)
+       CGLContextObj context = CGLGetCurrentContext();
+#elif defined(WIN32)
+       HGLRC context = wglGetCurrentContext();
+#else
+       GLXContext context = glXGetCurrentContext();
+#endif
+
        lock();
        for (int i = 0; i < fbo_list.count(); ++i) {
                glsl_fbo fbo = (glsl_fbo) fbo_list.peek(i);
-               if (!fbo->used && (fbo->width == width) && (fbo->height == height)) {
+               if (!fbo->used && (fbo->width == width) && (fbo->height == height) && (fbo->context == context)) {
                        fbo->used = 1;
                        unlock();
                        return fbo;
@@ -98,6 +114,7 @@ glsl_fbo GlslManager::get_fbo(int width, int height)
        fbo->width = width;
        fbo->height = height;
        fbo->used = 1;
+       fbo->context = context;
        lock();
        fbo_list.push_back(fbo);
        unlock();
index fe968dc8370f6fae528e549a8ac65e606ff2499d..554459158e3aeac75307ae1998d751b5b9b1fb87 100644 (file)
@@ -53,6 +53,7 @@ struct glsl_fbo_s
        int width;
        int height;
        GLuint fbo;
+       void* context;
 };
 typedef struct glsl_fbo_s *glsl_fbo;