Mesa (master): r300g: make texture transfers more pipelined

Marek Olšák mareko at kemper.freedesktop.org
Tue Jun 1 19:59:16 PDT 2010


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

Author: Marek Olšák <maraeo at gmail.com>
Date:   Wed Jun  2 03:49:43 2010 +0200

r300g: make texture transfers more pipelined

Mostly based on Michel Dänzer's patch.

---

 src/gallium/drivers/r300/r300_texture.h  |    1 +
 src/gallium/drivers/r300/r300_transfer.c |   27 +++++++++++++++++++++------
 src/gallium/drivers/r300/r300_transfer.h |    2 +-
 3 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/r300/r300_texture.h b/src/gallium/drivers/r300/r300_texture.h
index 2d8f0e1..ff640c5 100644
--- a/src/gallium/drivers/r300/r300_texture.h
+++ b/src/gallium/drivers/r300/r300_texture.h
@@ -26,6 +26,7 @@
 #include "util/u_format.h"
 
 struct r300_texture;
+struct r300_screen;
 
 unsigned r300_get_swizzle_combined(const unsigned char *swizzle_format,
                                    const unsigned char *swizzle_view);
diff --git a/src/gallium/drivers/r300/r300_transfer.c b/src/gallium/drivers/r300/r300_transfer.c
index 593b599..0d88d74 100644
--- a/src/gallium/drivers/r300/r300_transfer.c
+++ b/src/gallium/drivers/r300/r300_transfer.c
@@ -21,12 +21,9 @@
  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  * USE OR OTHER DEALINGS IN THE SOFTWARE. */
 
-#include "r300_context.h"
 #include "r300_transfer.h"
 #include "r300_texture.h"
-#include "r300_screen.h"
-
-#include "r300_winsys.h"
+#include "r300_screen_buffer.h"
 
 #include "util/u_memory.h"
 #include "util/u_format.h"
@@ -110,6 +107,16 @@ r300_texture_get_transfer(struct pipe_context *ctx,
     struct r300_screen *r300screen = r300_screen(ctx->screen);
     struct r300_transfer *trans;
     struct pipe_resource base;
+    boolean referenced_cs, referenced_hw;
+
+    referenced_cs = r300screen->rws->is_buffer_referenced(
+                                r300screen->rws, tex->buffer, R300_REF_CS);
+    if (referenced_cs) {
+        referenced_hw = TRUE;
+    } else {
+        referenced_hw = r300screen->rws->is_buffer_referenced(
+                                r300screen->rws, tex->buffer, R300_REF_HW);
+    }
 
     trans = CALLOC_STRUCT(r300_transfer);
     if (trans) {
@@ -120,8 +127,10 @@ r300_texture_get_transfer(struct pipe_context *ctx,
         trans->transfer.box = *box;
 
         /* If the texture is tiled, we must create a temporary detiled texture
-         * for this transfer. */
-        if (tex->microtile || tex->macrotile) {
+         * for this transfer.
+         * Also make write transfers pipelined. */
+        if (tex->microtile || tex->macrotile ||
+            (referenced_hw & !(usage & PIPE_TRANSFER_READ))) {
             base.target = PIPE_TEXTURE_2D;
             base.format = texture->format;
             base.width0 = box->width;
@@ -166,11 +175,17 @@ r300_texture_get_transfer(struct pipe_context *ctx,
                 /* We cannot map a tiled texture directly because the data is
                  * in a different order, therefore we do detiling using a blit. */
                 r300_copy_from_tiled_texture(ctx, trans);
+
+                /* Always referenced in the blit. */
+                ctx->flush(ctx, 0, NULL);
             }
         } else {
             trans->transfer.stride =
                 r300_texture_get_stride(r300screen, tex, sr.level);
             trans->offset = r300_texture_get_offset(tex, sr.level, box->z, sr.face);
+
+            if (referenced_cs && (usage & PIPE_TRANSFER_READ))
+                ctx->flush(ctx, PIPE_FLUSH_RENDER_CACHE, NULL);
         }
     }
     return &trans->transfer;
diff --git a/src/gallium/drivers/r300/r300_transfer.h b/src/gallium/drivers/r300/r300_transfer.h
index d72e54e..0d32a68 100644
--- a/src/gallium/drivers/r300/r300_transfer.h
+++ b/src/gallium/drivers/r300/r300_transfer.h
@@ -24,7 +24,7 @@
 #ifndef R300_TRANSFER
 #define R300_TRANSFER
 
-#include "pipe/p_screen.h"
+#include "pipe/p_context.h"
 
 struct r300_context;
 



More information about the mesa-commit mailing list