Module: Mesa
Branch: master
Commit: b5eb38f071135003014192b2686713be7ea76fb7
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b5eb38f071135003014192b2686713be7ea76fb7

Author: Marek Olšák <[email protected]>
Date:   Sat Feb 11 13:12:22 2017 +0100

radeonsi: implement uploading zero-stride vertex attribs

This is the only kind of user buffer we can get with the GL core profile.

Reviewed-by: Nicolai Hähnle <[email protected]>

---

 src/gallium/drivers/radeonsi/si_state.c | 31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_state.c 
b/src/gallium/drivers/radeonsi/si_state.c
index 107bc06..4ccca52 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -34,6 +34,7 @@
 #include "util/u_format_s3tc.h"
 #include "util/u_memory.h"
 #include "util/u_resource.h"
+#include "util/u_upload_mgr.h"
 
 /* Initialize an external atom (owned by ../radeon). */
 static void
@@ -3514,14 +3515,28 @@ static void si_set_vertex_buffers(struct pipe_context 
*ctx,
                for (i = 0; i < count; i++) {
                        const struct pipe_vertex_buffer *src = buffers + i;
                        struct pipe_vertex_buffer *dsti = dst + i;
-                       struct pipe_resource *buf = src->buffer;
-
-                       pipe_resource_reference(&dsti->buffer, buf);
-                       dsti->buffer_offset = src->buffer_offset;
-                       dsti->stride = src->stride;
-                       r600_context_add_resource_size(ctx, buf);
-                       if (buf)
-                               r600_resource(buf)->bind_history |= 
PIPE_BIND_VERTEX_BUFFER;
+
+                       if (unlikely(src->user_buffer)) {
+                               /* Zero-stride attribs only. */
+                               assert(src->stride == 0);
+
+                               /* Assume the attrib has 4 dwords like the vbo
+                                * module. This is also a good upper bound. */
+                               u_upload_data(sctx->b.b.stream_uploader, 0, 16, 
16,
+                                             src->user_buffer,
+                                             &dsti->buffer_offset,
+                                             &dsti->buffer);
+                               dsti->stride = 0;
+                       } else {
+                               struct pipe_resource *buf = src->buffer;
+
+                               pipe_resource_reference(&dsti->buffer, buf);
+                               dsti->buffer_offset = src->buffer_offset;
+                               dsti->stride = src->stride;
+                               r600_context_add_resource_size(ctx, buf);
+                               if (buf)
+                                       r600_resource(buf)->bind_history |= 
PIPE_BIND_VERTEX_BUFFER;
+                       }
                }
        } else {
                for (i = 0; i < count; i++) {

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to