On Sun, Feb 13, 2011 at 8:45 PM, Keith Whitwell <kei...@vmware.com> wrote:
> Marek, > > 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? > > eg. an app could do: > > memcpy(varray, foo, ...); > glDrawArrays(...); > memcpy(varray, bar, ...); > glDrawArrays(...); > > with these changes will drivers still notice the difference? > Keith, 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: @@ -646,6 +664,26 @@ st_draw_vbo(struct gl_context *ctx, #endif } + /* Notify the driver that the content of user buffers may have been + * changed. */ + if (!new_array && st->num_user_vbs) { + for (i = 0; i < st->num_user_vbs; i++) { + if (st->user_vb[i]) { + unsigned stride = st->user_vb_stride[i]; + + if (stride) { + pipe->redefine_user_buffer(pipe, st->user_vb[i], + min_index * stride, + (max_index + 1 - min_index) * stride); + } else { + /* stride == 0 */ + pipe->redefine_user_buffer(pipe, st->user_vb[i], + 0, st->user_vb[i]->width0); + } + } + } + } + setup_index_buffer(ctx, ib, &ibuffer); pipe->set_index_buffer(pipe, &ibuffer); 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. 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. Marek
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev