gallium/radeon: never use staging buffers with AMD_pinned_memory
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Wed, 12 Apr 2017 10:41:05 +0000 (12:41 +0200)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Thu, 13 Apr 2017 15:36:26 +0000 (17:36 +0200)
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
src/gallium/drivers/radeon/r600_buffer_common.c

index 10036afeba452522943c1d05d425cacf2ddba5a5..0e93404c018563fefa3f57b17371d9df27fc1fba 100644 (file)
@@ -327,11 +327,25 @@ static void *r600_buffer_transfer_map(struct pipe_context *ctx,
 {
        struct r600_common_context *rctx = (struct r600_common_context*)ctx;
        struct r600_common_screen *rscreen = (struct r600_common_screen*)ctx->screen;
-        struct r600_resource *rbuffer = r600_resource(resource);
-        uint8_t *data;
+       struct r600_resource *rbuffer = r600_resource(resource);
+       uint8_t *data;
 
        assert(box->x + box->width <= resource->width0);
 
+       /* From GL_AMD_pinned_memory issues:
+        *
+        *     4) Is glMapBuffer on a shared buffer guaranteed to return the
+        *        same system address which was specified at creation time?
+        *
+        *        RESOLVED: NO. The GL implementation might return a different
+        *        virtual mapping of that memory, although the same physical
+        *        page will be used.
+        *
+        * So don't ever use staging buffers.
+        */
+       if (rscreen->ws->buffer_is_user_ptr(rbuffer->buf))
+               usage |= PIPE_TRANSFER_PERSISTENT;
+
        /* See if the buffer range being mapped has never been initialized,
         * in which case it can be mapped unsynchronized. */
        if (!(usage & PIPE_TRANSFER_UNSYNCHRONIZED) &&