<div class="gmail_quote">On Sun, Feb 13, 2011 at 8:45 PM, Keith Whitwell <span dir="ltr"><<a href="mailto:keithw@vmware.com" target="_blank">keithw@vmware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div><div style="font-family: Times New Roman; font-size: 12pt; color: rgb(0, 0, 0);">Marek,<div><br></div><div>These patches look good, but have you covered the case where the application is changing the contents of vertex arrays without rebinding/notifying GL in any way?</div>
<div><br></div><div>eg. an app could do:</div><div><br></div><div> memcpy(varray, foo, ...);</div><div> glDrawArrays(...);</div><div> memcpy(varray, bar, ...);</div><div> glDrawArrays(...);</div><div><br></div><div>with these changes will drivers still notice the difference?<br>
</div></div></div></blockquote></div><br>Keith,<br><br>Yes, they will. If vertex buffers are not re-set in st_draw_vbo, redefine_user_buffer is called for each user buffer which is set and that tells a driver which buffer ranges need to be re-uploaded. This can be found in the last hunk of the last patch, specifically:<br>
<br>@@ -646,6 +664,26 @@ st_draw_vbo(struct gl_context *ctx,<br>
#endif<br>
}<br>
<br>
+ /* Notify the driver that the content of user buffers may have been<br>
+ * changed. */<br>
+ if (!new_array && st->num_user_vbs) {<br>
+ for (i = 0; i < st->num_user_vbs; i++) {<br>
+ if (st->user_vb[i]) {<br>
+ unsigned stride = st->user_vb_stride[i];<br>
+<br>
+ if (stride) {<br>
+ pipe->redefine_user_buffer(pipe, st->user_vb[i],<br><div>
+ min_index * stride,<br>
+ (max_index + 1 - min_index) * stride);<br>
+ } else {<br>
+ /* stride == 0 */<br>
+ pipe->redefine_user_buffer(pipe, st->user_vb[i],<br>
+ 0, st->user_vb[i]->width0);<br>
+ }<br>
+ }<br>
+ }<br>
+ }<br>
+<br>
setup_index_buffer(ctx, ib, &ibuffer);<br>
pipe->set_index_buffer(pipe, &ibuffer);<br>
<font color="#888888"><br></font></div>What remains to implement is using this information in drivers to re-upload the buffer ranges marked with redefine_user_buffer. r300g, r600g, some nouveau drivers, and anything which uses Draw do not need this information, so they are safe. I think the only driver which needs special handling is svga, but I don't know that driver so well to be able to do it.<br>
<br>If svga used u_vbuf_mgr, which can determine the dirty buffer ranges by other means and can re-upload vertices by itself, this redefine_user_buffer hook wouldn't be needed (besides for updating width0). It would also clean up svga quite a bit, because u_vbuf_mgr can transparently translate vertices to formats and layouts compatible with D3D9.<br>
<br>Marek<br>