Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2022-08-28 13:40:27 +0300
committerClément Foucault <foucault.clem@gmail.com>2022-08-28 13:40:27 +0300
commit3ea7e5583b303af65edb3b016b9d19f857da6d9e (patch)
tree93fdfe0be03623d5bfd2706fa11d01d610e73880 /source
parent8a21c6800451ece7a2073ae3007a73d253763e05 (diff)
Add debug option to freeze culling matrices to be able to fly through and
inspect culling
Diffstat (limited to 'source')
-rw-r--r--source/blender/draw/intern/draw_manager.cc5
-rw-r--r--source/blender/draw/intern/draw_view.cc26
-rw-r--r--source/blender/draw/intern/draw_view.hh10
-rw-r--r--source/blender/makesdna/DNA_userdef_types.h2
-rw-r--r--source/blender/makesdna/DNA_view3d_types.h9
-rw-r--r--source/blender/makesrna/intern/rna_space.c7
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c8
7 files changed, 55 insertions, 12 deletions
diff --git a/source/blender/draw/intern/draw_manager.cc b/source/blender/draw/intern/draw_manager.cc
index 82ff05604f0..e0bd766f781 100644
--- a/source/blender/draw/intern/draw_manager.cc
+++ b/source/blender/draw/intern/draw_manager.cc
@@ -113,7 +113,10 @@ void Manager::submit(PassMain &pass, View &view)
debug_bind();
- view.compute_visibility(bounds_buf, resource_len_);
+ bool freeze_culling = (U.experimental.use_viewport_debug && DST.draw_ctx.v3d &&
+ (DST.draw_ctx.v3d->debug_flag & V3D_DEBUG_FREEZE_CULLING) != 0);
+
+ view.compute_visibility(bounds_buf, resource_len_, freeze_culling);
command::RecordingState state;
state.inverted_view = view.is_inverted();
diff --git a/source/blender/draw/intern/draw_view.cc b/source/blender/draw/intern/draw_view.cc
index b267ce19866..326e8629e52 100644
--- a/source/blender/draw/intern/draw_view.cc
+++ b/source/blender/draw/intern/draw_view.cc
@@ -9,6 +9,7 @@
#include "GPU_compute.h"
#include "GPU_debug.h"
+#include "draw_debug.hh"
#include "draw_shader.h"
#include "draw_view.hh"
@@ -287,8 +288,19 @@ void View::bind()
GPU_uniformbuf_bind(data_, DRW_VIEW_UBO_SLOT);
}
-void View::compute_visibility(ObjectBoundsBuf &bounds, uint resource_len)
+void View::compute_visibility(ObjectBoundsBuf &bounds, uint resource_len, bool debug_freeze)
{
+ if (debug_freeze && frozen_ == false) {
+ data_freeze_ = static_cast<ViewInfos>(data_);
+ data_freeze_.push_update();
+ }
+#ifdef DEBUG
+ if (debug_freeze) {
+ drw_debug_matrix_as_bbox(data_freeze_.persinv, float4(0, 1, 0, 1));
+ }
+#endif
+ frozen_ = debug_freeze;
+
GPU_debug_group_begin("View.compute_visibility");
/* TODO(fclem): Early out if visibility hasn't changed. */
@@ -304,17 +316,17 @@ void View::compute_visibility(ObjectBoundsBuf &bounds, uint resource_len)
GPU_shader_uniform_1i(shader, "resource_len", resource_len);
GPU_storagebuf_bind(bounds, GPU_shader_get_ssbo(shader, "bounds_buf"));
GPU_storagebuf_bind(visibility_buf_, GPU_shader_get_ssbo(shader, "visibility_buf"));
- GPU_uniformbuf_bind(data_, DRW_VIEW_UBO_SLOT);
+ GPU_uniformbuf_bind((frozen_) ? data_freeze_ : data_, DRW_VIEW_UBO_SLOT);
GPU_compute_dispatch(shader, divide_ceil_u(resource_len, DRW_VISIBILITY_GROUP_SIZE), 1, 1);
GPU_memory_barrier(GPU_BARRIER_SHADER_STORAGE);
}
- GPU_debug_group_end();
-}
+ if (frozen_) {
+ /* Bind back the non frozen data. */
+ GPU_uniformbuf_bind(data_, DRW_VIEW_UBO_SLOT);
+ }
-bool View::is_inverted() const
-{
- return data_.is_inverted;
+ GPU_debug_group_end();
}
} // namespace blender::draw
diff --git a/source/blender/draw/intern/draw_view.hh b/source/blender/draw/intern/draw_view.hh
index 9c3b4054dd8..351a92d025f 100644
--- a/source/blender/draw/intern/draw_view.hh
+++ b/source/blender/draw/intern/draw_view.hh
@@ -26,6 +26,8 @@ class View {
private:
UniformBuffer<ViewInfos> data_;
+ /** Freezed version of data_ used for debugging culling. */
+ UniformBuffer<ViewInfos> data_freeze_;
/** Result of the visibility computation. 1 bit per resource ID. */
VisibilityBuf visibility_buf_;
@@ -33,6 +35,7 @@ class View {
bool do_visibility_ = true;
bool dirty_ = true;
+ bool frozen_ = false;
public:
View(const char *name) : visibility_buf_(name), debug_name_(name){};
@@ -54,7 +57,10 @@ class View {
return data_.winmat[3][3] == 0.0f;
}
- bool is_inverted() const;
+ bool is_inverted() const
+ {
+ return data_.is_inverted;
+ }
float far_clip() const
{
@@ -75,7 +81,7 @@ class View {
private:
/** Called from draw manager. */
void bind();
- void compute_visibility(ObjectBoundsBuf &bounds, uint resource_len);
+ void compute_visibility(ObjectBoundsBuf &bounds, uint resource_len, bool debug_freeze);
void update_view_vectors();
void update_viewport_size();
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index dc461502b10..39fb3690da4 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -640,8 +640,8 @@ typedef struct UserDef_Experimental {
char use_cycles_debug;
char show_asset_debug_info;
char no_asset_indexing;
+ char use_viewport_debug;
char SANITIZE_AFTER_HERE;
- char _pad0;
/* The following options are automatically sanitized (set to 0)
* when the release cycle is not alpha. */
char use_new_curves_tools;
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index 0d281032b7e..1ba057d9c40 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -296,7 +296,9 @@ typedef struct View3D {
char _pad6[2];
int layact DNA_DEPRECATED;
unsigned short local_collections_uuid;
- short _pad7[3];
+ short _pad7[2];
+
+ short debug_flag;
/** Optional bool for 3d cursor to define center. */
short ob_center_cursor;
@@ -489,6 +491,11 @@ enum {
V3D_SHADING_COMPOSITOR = (1 << 15),
};
+/** #View3D.debug_flag */
+enum {
+ V3D_DEBUG_FREEZE_CULLING = (1 << 0),
+};
+
#define V3D_USES_SCENE_LIGHTS(v3d) \
((((v3d)->shading.type == OB_MATERIAL) && ((v3d)->shading.flag & V3D_SHADING_SCENE_LIGHTS)) || \
(((v3d)->shading.type == OB_RENDER) && \
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 285afd7e737..e8731812c65 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -4735,6 +4735,13 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Opacity", "Vertex Paint mix factor");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_GPencil_update");
+
+ /* Developper Debug overlay */
+
+ prop = RNA_def_property(srna, "use_debug_freeze_view_culling", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "debug_flag", V3D_DEBUG_FREEZE_CULLING);
+ RNA_def_property_ui_text(prop, "Freeze Culling", "Freeze view culling bounds");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
}
static void rna_def_space_view3d(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 61e6ba892bc..eb78faa2cbb 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -6371,6 +6371,14 @@ static void rna_def_userdef_experimental(BlenderRNA *brna)
prop = RNA_def_property(srna, "enable_eevee_next", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "enable_eevee_next", 1);
RNA_def_property_ui_text(prop, "EEVEE Next", "Enable the new EEVEE codebase, requires restart");
+
+ prop = RNA_def_property(srna, "use_viewport_debug", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "use_viewport_debug", 1);
+ RNA_def_property_ui_text(prop,
+ "Viewport Debug",
+ "Enable viewport debugging options for developpers in the overlays "
+ "pop-over");
+ RNA_def_property_update(prop, 0, "rna_userdef_ui_update");
}
static void rna_def_userdef_addon_collection(BlenderRNA *brna, PropertyRNA *cprop)