<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Reviewed-by: Tim Rowley <<a href="mailto:timothy.o.rowley@intel.com" class="">timothy.o.rowley@intel.com</a>>
<div class=""><br class="">
<div>
<blockquote type="cite" class="">
<div class="">On Jun 15, 2017, at 11:24 AM, Bruce Cherniak <<a href="mailto:bruce.cherniak@intel.com" class="">bruce.cherniak@intel.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="">The swr driver uses vertex_buffer->stride to determine the number<br class="">
of elements in a VBO. A recent change to the state-tracker made it<br class="">
possible for VBO's with stride=0. This resulted in a divide by zero<br class="">
crash in the driver. The solution is to use the pre-calculated vertex<br class="">
element stream_pitch in this case.<br class="">
<br class="">
This patch fixes the crash in a number of piglit and VTK tests introduced<br class="">
by 17f776c27be266f2.<br class="">
<br class="">
There are several VTK tests that still crash and need proper handling of<br class="">
vertex_buffer_index.  This will come in a follow-on patch.<br class="">
<br class="">
v2: Correctly update all parameters for VBO constants (stride = 0).<br class="">
   Also fixes the remaining crashes/regressions that v1 did<br class="">
   not address, without touching vertex_buffer_index.<br class="">
---<br class="">
src/gallium/drivers/swr/swr_state.cpp | 25 ++++++++++++++++++-------<br class="">
1 file changed, 18 insertions(+), 7 deletions(-)<br class="">
<br class="">
diff --git a/src/gallium/drivers/swr/swr_state.cpp b/src/gallium/drivers/swr/swr_state.cpp<br class="">
index 08549e51a1..316872581d 100644<br class="">
--- a/src/gallium/drivers/swr/swr_state.cpp<br class="">
+++ b/src/gallium/drivers/swr/swr_state.cpp<br class="">
@@ -1247,13 +1247,24 @@ swr_update_derived(struct pipe_context *pipe,<br class="">
<br class="">
         pitch = vb->stride;<br class="">
         if (!vb->is_user_buffer) {<br class="">
-            /* VBO<br class="">
-             * size is based on buffer->width0 rather than info.max_index<br class="">
-             * to prevent having to validate VBO on each draw */<br class="">
-            size = vb->buffer.resource->width0;<br class="">
-            elems = size / pitch;<br class="">
-            partial_inbounds = size % pitch;<br class="">
-            min_vertex_index = 0;<br class="">
+            /* VBO */<br class="">
+            if (!pitch) {<br class="">
+               /* If pitch=0 (ie vb->stride), buffer contains a single<br class="">
+                * constant attribute.  Use the stream_pitch which was<br class="">
+                * calculated during creation of vertex_elements_state for the<br class="">
+                * size of the attribute. */<br class="">
+               size = ctx->velems->stream_pitch[i];<br class="">
+               elems = 1;<br class="">
+               partial_inbounds = 0;<br class="">
+               min_vertex_index = 0;<br class="">
+            } else {<br class="">
+               /* size is based on buffer->width0 rather than info.max_index<br class="">
+                * to prevent having to validate VBO on each draw. */<br class="">
+               size = vb->buffer.resource->width0;<br class="">
+               elems = size / pitch;<br class="">
+               partial_inbounds = size % pitch;<br class="">
+               min_vertex_index = 0;<br class="">
+            }<br class="">
<br class="">
            p_data = swr_resource_data(vb->buffer.resource) + vb->buffer_offset;<br class="">
         } else {<br class="">
-- <br class="">
2.11.0<br class="">
<br class="">
_______________________________________________<br class="">
mesa-dev mailing list<br class="">
<a href="mailto:mesa-dev@lists.freedesktop.org" class="">mesa-dev@lists.freedesktop.org</a><br class="">
https://lists.freedesktop.org/mailman/listinfo/mesa-dev<br class="">
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>