<div dir="ltr"><span class="gmail-m_-1170325871933010518gmail-il" style="font-size:12.8px">Tested</span><span style="font-size:12.8px">-</span><span class="gmail-m_-1170325871933010518gmail-il" style="font-size:12.8px">by</span><span style="font-size:12.8px">: Vadym Shovkoplias <<a href="mailto:vadym.shovkoplias@globallogic.com" target="_blank">vadym.shovkoplias@<wbr>globallogic.com</a></span><span style="font-size:12.8px">></span><br><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">This patch also fixes similar issue with SHENZHEN I/O game (<a href="https://bugs.freedesktop.org/show_bug.cgi?id=104392" target="_blank">https://bugs.freedesktop.org/<wbr>show_bug.cgi?id=104392</a>)</span></div><div><span style="font-size:12.8px">Tested on HP Zbook. </span></div></div><div class="gmail_extra"><br><div class="gmail_quote">2018-01-11 11:53 GMT+02:00 Thomas Hellstrom <span dir="ltr"><<a href="mailto:thellstrom@vmware.com" target="_blank">thellstrom@vmware.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Upon reception of an event that lowered the number of active back buffers,<br>
the code would immediately try to free all back buffers with an id equal to or<br>
higher than the new number of active back buffers.<br>
<br>
However, that could lead to an active or to-be-active back buffer being freed,<br>
since the old number of back buffers was used when obtaining an idle back<br>
buffer for use.<br>
<br>
This lead to crashes when lowering the number of active back buffers by<br>
transitioning from page-flipping to non-page-flipping presents.<br>
<br>
Fix this by computing the number of active back buffers only when trying to<br>
obtain a new back buffer.<br>
<br>
Fixes: 15e208c4cc ("loader/dri3: Don't accidently free buffer holding new back content")<br>
Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=104214" rel="noreferrer" target="_blank">https://bugs.freedesktop.org/<wbr>show_bug.cgi?id=104214</a><br>
Cc: "17.3" <<a href="mailto:mesa-stable@lists.freedesktop.org">mesa-stable@lists.<wbr>freedesktop.org</a>><br>
Signed-off-by: Thomas Hellstrom <<a href="mailto:thellstrom@vmware.com">thellstrom@vmware.com</a>><br>
---<br>
 src/loader/loader_dri3_helper.<wbr>c | 6 +++---<br>
 1 file changed, 3 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/src/loader/loader_dri3_<wbr>helper.c b/src/loader/loader_dri3_<wbr>helper.c<br>
index cc890bc..c01b0ac 100644<br>
--- a/src/loader/loader_dri3_<wbr>helper.c<br>
+++ b/src/loader/loader_dri3_<wbr>helper.c<br>
@@ -205,7 +205,6 @@ void<br>
 loader_dri3_set_swap_interval(<wbr>struct loader_dri3_drawable *draw, int interval)<br>
 {<br>
    draw->swap_interval = interval;<br>
-   dri3_update_num_back(draw);<br>
 }<br>
<br>
 /** dri3_free_render_buffer<br>
@@ -377,7 +376,6 @@ dri3_handle_present_event(<wbr>struct loader_dri3_drawable *draw,<br>
             draw->flipping = false;<br>
             break;<br>
          }<br>
-         dri3_update_num_back(draw);<br>
<br>
          if (draw->vtable->show_fps)<br>
             draw->vtable->show_fps(draw, ce->ust);<br>
@@ -402,7 +400,8 @@ dri3_handle_present_event(<wbr>struct loader_dri3_drawable *draw,<br>
             buf->busy = 0;<br>
<br>
          if (buf && draw->num_back <= b && b < LOADER_DRI3_MAX_BACK &&<br>
-             draw->cur_blit_source != b) {<br>
+             draw->cur_blit_source != b &&<br>
+             buf->busy == 0) {<br>
             dri3_free_render_buffer(draw, buf);<br>
             draw->buffers[b] = NULL;<br>
          }<br>
@@ -537,6 +536,7 @@ dri3_find_back(struct loader_dri3_drawable *draw)<br>
    /* Check whether we need to reuse the current back buffer as new back.<br>
     * In that case, wait until it's not busy anymore.<br>
     */<br>
+   dri3_update_num_back(draw);<br>
    num_to_consider = draw->num_back;<br>
    if (!loader_dri3_have_image_blit(<wbr>draw) && draw->cur_blit_source != -1) {<br>
       num_to_consider = 1;<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.7.4<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div>