[Bf-blender-cvs] [d64d7891740] temp-ghost-vulkan: Initialize vk backend.

Jeroen Bakker noreply at git.blender.org
Mon Nov 7 08:03:57 CET 2022


Commit: d64d78917406c467656f697d115e9b171802fcc5
Author: Jeroen Bakker
Date:   Mon Nov 7 08:03:50 2022 +0100
Branches: temp-ghost-vulkan
https://developer.blender.org/rBd64d78917406c467656f697d115e9b171802fcc5

Initialize vk backend.

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

M	source/blender/gpu/vulkan/vk_backend.cc
M	source/blender/gpu/vulkan/vk_backend.hh

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

diff --git a/source/blender/gpu/vulkan/vk_backend.cc b/source/blender/gpu/vulkan/vk_backend.cc
index 00bc43333d6..d22275cebef 100644
--- a/source/blender/gpu/vulkan/vk_backend.cc
+++ b/source/blender/gpu/vulkan/vk_backend.cc
@@ -5,7 +5,7 @@
  * \ingroup gpu
  */
 
-#include "vk_backend.hh"
+#include "gpu_platform_private.hh"
 
 #include "vk_batch.hh"
 #include "vk_context.hh"
@@ -19,8 +19,36 @@
 #include "vk_uniform_buffer.hh"
 #include "vk_vertex_buffer.hh"
 
+#include "vk_backend.hh"
+
 namespace blender::gpu {
 
+void VKBackend::init_platform()
+{
+  BLI_assert(!GPG.initialized);
+
+  eGPUDeviceType device = GPU_DEVICE_ANY;
+  eGPUOSType os = GPU_OS_ANY;
+  eGPUDriverType driver = GPU_DRIVER_ANY;
+  eGPUSupportLevel support_level = GPU_SUPPORT_LEVEL_SUPPORTED;
+
+#ifdef _WIN32
+  os = GPU_OS_WIN;
+#elif defined(__APPLE__)
+  os = GPU_OS_MAC;
+#else
+  os = GPU_OS_UNIX;
+#endif
+
+  GPG.init(device, os, driver, support_level, GPU_BACKEND_VULKAN, "", "", "");
+}
+
+void VKBackend::platform_exit()
+{
+  BLI_assert(GPG.initialized);
+  GPG.clear();
+}
+
 void VKBackend::delete_resources()
 {
 }
diff --git a/source/blender/gpu/vulkan/vk_backend.hh b/source/blender/gpu/vulkan/vk_backend.hh
index 549478586e8..55b528bfa00 100644
--- a/source/blender/gpu/vulkan/vk_backend.hh
+++ b/source/blender/gpu/vulkan/vk_backend.hh
@@ -13,6 +13,16 @@ namespace blender::gpu {
 
 class VKBackend : public GPUBackend {
  public:
+  VKBackend()
+  {
+    VKBackend::init_platform();
+  }
+
+  virtual ~VKBackend()
+  {
+    VKBackend::platform_exit();
+  }
+
   void delete_resources() override;
 
   void samplers_update() override;
@@ -37,6 +47,10 @@ class VKBackend : public GPUBackend {
   void render_begin() override;
   void render_end() override;
   void render_step() override;
+
+ private:
+  static void init_platform();
+  static void platform_exit();
 };
 
 }  // namespace blender::gpu
\ No newline at end of file



More information about the Bf-blender-cvs mailing list