Commit: 3a06bb5e45e650ac357bf18f7d7d9d9cc4eca00f
Author: Miguel Pozo
Date:   Tue Jan 17 16:03:02 2023 +0100
Branches: tmp-workbench-rewrite2
https://developer.blender.org/rB3a06bb5e45e650ac357bf18f7d7d9d9cc4eca00f

Add Freeze Culling support

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

M       source/blender/draw/engines/workbench/workbench_engine.cc
M       source/blender/draw/intern/draw_view.cc
M       source/blender/draw/intern/draw_view.hh

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

diff --git a/source/blender/draw/engines/workbench/workbench_engine.cc 
b/source/blender/draw/engines/workbench/workbench_engine.cc
index afa8281d1e0..36fe0dcb21e 100644
--- a/source/blender/draw/engines/workbench/workbench_engine.cc
+++ b/source/blender/draw/engines/workbench/workbench_engine.cc
@@ -21,6 +21,8 @@ using namespace draw;
 
 class Instance {
  public:
+  View view = {"DefaultView"};
+
   SceneState scene_state;
 
   SceneResources resources;
@@ -309,8 +311,10 @@ class Instance {
     }
   }
 
-  void draw(Manager &manager, View &view, GPUTexture *depth_tx, GPUTexture 
*color_tx)
+  void draw(Manager &manager, GPUTexture *depth_tx, GPUTexture *color_tx)
   {
+    view.sync(DRW_view_default_get());
+
     int2 resolution = scene_state.resolution;
 
     if (scene_state.render_finished) {
@@ -364,9 +368,9 @@ class Instance {
     resources.depth_in_front_tx.release();
   }
 
-  void draw_viewport(Manager &manager, View &view, GPUTexture *depth_tx, 
GPUTexture *color_tx)
+  void draw_viewport(Manager &manager, GPUTexture *depth_tx, GPUTexture 
*color_tx)
   {
-    this->draw(manager, view, depth_tx, color_tx);
+    this->draw(manager, depth_tx, color_tx);
 
     if (scene_state.sample + 1 < scene_state.samples_len) {
       DRW_viewport_request_redraw();
@@ -389,6 +393,7 @@ struct WORKBENCH_Data {
   DRWViewportEmptyList *psl;
   DRWViewportEmptyList *stl;
   workbench::Instance *instance;
+  draw::View *view;
 
   char info[GPU_INFO_SIZE];
 };
@@ -403,6 +408,7 @@ static void workbench_engine_init(void *vedata)
   WORKBENCH_Data *ved = reinterpret_cast<WORKBENCH_Data *>(vedata);
   if (ved->instance == nullptr) {
     ved->instance = new workbench::Instance();
+    ved->view = new draw::View("Default View");
   }
 
   ved->instance->init();
@@ -447,10 +453,8 @@ static void workbench_draw_scene(void *vedata)
     return;
   }
   DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
-  const DRWView *default_view = DRW_view_default_get();
   draw::Manager *manager = DRW_manager_get();
-  draw::View view("DefaultView", default_view);
-  ved->instance->draw_viewport(*manager, view, dtxl->depth, dtxl->color);
+  ved->instance->draw_viewport(*manager, dtxl->depth, dtxl->color);
 }
 
 static void workbench_instance_free(void *instance)
diff --git a/source/blender/draw/intern/draw_view.cc 
b/source/blender/draw/intern/draw_view.cc
index 2c5d4c6c9e6..85f31844311 100644
--- a/source/blender/draw/intern/draw_view.cc
+++ b/source/blender/draw/intern/draw_view.cc
@@ -31,6 +31,14 @@ void View::sync(const float4x4 &view_mat, const float4x4 
&win_mat, int view_id)
   dirty_ = true;
 }
 
+void View::sync(const DRWView *view)
+{
+  float4x4 view_mat, win_mat;
+  DRW_view_viewmat_get(view, view_mat.ptr(), false);
+  DRW_view_winmat_get(view, win_mat.ptr(), false);
+  this->sync(view_mat, win_mat);
+}
+
 void View::frustum_boundbox_calc(int view_id)
 {
   /* Extract the 8 corners from a Projection Matrix. */
diff --git a/source/blender/draw/intern/draw_view.hh 
b/source/blender/draw/intern/draw_view.hh
index 0408081c99c..5bf2bf1a568 100644
--- a/source/blender/draw/intern/draw_view.hh
+++ b/source/blender/draw/intern/draw_view.hh
@@ -64,14 +64,14 @@ class View {
   View(const char *name, const DRWView *view)
       : visibility_buf_(name), debug_name_(name), view_len_(1)
   {
-    float4x4 view_mat, win_mat;
-    DRW_view_viewmat_get(view, view_mat.ptr(), false);
-    DRW_view_winmat_get(view, win_mat.ptr(), false);
-    this->sync(view_mat, win_mat);
+    this->sync(view);
   }
 
   void sync(const float4x4 &view_mat, const float4x4 &win_mat, int view_id = 
0);
 
+  /* For compatibility with old system. Will be removed at some point. */
+  void sync(const DRWView *view);
+
   bool is_persp(int view_id = 0) const
   {
     BLI_assert(view_id < view_len_);

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to