[Bf-blender-cvs] [50e0d346f15] temp-ghost-vulkan: Implemented `newDrawingContext`.

Jeroen Bakker noreply at git.blender.org
Tue Nov 1 08:43:09 CET 2022


Commit: 50e0d346f1592164f6ed74759c70c7de71dadbd4
Author: Jeroen Bakker
Date:   Fri Oct 21 12:50:58 2022 +0200
Branches: temp-ghost-vulkan
https://developer.blender.org/rB50e0d346f1592164f6ed74759c70c7de71dadbd4

Implemented `newDrawingContext`.

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

M	intern/ghost/intern/GHOST_WindowCocoa.mm
M	intern/ghost/intern/GHOST_WindowWayland.cpp
M	intern/ghost/intern/GHOST_WindowWin32.cpp
M	intern/ghost/intern/GHOST_WindowX11.cpp

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

diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm
index bc1f1e99a3a..8748bbaeb35 100644
--- a/intern/ghost/intern/GHOST_WindowCocoa.mm
+++ b/intern/ghost/intern/GHOST_WindowCocoa.mm
@@ -8,6 +8,10 @@
 
 #include "GHOST_ContextCGL.h"
 
+#ifdef WITH_VULKAN_BACKEND
+#  include "GHOST_ContextVK.h"
+#endif
+
 #include <Cocoa/Cocoa.h>
 #include <Metal/Metal.h>
 #include <QuartzCore/QuartzCore.h>
@@ -803,6 +807,19 @@ GHOST_TSuccess GHOST_WindowCocoa::setOrder(GHOST_TWindowOrder order)
 
 GHOST_Context *GHOST_WindowCocoa::newDrawingContext(GHOST_TDrawingContextType type)
 {
+#ifdef WITH_VULKAN_BACKEND
+  if (type == GHOST_kDrawingContextTypeVulkan) {
+    GHOST_Context *context = new GHOST_ContextVK(m_wantStereoVisual, m_metalLayer, 1, 0, true);
+
+    if (!context->initializeDrawingContext()) {
+      delete context;
+      return NULL;
+    }
+
+    return context;
+  }
+#endif
+
   if (type == GHOST_kDrawingContextTypeOpenGL || type == GHOST_kDrawingContextTypeMetal) {
 
     GHOST_Context *context = new GHOST_ContextCGL(
diff --git a/intern/ghost/intern/GHOST_WindowWayland.cpp b/intern/ghost/intern/GHOST_WindowWayland.cpp
index ad94a02b514..c58aca3d72d 100644
--- a/intern/ghost/intern/GHOST_WindowWayland.cpp
+++ b/intern/ghost/intern/GHOST_WindowWayland.cpp
@@ -14,6 +14,9 @@
 
 #include "GHOST_ContextEGL.h"
 #include "GHOST_ContextNone.h"
+#ifdef WITH_VULKAN_BACKEND
+#  include "GHOST_ContextVK.h"
+#endif
 
 #include <wayland-client-protocol.h>
 
@@ -914,6 +917,13 @@ GHOST_Context *GHOST_WindowWayland::newDrawingContext(GHOST_TDrawingContextType
     case GHOST_kDrawingContextTypeNone:
       context = new GHOST_ContextNone(m_wantStereoVisual);
       break;
+
+#ifdef WITH_VULKAN_BACKEND
+    case GHOST_kDrawingContextTypeVulkan:
+      context = new GHOST_ContextVK(m_wantStereoVisual, m_metalLayer, 1, 0, true);
+      break;
+#endif
+
     case GHOST_kDrawingContextTypeOpenGL:
       for (int minor = 6; minor >= 0; --minor) {
         context = new GHOST_ContextEGL(system_,
diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp
index e2d143ee5e6..5086920be43 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.cpp
+++ b/intern/ghost/intern/GHOST_WindowWin32.cpp
@@ -15,6 +15,9 @@
 #include "utfconv.h"
 
 #include "GHOST_ContextWGL.h"
+#ifdef WITH_VULKAN_BACKEND
+#  include "GHOST_ContextVK.h"
+#endif
 
 #include <Dwmapi.h>
 
@@ -632,6 +635,19 @@ GHOST_Context *GHOST_WindowWin32::newDrawingContext(GHOST_TDrawingContextType ty
     return context;
   }
 
+#ifdef WITH_VULKAN_BACKEND
+  else if (type == GHOST_kDrawingContextTypeVulkan) {
+    GHOST_Context *context = new GHOST_ContextVK(false, m_hWnd, 1, 0, m_debug_context);
+
+    if (context->initializeDrawingContext()) {
+      return context;
+    }
+    else {
+      delete context;
+    }
+  }
+#endif
+
   return NULL;
 }
 
diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp
index 8d8ce3643f4..9f77bdc4dd0 100644
--- a/intern/ghost/intern/GHOST_WindowX11.cpp
+++ b/intern/ghost/intern/GHOST_WindowX11.cpp
@@ -24,6 +24,9 @@
 
 #include "GHOST_ContextEGL.h"
 #include "GHOST_ContextGLX.h"
+#ifdef WITH_VULKAN_BACKEND
+#  include "GHOST_ContextVK.h"
+#endif
 
 /* For #XIWarpPointer. */
 #ifdef WITH_X11_XINPUT
@@ -1228,6 +1231,26 @@ static GHOST_Context *create_glx_context(Window window,
 
 GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type)
 {
+#if defined(WITH_VULKAN)
+  if (type == GHOST_kDrawingContextTypeVulkan) {
+    GHOST_Context *context = new GHOST_ContextVK(m_wantStereoVisual,
+                                                 GHOST_kVulkanPlatformX11,
+                                                 m_window,
+                                                 m_display,
+                                                 NULL,
+                                                 NULL,
+                                                 1,
+                                                 0,
+                                                 m_is_debug_context);
+
+    if (!context->initializeDrawingContext()) {
+      delete context;
+      return nullptr;
+    }
+    return context;
+  }
+#endif
+
   if (type == GHOST_kDrawingContextTypeOpenGL) {
 
     /* During development:



More information about the Bf-blender-cvs mailing list