[Mesa-dev] [PATCH v2 06/11] r600g: override endian when mapping to read

Oded Gabbay oded.gabbay at gmail.com
Thu Apr 14 12:18:49 UTC 2016


When the driver performs a read from the GPU to the CPU, the endianess
should always be set to NATIVE.

Signed-off-by: Oded Gabbay <oded.gabbay at gmail.com>
---
 src/gallium/drivers/radeon/r600_texture.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/gallium/drivers/radeon/r600_texture.c b/src/gallium/drivers/radeon/r600_texture.c
index 0caa30f..0275808 100644
--- a/src/gallium/drivers/radeon/r600_texture.c
+++ b/src/gallium/drivers/radeon/r600_texture.c
@@ -1153,6 +1153,7 @@ static void *r600_texture_transfer_map(struct pipe_context *ctx,
 	struct r600_resource *buf;
 	unsigned offset = 0;
 	char *map;
+	enum pipe_endian saved_endian_format;
 
 	/* We cannot map a tiled texture directly because the data is
 	 * in a different order, therefore we do detiling using a blit.
@@ -1190,6 +1191,10 @@ static void *r600_texture_transfer_map(struct pipe_context *ctx,
 	trans->transfer.usage = usage;
 	trans->transfer.box = *box;
 
+	saved_endian_format = texture->endian_format;
+	if (usage & PIPE_TRANSFER_READ)
+		texture->endian_format = PIPE_ENDIAN_NATIVE;
+
 	if (rtex->is_depth) {
 		struct r600_texture *staging_depth;
 
@@ -1211,6 +1216,7 @@ static void *r600_texture_transfer_map(struct pipe_context *ctx,
 			if (!r600_init_flushed_depth_texture(ctx, &resource, &staging_depth)) {
 				R600_ERR("failed to create temporary texture to hold untiled copy\n");
 				FREE(trans);
+				texture->endian_format = saved_endian_format;
 				return NULL;
 			}
 
@@ -1219,6 +1225,7 @@ static void *r600_texture_transfer_map(struct pipe_context *ctx,
 				if (!temp) {
 					R600_ERR("failed to create a temporary depth texture\n");
 					FREE(trans);
+					texture->endian_format = saved_endian_format;
 					return NULL;
 				}
 
@@ -1234,6 +1241,7 @@ static void *r600_texture_transfer_map(struct pipe_context *ctx,
 			if (!r600_init_flushed_depth_texture(ctx, texture, &staging_depth)) {
 				R600_ERR("failed to create temporary texture to hold untiled copy\n");
 				FREE(trans);
+				texture->endian_format = saved_endian_format;
 				return NULL;
 			}
 
@@ -1262,6 +1270,7 @@ static void *r600_texture_transfer_map(struct pipe_context *ctx,
 		if (!staging) {
 			R600_ERR("failed to create temporary texture to hold untiled copy\n");
 			FREE(trans);
+			texture->endian_format = saved_endian_format;
 			return NULL;
 		}
 		trans->staging = &staging->resource;
@@ -1288,9 +1297,12 @@ static void *r600_texture_transfer_map(struct pipe_context *ctx,
 	if (!(map = r600_buffer_map_sync_with_rings(rctx, buf, usage))) {
 		pipe_resource_reference((struct pipe_resource**)&trans->staging, NULL);
 		FREE(trans);
+		texture->endian_format = saved_endian_format;
 		return NULL;
 	}
 
+	texture->endian_format = saved_endian_format;
+
 	*ptransfer = &trans->transfer;
 	return map + offset;
 }
-- 
2.5.5



More information about the mesa-dev mailing list