[Bf-blender-cvs] [ddd64ba03a2] tmp-vulkan: Merge branch 'master' into tmp-vulkan

Jeroen Bakker noreply at git.blender.org
Mon Jun 28 15:57:49 CEST 2021


Commit: ddd64ba03a2e2597489ab41a828299623150d85b
Author: Jeroen Bakker
Date:   Mon Jun 28 15:46:45 2021 +0200
Branches: tmp-vulkan
https://developer.blender.org/rBddd64ba03a2e2597489ab41a828299623150d85b

Merge branch 'master' into tmp-vulkan

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



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

diff --cc intern/ghost/intern/GHOST_SystemCocoa.mm
index d15814de174,97c5652f112..f336a5519fc
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@@ -32,16 -32,8 +32,12 @@@
  #include "GHOST_WindowCocoa.h"
  #include "GHOST_WindowManager.h"
  
- #if defined(WITH_GL_EGL)
- #  include "GHOST_ContextEGL.h"
- #else
- #  include "GHOST_ContextCGL.h"
- #endif
+ #include "GHOST_ContextCGL.h"
  
 +#if defined(WITH_VULKAN)
 +#  include "GHOST_ContextVK.h"
 +#endif
 +
  #ifdef WITH_INPUT_NDOF
  #  include "GHOST_NDOFManagerCocoa.h"
  #endif
diff --cc intern/ghost/intern/GHOST_SystemWin32.cpp
index f6cfe121a56,fd01d21da5a..967597ab295
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@@ -50,15 -50,7 +50,19 @@@
  #include "GHOST_WindowManager.h"
  #include "GHOST_WindowWin32.h"
  
++<<<<<<< HEAD
 +#if defined(WITH_VULKAN)
 +#  include "GHOST_ContextVK.h"
 +#endif
 +
 +#if defined(WITH_GL_EGL)
 +#  include "GHOST_ContextEGL.h"
 +#else
 +#  include "GHOST_ContextWGL.h"
 +#endif
++=======
+ #include "GHOST_ContextWGL.h"
++>>>>>>> master
  
  #ifdef WITH_INPUT_NDOF
  #  include "GHOST_NDOFManagerWin32.h"
diff --cc intern/ghost/intern/GHOST_SystemX11.cpp
index c9570cfe0c8,2b1069f9acc..5eafa13bb54
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@@ -452,41 -437,12 +452,42 @@@ GHOST_IContext *GHOST_SystemX11::create
  #  endif
  #endif
  
 -  GHOST_Context *context;
 +    GHOST_Context *context;
 +
 +    for (int minor = 5; minor >= 0; --minor) {
 +#if defined(WITH_GL_EGL)
 +      context = new GHOST_ContextEGL(false,
 +                                     EGLNativeWindowType(nullptr),
 +                                     EGLNativeDisplayType(m_display),
 +                                     profile_mask,
 +                                     4,
 +                                     minor,
 +                                     GHOST_OPENGL_EGL_CONTEXT_FLAGS |
 +                                         (false ? EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR : 0),
 +                                     GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
 +                                     EGL_OPENGL_API);
 +#else
 +      context = new GHOST_ContextGLX(false,
 +                                     (Window)NULL,
 +                                     m_display,
 +                                     (GLXFBConfig)NULL,
 +                                     profile_mask,
 +                                     4,
 +                                     minor,
 +                                     GHOST_OPENGL_GLX_CONTEXT_FLAGS |
 +                                         (false ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
 +                                     GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
 +#endif
 +
 +      if (context->initializeDrawingContext())
 +        return context;
 +      else
 +        delete context;
 +    }
  
 -  for (int minor = 5; minor >= 0; --minor) {
  #if defined(WITH_GL_EGL)
-     context = new GHOST_ContextEGL(false,
+     context = new GHOST_ContextEGL(this,
+                                    false,
                                     EGLNativeWindowType(nullptr),
                                     EGLNativeDisplayType(m_display),
                                     profile_mask,
diff --cc intern/ghost/intern/GHOST_WindowCocoa.mm
index 8c8edf97dbe,d082fa99ad8..175edc44dd1
--- a/intern/ghost/intern/GHOST_WindowCocoa.mm
+++ b/intern/ghost/intern/GHOST_WindowCocoa.mm
@@@ -22,16 -22,8 +22,12 @@@
  #include "GHOST_Debug.h"
  #include "GHOST_SystemCocoa.h"
  
- #if defined(WITH_GL_EGL)
- #  include "GHOST_ContextEGL.h"
- #else
- #  include "GHOST_ContextCGL.h"
- #endif
+ #include "GHOST_ContextCGL.h"
  
 +#if defined(WITH_VULKAN)
 +#  include "GHOST_ContextVK.h"
 +#endif
 +
  #include <Cocoa/Cocoa.h>
  #include <Metal/Metal.h>
  #include <QuartzCore/QuartzCore.h>
diff --cc source/blender/draw/tests/draw_testing.cc
index b12a775edee,45a857e7577..5087e7e494d
--- a/source/blender/draw/tests/draw_testing.cc
+++ b/source/blender/draw/tests/draw_testing.cc
@@@ -15,28 -9,10 +15,28 @@@
  namespace blender::draw {
  
  /* Base class for draw test cases. It will setup and tear down the GPU part around each test. */
- void DrawTest::SetUp()
+ void DrawOpenGLTest::SetUp()
  {
-   GPUTest::SetUp();
+   GPUOpenGLTest::SetUp();
 +
 +  /* Initialize color management. Required to construct a scene creation depends on it. */
 +  BKE_idtype_init();
 +  BKE_appdir_init();
 +  IMB_init();
 +
 +  DRW_engines_register();
 +
    DRW_draw_state_init_gtests(GPU_SHADER_CFG_DEFAULT);
  }
  
- void DrawTest::TearDown()
++void DrawOpenGLTest::TearDown()
 +{
 +  DRW_engines_free();
 +
 +  IMB_exit();
 +  BKE_appdir_exit();
 +
 +  GPUTest::TearDown();
 +}
 +
  }  // namespace blender::draw
diff --cc source/blender/draw/tests/draw_testing.hh
index c8188341afc,00f0ac5bab7..74712c10d49
--- a/source/blender/draw/tests/draw_testing.hh
+++ b/source/blender/draw/tests/draw_testing.hh
@@@ -5,10 -5,15 +5,16 @@@
  namespace blender::draw {
  
  /* Base class for draw test cases. It will setup and tear down the GPU part around each test. */
- class DrawTest : public blender::gpu::GPUTest {
+ class DrawOpenGLTest : public blender::gpu::GPUOpenGLTest {
   public:
    void SetUp() override;
 +  void TearDown() override;
  };
  
+ #define DRAW_TEST(test_name) \
+   TEST_F(DrawOpenGLTest, test_name) \
+   { \
+     test_##test_name(); \
+   }
+ 
  }  // namespace blender::draw
diff --cc source/blender/draw/tests/performance_test.cc
index 96a8566cb95,00000000000..e16a078fd9d
mode 100644,000000..100644
--- a/source/blender/draw/tests/performance_test.cc
+++ b/source/blender/draw/tests/performance_test.cc
@@@ -1,223 -1,0 +1,223 @@@
 +/* Apache License, Version 2.0 */
 +
 +#include "testing/testing.h"
 +
 +#include "draw_testing.hh"
 +#include "intern/draw_manager_testing.h"
 +
 +#include "DRW_engine.h"
 +#include "draw_cache_impl.h"
 +
 +#include "BKE_editmesh.h"
 +#include "BKE_idtype.h"
 +#include "BKE_mesh.h"
 +#include "BKE_mesh_wrapper.h"
 +#include "BKE_scene.h"
 +
 +#include "BLI_rand.hh"
 +#include "BLI_task.h"
 +
 +#include "ED_mesh.h"
 +
 +#include "DNA_mesh_types.h"
 +#include "DNA_object_types.h"
 +#include "DNA_scene_types.h"
 +
 +#include "GPU_context.h"
 +#include "GPU_init_exit.h"
 +#include "GPU_shader.h"
 +
 +#include "engines/eevee/eevee_private.h"
 +#include "engines/gpencil/gpencil_engine.h"
 +#include "engines/image/image_private.h"
 +#include "engines/overlay/overlay_private.h"
 +#include "engines/workbench/workbench_private.h"
 +
 +namespace blender::draw {
 +
 +/**
 + * During investigation or executing in a profiler it is handly to disable multithreading. This can
 + * be done by setting RUN_SINGLE_THREADED to true.
 + *
 + * Default(false) => run multithreaded
 + */
 +constexpr bool RUN_SINGLE_THREADED = false;
 +
- class DrawCacheTest : public DrawTest {
++class DrawCacheTest : public DrawOpenGLTest {
 + protected:
 +  TaskGraph *task_graph;
 +
 + public:
 +  void SetUp() override
 +  {
-     DrawTest::SetUp();
++    DrawOpenGLTest::SetUp();
 +    if (RUN_SINGLE_THREADED) {
 +      BLI_system_num_threads_override_set(1);
 +    }
 +    task_graph = BLI_task_graph_create();
 +  }
 +
 +  void TearDown() override
 +  {
 +    BLI_task_graph_free(task_graph);
 +    if (RUN_SINGLE_THREADED) {
 +      BLI_system_num_threads_override_set(0);
 +    }
-     DrawTest::TearDown();
++    DrawOpenGLTest::TearDown();
 +  }
 +};
 +
 +class DrawCachePerformanceTest : public DrawCacheTest {
 + protected:
 +  Scene scene = {{nullptr}};
 +  Object ob_mesh = {{nullptr}};
 +  Mesh mesh = {{nullptr}};
 +  BMesh *bm = nullptr;
 +  RandomNumberGenerator rng;
 +
 + public:
 +  void SetUp() override
 +  {
 +    DrawCacheTest::SetUp();
 +    IDType_ID_SCE.init_data(&scene.id);
 +    IDType_ID_OB.init_data(&ob_mesh.id);
 +    IDType_ID_ME.init_data(&mesh.id);
 +    ob_mesh.type = OB_MESH;
 +    ob_mesh.data = &mesh;
 +    EDBM_mesh_make(&ob_mesh, SCE_SELECT_VERTEX, false);
 +    bm = mesh.edit_mesh->bm;
 +
 +    /* Ensure batch cache is available. */
 +    DRW_mesh_batch_cache_validate(&mesh);
 +  }
 +
 +  void TearDown() override
 +  {
 +    EDBM_mesh_free(mesh.edit_mesh);
 +    bm = nullptr;
 +    IDType_ID_ME.free_data(&mesh.id);
 +    IDType_ID_OB.free_data(&ob_mesh.id);
 +    IDType_ID_SCE.free_data(&scene.id);
 +    DrawCacheTest::TearDown();
 +  }
 +
 + protected:
 +  /**
 +   * Build a test mesh with given number of polygons.
 +   * Each polygon is created from 3 random generated verts.
 +   */
 +  void build_mesh(size_t num_polygons)
 +  {
 +    add_polygons_to_bm(num_polygons);
 +
 +    /* Make sure mesh_eval_final is up to date (inline depsgraph evaluation). See
 +     * `editbmesh_calc_modifiers`. */
 +    mesh.edit_mesh->mesh_eval_final = BKE_mesh_from_bmesh_for_eval_nomain(
 +        mesh.edit_mesh->bm, nullptr, &mesh);
 +    mesh.edit_mesh->mesh_eval_cage = BKE_mesh_wrapper_from_editmesh_with_coords(
 +        mesh.edit_mesh, nullptr, nullptr, &mesh);
 +
 +    BKE_editmesh_looptri_calc(mesh.edit_mesh);
 +  }
 +
 +  /**
 +   * Check if the given GPUBatch is filled.
 +   */
 +  void expect_filled(GPUBatch *batch)
 +  {
 +    EXPECT_NE(batch->elem, nullptr);
 +  }
 +
 +  /**
 +   * Check if the given GPUBatch is filled.
 +   */
 +  void expect_empty(GPUBatch *batch)
 +  {
 +    EXPECT_EQ(batch->elem, nullptr);
 +    for (int i = 0; i < GPU_BATCH_VBO_MAX_LEN; i++) {
 +      EXPECT_EQ(batch->verts[i], nullptr);
 +    }
 +  }
 +
 + private:
 +  /**
 +   * Create a new random vert in BMesh.
 +   */
 +  BMVert *add_random_vert_to_bm()
 +  {
 +    float co[3] = {(rng.get_float() - 0.5f) * 10.0f,
 +                   (rng.get_float() - 0.5f) * 10.0f,
 +                   (rng.get_float() - 0.5f) * 10.0f};
 +    BMVert *result = BM_vert_create(bm, co, nullptr, BM_CREATE_NOP);
 +    return result;
 +  }
 +
 +  /**
 +   * Add `num_polygons` polygons to the BMesh.
 +   */
 +  void add_polygons_to_bm(size_t num_polygons)
 +  {
 +    /* Use 3 verts per face to skip triangulation. */
 +    const int verts_per_face = 3;
 +
 +    for (int i = 0; i < num_polygons; i++) {
 +  

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list