[Bf-blender-cvs] [3441314e406] soc-2019-openxr: Remove blitting from default framebuffer

Julian Eisel noreply at git.blender.org
Sat Aug 24 00:13:41 CEST 2019


Commit: 3441314e40606005a84dc4bd510971f206d9c7c6
Author: Julian Eisel
Date:   Fri Aug 23 23:36:04 2019 +0200
Branches: soc-2019-openxr
https://developer.blender.org/rB3441314e40606005a84dc4bd510971f206d9c7c6

Remove blitting from default framebuffer

===================================================================

M	intern/ghost/intern/GHOST_Context.cpp
M	intern/ghost/intern/GHOST_Context.h
M	intern/ghost/intern/GHOST_ContextCGL.mm
M	intern/ghost/intern/GHOST_ContextD3D.cpp
M	intern/ghost/intern/GHOST_ContextD3D.h
M	intern/ghost/intern/GHOST_ContextEGL.cpp
M	intern/ghost/intern/GHOST_ContextGLX.cpp
M	intern/ghost/intern/GHOST_ContextNone.h
M	intern/ghost/intern/GHOST_ContextSDL.cpp
M	intern/ghost/intern/GHOST_ContextWGL.cpp

===================================================================

diff --git a/intern/ghost/intern/GHOST_Context.cpp b/intern/ghost/intern/GHOST_Context.cpp
index 4df47006a56..c0f6b39a1d3 100644
--- a/intern/ghost/intern/GHOST_Context.cpp
+++ b/intern/ghost/intern/GHOST_Context.cpp
@@ -150,67 +150,3 @@ void GHOST_Context::initClearGL()
   glClearColor(0.000, 0.000, 0.000, 0.000);
 }
 
-GHOST_TSuccess GHOST_Context::blitOpenGLOffscreenContext(GHOST_Context *offscreen,
-                                                         GHOST_TInt32 width,
-                                                         GHOST_TInt32 height)
-{
-  GLuint fbo_offscreen;
-  GLuint fbo_onscreen;
-  GLuint render_buf_shared;
-  GLint fbo_prev_draw;
-
-  if ((m_type != GHOST_kDrawingContextTypeOpenGL) ||
-      (offscreen->m_type != GHOST_kDrawingContextTypeOpenGL)) {
-    return GHOST_kFailure;
-  }
-
-  offscreen->setDefaultFramebufferSize(width, height);
-
-  /* Logic here:
-   * We can't simply blit from one context's framebuffer into the other. Unlike Framebuffers/FBOs,
-   * Renderbuffers can be shared though. So create one, and blit the offscreen context framebuffer
-   * contents into it. To share it, an FBO has to be created for each context though, as the
-   * default framebuffer doesn't allow any attachments. */
-
-  offscreen->activateDrawingContext();
-
-  glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &fbo_prev_draw);
-
-  /* Create shared renderbuffer */
-  glGenRenderbuffers(1, &render_buf_shared);
-  glBindRenderbuffer(GL_RENDERBUFFER, render_buf_shared);
-  glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, width, height);
-
-  /* Create offscreen FBO and assign renderbuffer */
-  glGenFramebuffers(1, &fbo_offscreen);
-  glBindFramebuffer(GL_FRAMEBUFFER, fbo_offscreen);
-  glFramebufferRenderbuffer(
-      GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, render_buf_shared);
-
-  /* Blit offscreen framebuffer into renderbuffer */
-  glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo_prev_draw);
-  glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo_offscreen);
-  glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, GL_COLOR_BUFFER_BIT, GL_LINEAR);
-
-  glDeleteFramebuffers(1, &fbo_offscreen); /* Can delete already. Do before context change. */
-
-  activateDrawingContext();
-
-  /* Create onscreen FBO and assign renderbuffer */
-  glGenFramebuffers(1, &fbo_onscreen);
-  glBindFramebuffer(GL_FRAMEBUFFER, fbo_onscreen);
-  glFramebufferRenderbuffer(
-      GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, render_buf_shared);
-
-  glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo_onscreen);
-  glBindFramebuffer(GL_DRAW_FRAMEBUFFER, getDefaultFramebuffer());
-  /* Finally, blit to onscreen buffer. */
-  glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, GL_COLOR_BUFFER_BIT, GL_LINEAR);
-
-  glDeleteFramebuffers(1, &fbo_onscreen);
-  glDeleteRenderbuffers(1, &render_buf_shared);
-
-  glBindFramebuffer(GL_FRAMEBUFFER, 0);
-
-  return GHOST_kSuccess;
-}
diff --git a/intern/ghost/intern/GHOST_Context.h b/intern/ghost/intern/GHOST_Context.h
index a257f383518..c780d4503eb 100644
--- a/intern/ghost/intern/GHOST_Context.h
+++ b/intern/ghost/intern/GHOST_Context.h
@@ -38,8 +38,8 @@ class GHOST_Context : public GHOST_IContext {
    * Constructor.
    * \param stereoVisual      Stereo visual for quad buffered stereo.
    */
-  GHOST_Context(GHOST_TDrawingContextType type, bool stereoVisual)
-      : m_type(type), m_stereoVisual(stereoVisual)
+  GHOST_Context(bool stereoVisual)
+      : m_stereoVisual(stereoVisual)
   {
   }
 
@@ -149,14 +149,9 @@ class GHOST_Context : public GHOST_IContext {
     return GHOST_kFailure;
   }
 
-  virtual GHOST_TSuccess blitOpenGLOffscreenContext(GHOST_Context *offscreen,
-                                                    GHOST_TInt32 width,
-                                                    GHOST_TInt32 height);
-
  protected:
   void initContextGLEW();
 
-  GHOST_TDrawingContextType m_type;
   bool m_stereoVisual;
 
   static void initClearGL();
diff --git a/intern/ghost/intern/GHOST_ContextCGL.mm b/intern/ghost/intern/GHOST_ContextCGL.mm
index 5448c85e1f5..12c340ffe97 100644
--- a/intern/ghost/intern/GHOST_ContextCGL.mm
+++ b/intern/ghost/intern/GHOST_ContextCGL.mm
@@ -55,7 +55,7 @@ GHOST_ContextCGL::GHOST_ContextCGL(bool stereoVisual,
                                    NSView *metalView,
                                    CAMetalLayer *metalLayer,
                                    NSOpenGLView *openGLView)
-    : GHOST_Context(GHOST_kDrawingContextTypeOpenGL, stereoVisual),
+    : GHOST_Context(stereoVisual),
       m_metalView(metalView),
       m_metalLayer(metalLayer),
       m_metalCmdQueue(nil),
diff --git a/intern/ghost/intern/GHOST_ContextD3D.cpp b/intern/ghost/intern/GHOST_ContextD3D.cpp
index a0668b2d985..59a3d1de75a 100644
--- a/intern/ghost/intern/GHOST_ContextD3D.cpp
+++ b/intern/ghost/intern/GHOST_ContextD3D.cpp
@@ -40,7 +40,7 @@ static void drawTestTriangle(ID3D11Device *m_device,
 #endif
 
 GHOST_ContextD3D::GHOST_ContextD3D(bool stereoVisual, HWND hWnd)
-    : GHOST_Context(GHOST_kDrawingContextTypeD3D, stereoVisual), m_hWnd(hWnd)
+    : GHOST_Context(stereoVisual), m_hWnd(hWnd)
 {
 }
 
@@ -151,21 +151,6 @@ GHOST_TSuccess GHOST_ContextD3D::releaseNativeHandles()
   return GHOST_kFailure;
 }
 
-GHOST_TSuccess GHOST_ContextD3D::blitOpenGLOffscreenContext(GHOST_Context * /*offscreen_ctx*/,
-                                                            GHOST_TInt32 width,
-                                                            GHOST_TInt32 height)
-{
-  GHOST_SharedOpenGLResource *shared_res = createSharedOpenGLResource(width, height);
-
-  if (shared_res) {
-    GHOST_TSuccess ret = blitFromOpenGLContext(shared_res, width, height);
-    disposeSharedOpenGLResource(shared_res);
-    return ret;
-  }
-
-  return GHOST_kFailure;
-}
-
 class GHOST_SharedOpenGLResource {
   struct SharedData {
     HANDLE device;
diff --git a/intern/ghost/intern/GHOST_ContextD3D.h b/intern/ghost/intern/GHOST_ContextD3D.h
index 40264bffb56..1a5cdbd77e1 100644
--- a/intern/ghost/intern/GHOST_ContextD3D.h
+++ b/intern/ghost/intern/GHOST_ContextD3D.h
@@ -108,10 +108,6 @@ class GHOST_ContextD3D : public GHOST_Context {
     return 0;
   }
 
-  GHOST_TSuccess blitOpenGLOffscreenContext(GHOST_Context *offscreen_ctx,
-                                            GHOST_TInt32 width,
-                                            GHOST_TInt32 height);
-
   class GHOST_SharedOpenGLResource *createSharedOpenGLResource(
       unsigned int width, unsigned int height, ID3D11RenderTargetView *render_target);
   class GHOST_SharedOpenGLResource *createSharedOpenGLResource(unsigned int width,
diff --git a/intern/ghost/intern/GHOST_ContextEGL.cpp b/intern/ghost/intern/GHOST_ContextEGL.cpp
index a7c94448fe6..d4eeda2a9ef 100644
--- a/intern/ghost/intern/GHOST_ContextEGL.cpp
+++ b/intern/ghost/intern/GHOST_ContextEGL.cpp
@@ -208,7 +208,7 @@ GHOST_ContextEGL::GHOST_ContextEGL(bool stereoVisual,
                                    EGLint contextFlags,
                                    EGLint contextResetNotificationStrategy,
                                    EGLenum api)
-    : GHOST_Context(GHOST_kDrawingContextTypeOpenGL, stereoVisual),
+    : GHOST_Context(stereoVisual),
       m_nativeDisplay(nativeDisplay),
       m_nativeWindow(nativeWindow),
       m_contextProfileMask(contextProfileMask),
diff --git a/intern/ghost/intern/GHOST_ContextGLX.cpp b/intern/ghost/intern/GHOST_ContextGLX.cpp
index 8bde9f69b02..ecf824aafb7 100644
--- a/intern/ghost/intern/GHOST_ContextGLX.cpp
+++ b/intern/ghost/intern/GHOST_ContextGLX.cpp
@@ -52,7 +52,7 @@ GHOST_ContextGLX::GHOST_ContextGLX(bool stereoVisual,
                                    int contextMinorVersion,
                                    int contextFlags,
                                    int contextResetNotificationStrategy)
-    : GHOST_Context(GHOST_kDrawingContextTypeOpenGL, stereoVisual),
+    : GHOST_Context(stereoVisual),
       m_display(display),
       m_fbconfig(fbconfig),
       m_window(window),
diff --git a/intern/ghost/intern/GHOST_ContextNone.h b/intern/ghost/intern/GHOST_ContextNone.h
index b68f1dc9076..42820f0e243 100644
--- a/intern/ghost/intern/GHOST_ContextNone.h
+++ b/intern/ghost/intern/GHOST_ContextNone.h
@@ -31,7 +31,7 @@
 class GHOST_ContextNone : public GHOST_Context {
  public:
   GHOST_ContextNone(bool stereoVisual)
-      : GHOST_Context(GHOST_kDrawingContextTypeNone, stereoVisual), m_swapInterval(1)
+      : GHOST_Context(stereoVisual), m_swapInterval(1)
   {
   }
 
diff --git a/intern/ghost/intern/GHOST_ContextSDL.cpp b/intern/ghost/intern/GHOST_ContextSDL.cpp
index 3b26343ca92..bf0737e5efa 100644
--- a/intern/ghost/intern/GHOST_ContextSDL.cpp
+++ b/intern/ghost/intern/GHOST_ContextSDL.cpp
@@ -41,7 +41,7 @@ GHOST_ContextSDL::GHOST_ContextSDL(bool stereoVisual,
                                    int contextMinorVersion,
                                    int contextFlags,
                                    int contextResetNotificationStrategy)
-    : GHOST_Context(GHOST_kDrawingContextTypeOpenGL, stereoVisual),
+    : GHOST_Context(stereoVisual),
       m_window(window),
       m_hidden_window(NULL),
       m_contextProfileMask(contextProfileMask),
diff --git a/intern/ghost/intern/GHOST_ContextWGL.cpp b/intern/ghost/intern/GHOST_ContextWGL.cpp
index c88b6d71609..1991dff6fa1 100644
--- a/intern/ghost/intern/GHOST_ContextWGL.cpp
+++ b/intern/ghost/intern/GHOST_ContextWGL.cpp
@@ -52,7 +52,7 @@ GHOST_ContextWGL::GHOST_ContextWGL(bool stereoVisual,
                                    int contextMinorVersion,
                                    int contextFlags,
                                    int contextResetNotificationStrategy)
-    : GHOST_Context(GHOST_kDrawingContextTypeOpenGL, stereoVisual),
+    : GHOST_Context(stereoVisual),
       m_hWnd(hWnd),
       m_hDC(hDC),
       m_contextProfileMask(contextProfileMask),



More information about the Bf-blender-cvs mailing list