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
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2022-05-11 00:36:05 +0300
committerClément Foucault <foucault.clem@gmail.com>2022-05-11 00:36:16 +0300
commitb47c5505aa3791639c2bd7d68a95bd1515e606ed (patch)
tree975d1949b7a0d39e987e3e938a35202f3f011d25
parent74228e2cd253c66a9204cc3926243dd8e07edd53 (diff)
Fix T96892 Overlay: Hiding all of a mesh in edit mode causes visual glitch
This is caused by the geometry shader used by the edit mode line drawing. If the drawcall uses indexed drawing and if the index buffer only contains restart indices, it seems the result is 1 glitchy invocation of the geometry shader. Workaround by tagging these special case index buffers and bypassing their drawcall.
-rw-r--r--source/blender/gpu/intern/gpu_index_buffer.cc1
-rw-r--r--source/blender/gpu/intern/gpu_index_buffer_private.hh7
2 files changed, 7 insertions, 1 deletions
diff --git a/source/blender/gpu/intern/gpu_index_buffer.cc b/source/blender/gpu/intern/gpu_index_buffer.cc
index 54473b3a44d..146461d1dfb 100644
--- a/source/blender/gpu/intern/gpu_index_buffer.cc
+++ b/source/blender/gpu/intern/gpu_index_buffer.cc
@@ -232,6 +232,7 @@ void IndexBuf::init(uint indices_len, uint32_t *indices, uint min_index, uint ma
data_ = indices;
index_start_ = 0;
index_len_ = indices_len;
+ is_empty_ = min_index > max_index;
#if GPU_TRACK_INDEX_RANGE
/* Everything remains 32 bit while building to keep things simple.
diff --git a/source/blender/gpu/intern/gpu_index_buffer_private.hh b/source/blender/gpu/intern/gpu_index_buffer_private.hh
index 9323a81d393..6ce62ae852e 100644
--- a/source/blender/gpu/intern/gpu_index_buffer_private.hh
+++ b/source/blender/gpu/intern/gpu_index_buffer_private.hh
@@ -45,6 +45,8 @@ class IndexBuf {
bool is_init_ = false;
/** Is this object only a reference to a subrange of another IndexBuf. */
bool is_subrange_ = false;
+ /** True if buffer only contains restart indices. */
+ bool is_empty_ = false;
union {
/** Mapped buffer data. non-NULL indicates not yet sent to VRAM. */
@@ -61,9 +63,12 @@ class IndexBuf {
void init_subrange(IndexBuf *elem_src, uint start, uint length);
void init_build_on_device(uint index_len);
+ /* Returns render index count (not precise). */
uint32_t index_len_get() const
{
- return index_len_;
+ /* Return 0 to bypass drawing for index buffers full of restart indices.
+ * They can lead to graphical glitches on some systems. (See T96892) */
+ return is_empty_ ? 0 : index_len_;
}
/* Return size in byte of the drawable data buffer range. Actual buffer size might be bigger. */
size_t size_get() const