<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Mar 15, 2019 at 9:30 PM Qiang Yu <<a href="mailto:yuq825@gmail.com">yuq825@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">From: Erico Nunes <<a href="mailto:nunes.erico@gmail.com" target="_blank">nunes.erico@gmail.com</a>><br>
<br>
pipe_draw_info has min_index and max_index fields that can be useful in<br>
indexed drawing, however gallium may decide to not compute them in some<br>
cases to avoid impacting performance if the driver won't need them.<br>
However, some drivers may need to always compute these values to build a<br>
valid command stream for indexed draw.<br>
Instead of reimplementing this functionality or having to explicitly<br>
compute those in driver specific code, this new cap can be used to<br>
ensure that gallium will not skip the computation.<br>
Drivers that set this cap will be able to rely on those values to build<br>
the command stream.<br>
<br>
For more details on this patch:<br>
<a href="https://lists.freedesktop.org/archives/mesa-dev/2018-March/189251.html" rel="noreferrer" target="_blank">https://lists.freedesktop.org/archives/mesa-dev/2018-March/189251.html</a><br>
<br>
Signed-off-by: Erico Nunes <<a href="mailto:nunes.erico@gmail.com" target="_blank">nunes.erico@gmail.com</a>><br>
---<br>
 src/gallium/auxiliary/util/u_screen.c | 3 +++<br>
 src/gallium/include/pipe/p_defines.h  | 1 +<br>
 src/mesa/state_tracker/st_draw.c      | 5 ++++-<br>
 3 files changed, 8 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/src/gallium/auxiliary/util/u_screen.c b/src/gallium/auxiliary/util/u_screen.c<br>
index 50964f3b3ef..e8fbdf56e2f 100644<br>
--- a/src/gallium/auxiliary/util/u_screen.c<br>
+++ b/src/gallium/auxiliary/util/u_screen.c<br>
@@ -341,6 +341,9 @@ u_pipe_screen_get_param_defaults(struct pipe_screen *pscreen,<br>
    case PIPE_CAP_MAX_VARYINGS:<br>
       return 8;<br>
<br>
+   case PIPE_CAP_FORCE_COMPUTE_MINMAX_INDICES:<br>
+      return 0;<br>
+<br>
    default:<br>
       unreachable("bad PIPE_CAP_*");<br>
    }<br>
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h<br>
index e2b0104ce43..495ba88e521 100644<br>
--- a/src/gallium/include/pipe/p_defines.h<br>
+++ b/src/gallium/include/pipe/p_defines.h<br>
@@ -858,6 +858,7 @@ enum pipe_cap<br>
    PIPE_CAP_DEST_SURFACE_SRGB_CONTROL,<br>
    PIPE_CAP_NIR_COMPACT_ARRAYS,<br>
    PIPE_CAP_MAX_VARYINGS,<br>
+   PIPE_CAP_FORCE_COMPUTE_MINMAX_INDICES,<br>
 };<br>
<br>
 /**<br>
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c<br>
index 7485fc82b18..501c09817c0 100644<br>
--- a/src/mesa/state_tracker/st_draw.c<br>
+++ b/src/mesa/state_tracker/st_draw.c<br>
@@ -195,9 +195,12 @@ st_draw_vbo(struct gl_context *ctx,<br>
<br>
    if (ib) {<br>
       struct gl_buffer_object *bufobj = ib->obj;<br>
+      struct pipe_screen *screen = st->pipe->screen;<br>
+      bool needs_minmax_index = st->draw_needs_minmax_index ||<br>
+         screen->get_param(screen, PIPE_CAP_FORCE_COMPUTE_MINMAX_INDICES);<br></blockquote><div><br></div><div>Can you call this only once at context creation?</div><div><br></div><div>Marek</div></div></div>