[Bf-blender-cvs] [f0ce95b7b91] master: GPU: Enabled Metal test cases.

Jeroen Bakker noreply at git.blender.org
Tue Nov 15 13:51:09 CET 2022


Commit: f0ce95b7b91d5192a7fcda80f27511033800c579
Author: Jeroen Bakker
Date:   Tue Nov 15 13:12:05 2022 +0100
Branches: master
https://developer.blender.org/rBf0ce95b7b91d5192a7fcda80f27511033800c579

GPU: Enabled Metal test cases.

This commit enabled the metal gpu backend test cases. These test cases
will currently fail, but are by default disabled.

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

M	source/blender/gpu/tests/gpu_testing.cc
M	source/blender/gpu/tests/gpu_testing.hh

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

diff --git a/source/blender/gpu/tests/gpu_testing.cc b/source/blender/gpu/tests/gpu_testing.cc
index 67e296b11d5..1f54837cca3 100644
--- a/source/blender/gpu/tests/gpu_testing.cc
+++ b/source/blender/gpu/tests/gpu_testing.cc
@@ -14,7 +14,9 @@ namespace blender::gpu {
 
 void GPUTest::SetUp()
 {
+  GPU_backend_type_selection_set(gpu_backend_type);
   GHOST_GLSettings glSettings = {0};
+  glSettings.context_type = draw_context_type;
   CLG_init();
   ghost_system = GHOST_CreateSystem();
   ghost_context = GHOST_CreateOpenGLContext(ghost_system, glSettings);
diff --git a/source/blender/gpu/tests/gpu_testing.hh b/source/blender/gpu/tests/gpu_testing.hh
index 55ae2d7825a..058eabcc7ad 100644
--- a/source/blender/gpu/tests/gpu_testing.hh
+++ b/source/blender/gpu/tests/gpu_testing.hh
@@ -3,6 +3,7 @@
 #include "testing/testing.h"
 
 #include "GHOST_C-api.h"
+#include "GPU_platform.h"
 
 struct GPUContext;
 
@@ -18,12 +19,14 @@ namespace blender::gpu {
 class GPUTest : public ::testing::Test {
  private:
   GHOST_TDrawingContextType draw_context_type = GHOST_kDrawingContextTypeNone;
+  eGPUBackendType gpu_backend_type;
   GHOST_SystemHandle ghost_system;
   GHOST_ContextHandle ghost_context;
   struct GPUContext *context;
 
  protected:
-  GPUTest(GHOST_TDrawingContextType draw_context_type) : draw_context_type(draw_context_type)
+  GPUTest(GHOST_TDrawingContextType draw_context_type, eGPUBackendType gpu_backend_type)
+      : draw_context_type(draw_context_type), gpu_backend_type(gpu_backend_type)
   {
   }
 
@@ -33,15 +36,35 @@ class GPUTest : public ::testing::Test {
 
 class GPUOpenGLTest : public GPUTest {
  public:
-  GPUOpenGLTest() : GPUTest(GHOST_kDrawingContextTypeOpenGL)
+  GPUOpenGLTest() : GPUTest(GHOST_kDrawingContextTypeOpenGL, GPU_BACKEND_OPENGL)
   {
   }
 };
 
-#define GPU_TEST(test_name) \
+#define GPU_OPENGL_TEST(test_name) \
   TEST_F(GPUOpenGLTest, test_name) \
   { \
     test_##test_name(); \
   }
 
+#ifdef WITH_METAL_BACKEND
+class GPUMetalTest : public GPUTest {
+ public:
+  GPUMetalTest() : GPUTest(GHOST_kDrawingContextTypeMetal, GPU_BACKEND_METAL)
+  {
+  }
+};
+#  define GPU_METAL_TEST(test_name) \
+    TEST_F(GPUMetalTest, test_name) \
+    { \
+      test_##test_name(); \
+    }
+#else
+#  define GPU_METAL_TEST(test_name)
+#endif
+
+#define GPU_TEST(test_name) \
+  GPU_OPENGL_TEST(test_name) \
+  GPU_METAL_TEST(test_name)
+
 }  // namespace blender::gpu



More information about the Bf-blender-cvs mailing list