[Bf-blender-cvs] [eda7e84aac6] master: GHOST: remove OpenGL depth buffer, remove code for other unused buffers

mano-wii noreply at git.blender.org
Thu Apr 25 14:34:25 CEST 2019


Commit: eda7e84aac661f19478b2e5fe94d8899c9782cc8
Author: mano-wii
Date:   Thu Apr 25 14:09:01 2019 +0200
Branches: master
https://developer.blender.org/rBeda7e84aac661f19478b2e5fe94d8899c9782cc8

GHOST: remove OpenGL depth buffer, remove code for other unused buffers

Viewport drawing has moved to offscreen buffers, and we no longer need to have
depth, stencil, aa samples, sRGB buffers as part of the window. So all that
code is removed now. The depth buffer was the only one still being allocated,
its removal save a bit of memory.

Code by Germano and Brecht.

Differential Revision: https://developer.blender.org/D4708

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

M	intern/ghost/GHOST_C-api.h
M	intern/ghost/GHOST_ISystem.h
M	intern/ghost/GHOST_IWindow.h
M	intern/ghost/GHOST_Types.h
M	intern/ghost/intern/GHOST_C-api.cpp
M	intern/ghost/intern/GHOST_Context.h
M	intern/ghost/intern/GHOST_ContextCGL.h
M	intern/ghost/intern/GHOST_ContextCGL.mm
M	intern/ghost/intern/GHOST_ContextEGL.cpp
M	intern/ghost/intern/GHOST_ContextEGL.h
M	intern/ghost/intern/GHOST_ContextGLX.cpp
M	intern/ghost/intern/GHOST_ContextGLX.h
M	intern/ghost/intern/GHOST_ContextNone.h
M	intern/ghost/intern/GHOST_ContextSDL.cpp
M	intern/ghost/intern/GHOST_ContextSDL.h
M	intern/ghost/intern/GHOST_ContextWGL.cpp
M	intern/ghost/intern/GHOST_ContextWGL.h
M	intern/ghost/intern/GHOST_System.cpp
M	intern/ghost/intern/GHOST_System.h
M	intern/ghost/intern/GHOST_SystemCocoa.mm
M	intern/ghost/intern/GHOST_SystemSDL.cpp
M	intern/ghost/intern/GHOST_SystemWin32.cpp
M	intern/ghost/intern/GHOST_SystemX11.cpp
M	intern/ghost/intern/GHOST_Window.cpp
M	intern/ghost/intern/GHOST_Window.h
M	intern/ghost/intern/GHOST_WindowCocoa.h
M	intern/ghost/intern/GHOST_WindowCocoa.mm
M	intern/ghost/intern/GHOST_WindowNULL.h
M	intern/ghost/intern/GHOST_WindowSDL.cpp
M	intern/ghost/intern/GHOST_WindowSDL.h
M	intern/ghost/intern/GHOST_WindowWin32.cpp
M	intern/ghost/intern/GHOST_WindowWin32.h
M	intern/ghost/intern/GHOST_WindowX11.cpp
M	intern/ghost/intern/GHOST_WindowX11.h

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

diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h
index 8bb6a670754..ec8115c914f 100644
--- a/intern/ghost/GHOST_C-api.h
+++ b/intern/ghost/GHOST_C-api.h
@@ -690,12 +690,6 @@ extern GHOST_TSuccess GHOST_SetSwapInterval(GHOST_WindowHandle windowhandle, int
  */
 extern GHOST_TSuccess GHOST_GetSwapInterval(GHOST_WindowHandle windowhandle, int *intervalOut);
 
-/**
- * Gets the current swap interval for swapBuffers.
- * \return Number of AA Samples (0 if there is no multisample buffer)
- */
-extern GHOST_TUns16 GHOST_GetNumOfAASamples(GHOST_WindowHandle windowhandle);
-
 /**
  * Activates the drawing context of this window.
  * \param windowhandle The handle to the window
diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h
index 66e37a525c0..0b7b3a18309 100644
--- a/intern/ghost/GHOST_ISystem.h
+++ b/intern/ghost/GHOST_ISystem.h
@@ -287,8 +287,7 @@ class GHOST_ISystem {
   virtual GHOST_TSuccess beginFullScreen(const GHOST_DisplaySetting &setting,
                                          GHOST_IWindow **window,
                                          const bool stereoVisual,
-                                         const bool alphaBackground = 0,
-                                         const GHOST_TUns16 numOfAASamples = 0) = 0;
+                                         const bool alphaBackground = 0) = 0;
 
   /**
    * Updates the resolution while in fullscreen mode.
diff --git a/intern/ghost/GHOST_IWindow.h b/intern/ghost/GHOST_IWindow.h
index 0b1b83c36a7..2c5f6e811d3 100644
--- a/intern/ghost/GHOST_IWindow.h
+++ b/intern/ghost/GHOST_IWindow.h
@@ -210,12 +210,6 @@ class GHOST_IWindow {
    */
   virtual GHOST_TSuccess getSwapInterval(int &intervalOut) = 0;
 
-  /**
-   * Gets the current swap interval for swapBuffers.
-   * \return Number of AA Samples (0 if there is no multisample buffer)
-   */
-  virtual GHOST_TUns16 getNumOfAASamples() = 0;
-
   /**
    * Activates the drawing context of this window.
    * \return  A boolean success indicator.
diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h
index 36678bcc913..69513ec514c 100644
--- a/intern/ghost/GHOST_Types.h
+++ b/intern/ghost/GHOST_Types.h
@@ -49,7 +49,6 @@ typedef int GHOST_TInt32;
 typedef unsigned int GHOST_TUns32;
 
 typedef struct {
-  GHOST_TUns16 numOfAASamples;
   int flags;
 } GHOST_GLSettings;
 
diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp
index 8d9570a39f3..3848c723e5b 100644
--- a/intern/ghost/intern/GHOST_C-api.cpp
+++ b/intern/ghost/intern/GHOST_C-api.cpp
@@ -611,13 +611,6 @@ GHOST_TSuccess GHOST_GetSwapInterval(GHOST_WindowHandle windowhandle, int *inter
   return window->getSwapInterval(*intervalOut);
 }
 
-GHOST_TUns16 GHOST_GetNumOfAASamples(GHOST_WindowHandle windowhandle)
-{
-  GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
-
-  return window->getNumOfAASamples();
-}
-
 GHOST_TSuccess GHOST_ActivateWindowDrawingContext(GHOST_WindowHandle windowhandle)
 {
   GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
diff --git a/intern/ghost/intern/GHOST_Context.h b/intern/ghost/intern/GHOST_Context.h
index ed7b63aa436..7937fd1f7c7 100644
--- a/intern/ghost/intern/GHOST_Context.h
+++ b/intern/ghost/intern/GHOST_Context.h
@@ -37,10 +37,8 @@ class GHOST_Context : public GHOST_IContext {
   /**
    * Constructor.
    * \param stereoVisual      Stereo visual for quad buffered stereo.
-   * \param numOfAASamples    Number of samples used for AA (zero if no AA)
    */
-  GHOST_Context(bool stereoVisual, GHOST_TUns16 numOfAASamples)
-      : m_stereoVisual(stereoVisual), m_numOfAASamples(numOfAASamples)
+  GHOST_Context(bool stereoVisual) : m_stereoVisual(stereoVisual)
   {
   }
 
@@ -121,19 +119,11 @@ class GHOST_Context : public GHOST_IContext {
     return m_stereoVisual;
   }
 
-  /** Number of samples used in anti-aliasing, set to 0 if no AA */
-  inline GHOST_TUns16 getNumOfAASamples() const
-  {
-    return m_numOfAASamples;
-  }
-
  protected:
   void initContextGLEW();
 
   bool m_stereoVisual;
 
-  GHOST_TUns16 m_numOfAASamples;
-
   static void initClearGL();
 
 #ifdef WITH_CXX_GUARDEDALLOC
diff --git a/intern/ghost/intern/GHOST_ContextCGL.h b/intern/ghost/intern/GHOST_ContextCGL.h
index 648af1cc9c7..fd760837d45 100644
--- a/intern/ghost/intern/GHOST_ContextCGL.h
+++ b/intern/ghost/intern/GHOST_ContextCGL.h
@@ -44,7 +44,6 @@ class GHOST_ContextCGL : public GHOST_Context {
    * Constructor.
    */
   GHOST_ContextCGL(bool stereoVisual,
-                   GHOST_TUns16 numOfAASamples,
                    NSWindow *window,
                    NSOpenGLView *openGLView,
                    int contextProfileMask,
diff --git a/intern/ghost/intern/GHOST_ContextCGL.mm b/intern/ghost/intern/GHOST_ContextCGL.mm
index 9b4e1864adf..4a493cc416d 100644
--- a/intern/ghost/intern/GHOST_ContextCGL.mm
+++ b/intern/ghost/intern/GHOST_ContextCGL.mm
@@ -40,7 +40,6 @@ NSOpenGLContext *GHOST_ContextCGL::s_sharedOpenGLContext = nil;
 int GHOST_ContextCGL::s_sharedCount = 0;
 
 GHOST_ContextCGL::GHOST_ContextCGL(bool stereoVisual,
-                                   GHOST_TUns16 numOfAASamples,
                                    NSWindow *window,
                                    NSOpenGLView *openGLView,
                                    int contextProfileMask,
@@ -48,7 +47,7 @@ GHOST_ContextCGL::GHOST_ContextCGL(bool stereoVisual,
                                    int contextMinorVersion,
                                    int contextFlags,
                                    int contextResetNotificationStrategy)
-    : GHOST_Context(stereoVisual, numOfAASamples),
+    : GHOST_Context(stereoVisual),
       m_openGLView(openGLView),
       m_openGLContext(nil),
       m_debug(contextFlags)
@@ -183,9 +182,7 @@ GHOST_TSuccess GHOST_ContextCGL::updateDrawingContext()
 static void makeAttribList(std::vector<NSOpenGLPixelFormatAttribute> &attribs,
                            bool coreProfile,
                            bool stereoVisual,
-                           int numOfAASamples,
                            bool needAlpha,
-                           bool needStencil,
                            bool softwareGL)
 {
   attribs.clear();
@@ -207,9 +204,6 @@ static void makeAttribList(std::vector<NSOpenGLPixelFormatAttribute> &attribs,
 
   attribs.push_back(NSOpenGLPFAAllowOfflineRenderers);  // for automatic GPU switching
 
-  attribs.push_back(NSOpenGLPFADepthSize);
-  attribs.push_back((NSOpenGLPixelFormatAttribute)32);
-
   if (stereoVisual)
     attribs.push_back(NSOpenGLPFAStereo);
 
@@ -218,22 +212,6 @@ static void makeAttribList(std::vector<NSOpenGLPixelFormatAttribute> &attribs,
     attribs.push_back((NSOpenGLPixelFormatAttribute)8);
   }
 
-  if (needStencil) {
-    attribs.push_back(NSOpenGLPFAStencilSize);
-    attribs.push_back((NSOpenGLPixelFormatAttribute)8);
-  }
-
-  if (numOfAASamples > 0) {
-    // Multisample anti-aliasing
-    attribs.push_back(NSOpenGLPFAMultisample);
-
-    attribs.push_back(NSOpenGLPFASampleBuffers);
-    attribs.push_back((NSOpenGLPixelFormatAttribute)1);
-
-    attribs.push_back(NSOpenGLPFASamples);
-    attribs.push_back((NSOpenGLPixelFormatAttribute)numOfAASamples);
-  }
-
   attribs.push_back((NSOpenGLPixelFormatAttribute)0);
 }
 
@@ -263,57 +241,18 @@ GHOST_TSuccess GHOST_ContextCGL::initializeDrawingContext()
   static const bool needAlpha = false;
 #endif
 
-#ifdef GHOST_OPENGL_STENCIL
-  static const bool needStencil = true;
-#else
-  static const bool needStencil = false;
-#endif
-
   static bool softwareGL = getenv("BLENDER_SOFTWAREGL");  // command-line argument would be better
   GLint major = 0, minor = 0;
   NSOpenGLPixelFormat *pixelFormat;
   // TODO: keep pixel format for subsequent windows/contexts instead of recreating each time
 
-  makeAttribList(attribs,
-                 m_coreProfile,
-                 m_stereoVisual,
-                 m_numOfAASamples,
-                 needAlpha,
-                 needStencil,
-                 softwareGL);
+  makeAttribList(attribs, m_coreProfile, m_stereoVisual, needAlpha, softwareGL);
 
   pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:&attribs[0]];
 
-  // Fall back to no multisampling if Antialiasing init failed
-  if (m_numOfAASamples > 0 && pixelFormat == nil) {
-    // XXX jwilkins: Does CGL only succeed when it makes an exact match on the number of samples?
-    // Does this need to explicitly try for a lesser match before giving up?
-    // (Now that I think about it, does WGL really require the code that it has for finding a lesser match?)
-
-    attribs.clear();
-    makeAttribList(attribs, m_coreProfile, m_stereoVisual, 0, needAlpha, needStencil, softwareGL);
-    pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:&attribs[0]];
-  }
-
   if (pixelFormat == nil)
     goto error;
 
-  if (m_numOfAASamples > 0) {  //Set m_numOfAASamples to the actual value
-    GLint actualSamples;
-    [pixelFormat getValues:&actualSamples forAttribute:NSOpenGLPFASamples forVirtualScreen:0];
-
-    if (m_numOfAASamples != (GHOST_TUns16)actualSamples) {
-      fprintf(
-          stderr,
-          "Warning! Unable to find a multisample pixel format that supports exactly %d samples. "
-          "Substituting one that uses %d samples.\n",
-          m_numOfAASamples,
-          actualSamples);
-
-      m_numOfAASamples = (GHOST_TUns16)actualSamples;
-    }
-  }
-
   m_openGLContext = [[NSOpenGLContext alloc] initWithFormat:pixelFormat
                                                shareContext:s_sharedOpenGLContext];
   [pixelFormat release];
@@ -336,13 +275,7 @@ GHOST_TSuccess GHOST_ContextCGL::initializeDrawingContext()
     [m_openGLContext release];
 
     // create software GL context
-    makeAttribList(attribs,
-                   m_coreProfile,
-                   m_stereoVisual,
-                   m_numOfAASamples,
-                   needAlpha,
-                   needStencil,
-                   softwareGL);
+    makeAttribList(attribs, m_coreProfile, m_stereoVisual, needAlpha, softwareGL);
     pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:&attribs[0]];
     m_openGLContext = [[NSOpenGLContext alloc] initWithFormat:pixelF

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list