gallium/u_index_modify: don't add PIPE_TRANSFER_UNSYNCHRONIZED unconditionally
authorMarek Olšák <marek.olsak@amd.com>
Fri, 17 Feb 2017 11:55:24 +0000 (12:55 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Sun, 19 Feb 2017 16:16:26 +0000 (17:16 +0100)
It's OK for r300g (because r300g can't write to buffers via the GPU), but
not later hardware. This issue was spotted randomly.

Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/auxiliary/util/u_index_modify.c
src/gallium/auxiliary/util/u_index_modify.h
src/gallium/drivers/r300/r300_render_translate.c
src/gallium/drivers/r600/r600_state_common.c
src/gallium/drivers/radeonsi/si_state_draw.c

index 5c4fc3c05d13a09bcad2c70bd78c01b19c2903bf..7b072b29a0faba202623316636312069b608b9ad 100644 (file)
@@ -28,6 +28,7 @@
 
 void util_shorten_ubyte_elts_to_userptr(struct pipe_context *context,
                                        struct pipe_index_buffer *ib,
+                                        unsigned add_transfer_flags,
                                        int index_bias,
                                        unsigned start,
                                        unsigned count,
@@ -43,7 +44,7 @@ void util_shorten_ubyte_elts_to_userptr(struct pipe_context *context,
     } else {
        in_map = pipe_buffer_map(context, ib->buffer,
                                 PIPE_TRANSFER_READ |
-                                PIPE_TRANSFER_UNSYNCHRONIZED,
+                                add_transfer_flags,
                                 &src_transfer);
     }
     in_map += start;
@@ -62,6 +63,7 @@ void util_shorten_ubyte_elts_to_userptr(struct pipe_context *context,
 
 void util_rebuild_ushort_elts_to_userptr(struct pipe_context *context,
                                         struct pipe_index_buffer *ib,
+                                         unsigned add_transfer_flags,
                                         int index_bias,
                                         unsigned start, unsigned count,
                                         void *out)
@@ -76,7 +78,7 @@ void util_rebuild_ushort_elts_to_userptr(struct pipe_context *context,
     } else {
        in_map = pipe_buffer_map(context, ib->buffer,
                                 PIPE_TRANSFER_READ |
-                                PIPE_TRANSFER_UNSYNCHRONIZED,
+                                add_transfer_flags,
                                 &in_transfer);
     }
     in_map += start;
@@ -95,6 +97,7 @@ void util_rebuild_ushort_elts_to_userptr(struct pipe_context *context,
 
 void util_rebuild_uint_elts_to_userptr(struct pipe_context *context,
                                       struct pipe_index_buffer *ib,
+                                       unsigned add_transfer_flags,
                                       int index_bias,
                                       unsigned start, unsigned count,
                                       void *out)
@@ -109,7 +112,7 @@ void util_rebuild_uint_elts_to_userptr(struct pipe_context *context,
     } else {
        in_map = pipe_buffer_map(context, ib->buffer,
                                 PIPE_TRANSFER_READ |
-                                PIPE_TRANSFER_UNSYNCHRONIZED,
+                                add_transfer_flags,
                                 &in_transfer);
     }
     in_map += start;
index 1d34b12e519e195f33b07265249be471b86a211d..0cfc189ede177b6d28fe54a4d209e7c0d3db1c90 100644 (file)
@@ -29,6 +29,7 @@ struct pipe_index_buffer;
 
 void util_shorten_ubyte_elts_to_userptr(struct pipe_context *context,
                                        struct pipe_index_buffer *ib,
+                                        unsigned add_transfer_flags,
                                        int index_bias,
                                        unsigned start,
                                        unsigned count,
@@ -36,12 +37,14 @@ void util_shorten_ubyte_elts_to_userptr(struct pipe_context *context,
 
 void util_rebuild_ushort_elts_to_userptr(struct pipe_context *context,
                                         struct pipe_index_buffer *ib,
+                                         unsigned add_transfer_flags,
                                         int index_bias,
                                         unsigned start, unsigned count,
                                         void *out);
 
 void util_rebuild_uint_elts_to_userptr(struct pipe_context *context,
                                       struct pipe_index_buffer *ib,
+                                       unsigned add_transfer_flags,
                                       int index_bias,
                                       unsigned start, unsigned count,
                                       void *out);
index 7221211deea4ed9671b7730f94e81a713ef30412..7800f6eea229554b322730a96bcfcb1662425b36 100644 (file)
@@ -41,7 +41,7 @@ void r300_translate_index_buffer(struct r300_context *r300,
                        &out_offset, out_buffer, &ptr);
 
         util_shorten_ubyte_elts_to_userptr(
-                &r300->context, ib, index_offset,
+                &r300->context, ib, PIPE_TRANSFER_UNSYNCHRONIZED, index_offset,
                 *start, count, ptr);
 
         *index_size = 2;
@@ -55,6 +55,7 @@ void r300_translate_index_buffer(struct r300_context *r300,
                            &out_offset, out_buffer, &ptr);
 
             util_rebuild_ushort_elts_to_userptr(&r300->context, ib,
+                                                PIPE_TRANSFER_UNSYNCHRONIZED,
                                                 index_offset, *start,
                                                 count, ptr);
 
@@ -69,6 +70,7 @@ void r300_translate_index_buffer(struct r300_context *r300,
                            &out_offset, out_buffer, &ptr);
 
             util_rebuild_uint_elts_to_userptr(&r300->context, ib,
+                                              PIPE_TRANSFER_UNSYNCHRONIZED,
                                               index_offset, *start,
                                               count, ptr);
 
index 9ff2364d875691c179899135a8bae3486c278d04..1fbe39209dead8c9314dc0c4b05b29e4e8fa132f 100644 (file)
@@ -1743,7 +1743,7 @@ static void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info
                                        256, &out_offset, &out_buffer, &ptr);
 
                        util_shorten_ubyte_elts_to_userptr(
-                                               &rctx->b.b, &ib, 0, ib.offset + start, count, ptr);
+                                               &rctx->b.b, &ib, 0, 0, ib.offset + start, count, ptr);
 
                        pipe_resource_reference(&ib.buffer, NULL);
                        ib.user_buffer = NULL;
index c463fef835c6c4c896161e90066e95bae42b78c5..141dd8f7526aff1e7b7c23be4327346b1e745ea2 100644 (file)
@@ -1064,7 +1064,7 @@ void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
                                return;
                        }
 
-                       util_shorten_ubyte_elts_to_userptr(&sctx->b.b, &ib, 0,
+                       util_shorten_ubyte_elts_to_userptr(&sctx->b.b, &ib, 0, 0,
                                                           ib.offset + start,
                                                           count, ptr);