Mesa (master): util: move and adjust the vertex upload heuristic equation from u_vbuf

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Apr 6 15:04:57 UTC 2020


Module: Mesa
Branch: master
Commit: 068a3bf0d7cda0301b3dfc2e258698c6848ca706
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=068a3bf0d7cda0301b3dfc2e258698c6848ca706

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Sun Mar 22 21:00:18 2020 -0400

util: move and adjust the vertex upload heuristic equation from u_vbuf

This will also be used by glthread.

The new equation is optimized for glthread.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4466>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4466>

---

 src/gallium/auxiliary/util/u_vbuf.c |  3 +--
 src/util/u_math.h                   | 20 +++++++++++++++++++-
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_vbuf.c b/src/gallium/auxiliary/util/u_vbuf.c
index f47d93ac3f1..567cb6a75c9 100644
--- a/src/gallium/auxiliary/util/u_vbuf.c
+++ b/src/gallium/auxiliary/util/u_vbuf.c
@@ -1433,8 +1433,7 @@ void u_vbuf_draw_vbo(struct u_vbuf *mgr, const struct pipe_draw_info *info)
           * performance. */
          if (!info->indirect &&
              !new_info.primitive_restart &&
-             num_vertices > new_info.count * 4 &&
-             new_info.count > 32 &&
+             util_is_vbo_upload_ratio_too_large(new_info.count, num_vertices) &&
              !u_vbuf_mapping_vertex_buffer_blocks(mgr)) {
             unroll_indices = TRUE;
             user_vb_mask &= ~(mgr->nonzero_stride_vb_mask &
diff --git a/src/util/u_math.h b/src/util/u_math.h
index a672486f02f..6c2cb5437c0 100644
--- a/src/util/u_math.h
+++ b/src/util/u_math.h
@@ -783,7 +783,25 @@ util_fpstate_set_denorms_to_zero(unsigned current_fpstate);
 void
 util_fpstate_set(unsigned fpstate);
 
-
+/**
+ * For indexed draw calls, return true if the vertex count to be drawn is
+ * much lower than the vertex count that has to be uploaded, meaning
+ * that the driver should flatten indices instead of trying to upload
+ * a too big range.
+ *
+ * This is used by vertex upload code in u_vbuf and glthread.
+ */
+static inline bool
+util_is_vbo_upload_ratio_too_large(unsigned draw_vertex_count,
+                                   unsigned upload_vertex_count)
+{
+   if (draw_vertex_count > 1024)
+      return upload_vertex_count > draw_vertex_count * 4;
+   else if (draw_vertex_count > 32)
+      return upload_vertex_count > draw_vertex_count * 8;
+   else
+      return upload_vertex_count > draw_vertex_count * 16;
+}
 
 #ifdef __cplusplus
 }



More information about the mesa-commit mailing list