[Bf-blender-cvs] [2c77f2deac7] soc-2019-openxr: Remove GHOST API functions for OpenGL offscreen blitting

Julian Eisel noreply at git.blender.org
Wed Aug 21 20:38:47 CEST 2019


Commit: 2c77f2deac7b3a3728be394e53f699c6fd03aa88
Author: Julian Eisel
Date:   Wed Aug 21 20:36:40 2019 +0200
Branches: soc-2019-openxr
https://developer.blender.org/rB2c77f2deac7b3a3728be394e53f699c6fd03aa88

Remove GHOST API functions for OpenGL offscreen blitting

These were previously used to blit from a offscreen (non-OpenGL)
context, into an onscreen one. We do this differently, and only within
GHOST_XrGraphicsBinding now, so this can be removed.

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

M	intern/ghost/GHOST_C-api.h
M	intern/ghost/GHOST_IContext.h
M	intern/ghost/GHOST_IWindow.h
M	intern/ghost/intern/GHOST_C-api.cpp
M	intern/ghost/intern/GHOST_Context.h
M	intern/ghost/intern/GHOST_ContextD3D.cpp
M	intern/ghost/intern/GHOST_ContextD3D.h
M	intern/ghost/intern/GHOST_Window.cpp
M	intern/ghost/intern/GHOST_Window.h
M	intern/ghost/intern/GHOST_XrGraphicsBinding.cpp

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

diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h
index 84bad87e654..03cf3a1c7a0 100644
--- a/intern/ghost/GHOST_C-api.h
+++ b/intern/ghost/GHOST_C-api.h
@@ -197,15 +197,6 @@ GHOST_TSuccess GHOST_DisposeDirectXContext(GHOST_SystemHandle systemhandle,
                                            GHOST_ContextHandle contexthandle);
 #endif
 
-GHOST_TSuccess GHOST_BlitOpenGLOffscreenContext(GHOST_WindowHandle windowhandle,
-                                                GHOST_ContextHandle offscreen_contexthandle);
-
-extern GHOST_TSuccess GHOST_ContextBlitOpenGLOffscreenContext(
-    GHOST_ContextHandle onscreen_contexthandle,
-    GHOST_ContextHandle offscreen_contexthandle,
-    GHOST_TInt32 width,
-    GHOST_TInt32 height);
-
 extern GHOST_ContextHandle GHOST_GetWindowContext(GHOST_WindowHandle windowhandle);
 
 /**
diff --git a/intern/ghost/GHOST_IContext.h b/intern/ghost/GHOST_IContext.h
index 3bad8db115f..d114df428b0 100644
--- a/intern/ghost/GHOST_IContext.h
+++ b/intern/ghost/GHOST_IContext.h
@@ -56,10 +56,6 @@ class GHOST_IContext {
    */
   virtual GHOST_TSuccess releaseDrawingContext() = 0;
 
-  virtual GHOST_TSuccess blitOpenGLOffscreenContext(class GHOST_Context *offscreen,
-                                                    GHOST_TInt32 width,
-                                                    GHOST_TInt32 height) = 0;
-
   virtual unsigned int getDefaultFramebuffer() = 0;
 
   virtual GHOST_TSuccess swapBuffers() = 0;
diff --git a/intern/ghost/GHOST_IWindow.h b/intern/ghost/GHOST_IWindow.h
index 212e7ff8d13..547ae1d3ec3 100644
--- a/intern/ghost/GHOST_IWindow.h
+++ b/intern/ghost/GHOST_IWindow.h
@@ -79,8 +79,6 @@ class GHOST_IWindow {
 
   virtual class GHOST_IContext *getDrawingContext() = 0;
 
-  virtual GHOST_TSuccess blitOpenGLOffscreenContext(GHOST_IContext *offscreen) = 0;
-
   /**
    * Sets the title displayed in the title bar.
    * \param title The title to display in the title bar.
diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp
index 778daf83d32..898378460c6 100644
--- a/intern/ghost/intern/GHOST_C-api.cpp
+++ b/intern/ghost/intern/GHOST_C-api.cpp
@@ -150,25 +150,6 @@ GHOST_TSuccess GHOST_DisposeDirectXContext(GHOST_SystemHandle systemhandle,
 
 #endif
 
-GHOST_TSuccess GHOST_BlitOpenGLOffscreenContext(GHOST_WindowHandle windowhandle,
-                                                GHOST_ContextHandle offscreen_contexthandle)
-{
-  GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
-
-  return window->blitOpenGLOffscreenContext((GHOST_IContext *)offscreen_contexthandle);
-}
-
-GHOST_TSuccess GHOST_ContextBlitOpenGLOffscreenContext(GHOST_ContextHandle onscreen_contexthandle,
-                                                       GHOST_ContextHandle offscreen_contexthandle,
-                                                       GHOST_TInt32 width,
-                                                       GHOST_TInt32 height)
-{
-  GHOST_IContext *context = (GHOST_IContext *)onscreen_contexthandle;
-
-  return context->blitOpenGLOffscreenContext(
-      (class GHOST_Context *)offscreen_contexthandle, width, height);
-}
-
 GHOST_ContextHandle GHOST_GetWindowContext(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 0bc2aa21119..af801112bda 100644
--- a/intern/ghost/intern/GHOST_Context.h
+++ b/intern/ghost/intern/GHOST_Context.h
@@ -146,9 +146,9 @@ class GHOST_Context : public GHOST_IContext {
     return GHOST_kFailure;
   }
 
-  GHOST_TSuccess blitOpenGLOffscreenContext(GHOST_Context *offscreen,
-                                            GHOST_TInt32 width,
-                                            GHOST_TInt32 height);
+  virtual GHOST_TSuccess blitOpenGLOffscreenContext(GHOST_Context *offscreen,
+                                                    GHOST_TInt32 width,
+                                                    GHOST_TInt32 height);
 
  protected:
   void initContextGLEW();
diff --git a/intern/ghost/intern/GHOST_ContextD3D.cpp b/intern/ghost/intern/GHOST_ContextD3D.cpp
index f5fc36a4831..e9253216d9a 100644
--- a/intern/ghost/intern/GHOST_ContextD3D.cpp
+++ b/intern/ghost/intern/GHOST_ContextD3D.cpp
@@ -210,29 +210,19 @@ GHOST_TSuccess GHOST_ContextD3D::releaseNativeHandles()
   return GHOST_kFailure;
 }
 
-GHOST_TSuccess GHOST_ContextD3D::blitOpenGLOffscreenContext(GHOST_Context *offscreen_ctx,
-                                                            ID3D11RenderTargetView *render_target,
-                                                            GHOST_TInt32 width,
-                                                            GHOST_TInt32 height)
-{
-  GHOST_SharedOpenGLResource *shared_res = createSharedOpenGLResource(
-      width, height, render_target);
-
-  if (shared_res) {
-    GHOST_TSuccess ret = blitFromOpenGLContext(shared_res, width, height);
-    disposeSharedOpenGLResource(shared_res);
-    return ret;
-  }
-
-  return GHOST_kFailure;
-}
-
-GHOST_TSuccess GHOST_ContextD3D::blitOpenGLOffscreenContext(GHOST_Context *offscreen_ctx,
+GHOST_TSuccess GHOST_ContextD3D::blitOpenGLOffscreenContext(GHOST_Context * /*offscreen_ctx*/,
                                                             GHOST_TInt32 width,
                                                             GHOST_TInt32 height)
 {
   if (updateSwapchain(width, height) == GHOST_kSuccess) {
-    return blitOpenGLOffscreenContext(offscreen_ctx, m_backbuffer_view, width, height);
+    GHOST_SharedOpenGLResource *shared_res = createSharedOpenGLResource(
+        width, height, m_backbuffer_view);
+
+    if (shared_res) {
+      GHOST_TSuccess ret = blitFromOpenGLContext(shared_res, width, height);
+      disposeSharedOpenGLResource(shared_res);
+      return ret;
+    }
   }
 
   return GHOST_kFailure;
@@ -274,11 +264,12 @@ class GHOST_SharedOpenGLResource {
       renderTargetViewDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
       renderTargetViewDesc.Texture2D.MipSlice = 0;
 
-      device->CreateRenderTargetView(tex, &renderTargetViewDesc, &m_render_target);
+      device->CreateRenderTargetView(tex, &renderTargetViewDesc, &render_target);
 
       tex->Release();
     }
 
+    m_render_target = render_target;
     m_render_target->GetResource(&backbuffer_res);
     backbuffer_res->QueryInterface<ID3D11Texture2D>(&m_render_target_tex);
     backbuffer_res->Release();
diff --git a/intern/ghost/intern/GHOST_ContextD3D.h b/intern/ghost/intern/GHOST_ContextD3D.h
index ed3e0331f17..d282d3978ed 100644
--- a/intern/ghost/intern/GHOST_ContextD3D.h
+++ b/intern/ghost/intern/GHOST_ContextD3D.h
@@ -111,10 +111,6 @@ class GHOST_ContextD3D : public GHOST_Context {
   GHOST_TSuccess blitOpenGLOffscreenContext(GHOST_Context *offscreen_ctx,
                                             GHOST_TInt32 width,
                                             GHOST_TInt32 height);
-  GHOST_TSuccess blitOpenGLOffscreenContext(GHOST_Context *offscreen_ctx,
-                                            ID3D11RenderTargetView *render_target,
-                                            GHOST_TInt32 width,
-                                            GHOST_TInt32 height);
 
   class GHOST_SharedOpenGLResource *createSharedOpenGLResource(
       unsigned int width, unsigned int height, ID3D11RenderTargetView *render_target);
diff --git a/intern/ghost/intern/GHOST_Window.cpp b/intern/ghost/intern/GHOST_Window.cpp
index e639562f96e..cc4f871ea26 100644
--- a/intern/ghost/intern/GHOST_Window.cpp
+++ b/intern/ghost/intern/GHOST_Window.cpp
@@ -114,16 +114,6 @@ unsigned int GHOST_Window::getDefaultFramebuffer()
   return (m_context) ? m_context->getDefaultFramebuffer() : 0;
 }
 
-GHOST_TSuccess GHOST_Window::blitOpenGLOffscreenContext(GHOST_IContext *offscreen_ctx)
-{
-  GHOST_Rect rect;
-
-  getWindowBounds(rect);
-
-  return m_context->blitOpenGLOffscreenContext(
-      (GHOST_Context *)offscreen_ctx, rect.getWidth(), rect.getHeight());
-}
-
 bool GHOST_Window::isUpsideDown() const
 {
   return m_context->isUpsideDown();
diff --git a/intern/ghost/intern/GHOST_Window.h b/intern/ghost/intern/GHOST_Window.h
index 64515d9e5ee..59784abbae3 100644
--- a/intern/ghost/intern/GHOST_Window.h
+++ b/intern/ghost/intern/GHOST_Window.h
@@ -266,8 +266,6 @@ class GHOST_Window : public GHOST_IWindow {
    */
   virtual unsigned int getDefaultFramebuffer();
 
-  virtual GHOST_TSuccess blitOpenGLOffscreenContext(class GHOST_IContext *offscreen_ctx);
-
   /**
    * Returns the window user data.
    * \return The window user data.
diff --git a/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp b/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp
index 194f33fcccc..2732af49c12 100644
--- a/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp
+++ b/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp
@@ -258,23 +258,25 @@ class GHOST_XrGraphicsBindingD3D : public GHOST_IXrGraphicsBinding {
         swapchain_image);
 
     ogl_ctx->activateDrawingContext();
+    ogl_ctx->setDefaultFramebufferSize(draw_info->width, draw_info->height);
 
 #  if 0
     /* Ideally we'd just create a render target view for the OpenXR swapchain image texture and
      * blit from the OpenGL context into it. The NV_DX_interop extension doesn't want to work with
      * this though. At least not with Optimus hardware. See:
      * https://github.com/mpv-player/mpv/issues/2949#issuecomment-197262807.
-     * Note: Even if this worked, the blitting code only supports one shared resource by now, we'd
-     * need at least two (for each eye). We could also entirely re-register shared resources all
-     * the time. Also, the runtime might recreate the swapchain image so the shared resource would
-     * have to be re-registered then as well. */
+     */
 
     ID3D11RenderTargetView *rtv;
     CD3D11_RENDER_TARGET_VIEW_DESC rtv_desc(D3D11_RTV_DIMENSION_TEXTURE2D,
                                             DXGI_FORMAT_R8G8B8A8_UNORM);
 
     m_ghost_ctx->m_device->CreateRenderTargetView(d3d_swapchain_image->texture, &rtv_desc, &rtv);
-    m_ghost_ctx->blitOpenGLOffscreenContext(ogl_ctx, rtv, draw_info->width, draw_info->height);
+  

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list