[Bf-blender-cvs] [3ee90b6c017] temp-T101905-gpu-backend-argument: Shader builder process all available backends.

Jeroen Bakker noreply at git.blender.org
Wed Oct 19 13:19:30 CEST 2022


Commit: 3ee90b6c01783e36a17a077489f2fd1150c7d19d
Author: Jeroen Bakker
Date:   Wed Oct 19 13:19:26 2022 +0200
Branches: temp-T101905-gpu-backend-argument
https://developer.blender.org/rB3ee90b6c01783e36a17a077489f2fd1150c7d19d

Shader builder process all available backends.

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

M	source/blender/gpu/intern/gpu_shader_builder.cc
M	source/blender/gpu/intern/gpu_shader_builder_stubs.cc

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

diff --git a/source/blender/gpu/intern/gpu_shader_builder.cc b/source/blender/gpu/intern/gpu_shader_builder.cc
index b3aa7dd428b..9f28126da75 100644
--- a/source/blender/gpu/intern/gpu_shader_builder.cc
+++ b/source/blender/gpu/intern/gpu_shader_builder.cc
@@ -15,6 +15,8 @@
 #include "GPU_init_exit.h"
 #include "gpu_shader_create_info_private.hh"
 
+#include "BLI_vector.hh"
+
 #include "CLG_log.h"
 
 namespace blender::gpu::shader_builder {
@@ -41,8 +43,22 @@ void ShaderBuilder::init()
   CLG_init();
 
   GHOST_GLSettings glSettings = {0};
-  // TODO(jbakker): should be based on a startup option(s).
-  glSettings.context_type = GHOST_kDrawingContextTypeOpenGL;
+  switch (GPU_backend_type_selection_get()) {
+    case GPU_BACKEND_OPENGL:
+      glSettings.context_type = GHOST_kDrawingContextTypeOpenGL;
+      break;
+
+#ifdef WITH_METAL_BACKEND
+    case GPU_BACKEND_METAL:
+      glSettings.context_type = GHOST_kDrawingContextTypeMetal;
+      break;
+#endif
+
+    default:
+      BLI_assert_unreachable();
+      break;
+  }
+
   ghost_system_ = GHOST_CreateSystem();
   ghost_context_ = GHOST_CreateOpenGLContext(ghost_system_, glSettings);
   GHOST_ActivateOpenGLContext(ghost_context_);
@@ -75,13 +91,21 @@ int main(int argc, const char *argv[])
 
   int exit_code = 0;
 
-  blender::gpu::shader_builder::ShaderBuilder builder;
-  builder.init();
-  if (!builder.bake_create_infos()) {
-    exit_code = 1;
+  blender::Vector<eGPUBackendType> backends_to_validate;
+  backends_to_validate.append(GPU_BACKEND_OPENGL);
+#ifdef WITH_METAL_BACKEND
+  backends_to_validate.append(GPU_BACKEND_METAL);
+#endif
+  for (eGPUBackendType backend : backends_to_validate) {
+    GPU_backend_type_selection_set(backend);
+    blender::gpu::shader_builder::ShaderBuilder builder;
+    builder.init();
+    if (!builder.bake_create_infos()) {
+      exit_code = 1;
+    }
+    builder.exit();
+    exit(exit_code);
   }
-  builder.exit();
-  exit(exit_code);
 
   return exit_code;
 }
diff --git a/source/blender/gpu/intern/gpu_shader_builder_stubs.cc b/source/blender/gpu/intern/gpu_shader_builder_stubs.cc
index 7a06ede5c6d..65bda7ba858 100644
--- a/source/blender/gpu/intern/gpu_shader_builder_stubs.cc
+++ b/source/blender/gpu/intern/gpu_shader_builder_stubs.cc
@@ -46,6 +46,15 @@ void IMB_freeImBuf(ImBuf * /*ibuf*/)
   BLI_assert_unreachable();
 }
 
+struct ImBuf *IMB_allocImBuf(unsigned int /*x*/,
+                             unsigned int /*y*/,
+                             unsigned char /*planes*/,
+                             unsigned int /*flags*/)
+{
+  BLI_assert_unreachable();
+  return nullptr;
+}
+
 /** \} */
 
 /* -------------------------------------------------------------------- */



More information about the Bf-blender-cvs mailing list