[Mesa-dev] [PATCH 07/14] radeon/video: directly create buffers in the right domain

Christian König deathsimple at vodafone.de
Tue Feb 4 16:17:43 CET 2014


From: Christian König <christian.koenig at amd.com>

Avoid moving things around on start of stream.

Signed-off-by: Christian König <christian.koenig at amd.com>
---
 src/gallium/drivers/radeon/radeon_uvd.c   | 6 +++---
 src/gallium/drivers/radeon/radeon_video.c | 9 ++++++---
 src/gallium/drivers/radeon/radeon_video.h | 4 +++-
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/radeon/radeon_uvd.c b/src/gallium/drivers/radeon/radeon_uvd.c
index e12b6fb..3075905 100644
--- a/src/gallium/drivers/radeon/radeon_uvd.c
+++ b/src/gallium/drivers/radeon/radeon_uvd.c
@@ -815,12 +815,12 @@ struct pipe_video_codec *ruvd_create_decoder(struct pipe_context *context,
 	for (i = 0; i < NUM_BUFFERS; ++i) {
 		unsigned msg_fb_size = FB_BUFFER_OFFSET + FB_BUFFER_SIZE;
 		STATIC_ASSERT(sizeof(struct ruvd_msg) <= FB_BUFFER_OFFSET);
-		if (!rvid_create_buffer(dec->ws, &dec->msg_fb_buffers[i], msg_fb_size)) {
+		if (!rvid_create_buffer(dec->ws, &dec->msg_fb_buffers[i], msg_fb_size, RADEON_DOMAIN_VRAM)) {
 			RVID_ERR("Can't allocated message buffers.\n");
 			goto error;
 		}
 
-		if (!rvid_create_buffer(dec->ws, &dec->bs_buffers[i], bs_buf_size)) {
+		if (!rvid_create_buffer(dec->ws, &dec->bs_buffers[i], bs_buf_size, RADEON_DOMAIN_GTT)) {
 			RVID_ERR("Can't allocated bitstream buffers.\n");
 			goto error;
 		}
@@ -829,7 +829,7 @@ struct pipe_video_codec *ruvd_create_decoder(struct pipe_context *context,
 		rvid_clear_buffer(dec->ws, dec->cs, &dec->bs_buffers[i]);
 	}
 
-	if (!rvid_create_buffer(dec->ws, &dec->dpb, dpb_size)) {
+	if (!rvid_create_buffer(dec->ws, &dec->dpb, dpb_size, RADEON_DOMAIN_VRAM)) {
 		RVID_ERR("Can't allocated dpb.\n");
 		goto error;
 	}
diff --git a/src/gallium/drivers/radeon/radeon_video.c b/src/gallium/drivers/radeon/radeon_video.c
index 3471202..455b147 100644
--- a/src/gallium/drivers/radeon/radeon_video.c
+++ b/src/gallium/drivers/radeon/radeon_video.c
@@ -59,9 +59,12 @@ unsigned rvid_alloc_stream_handle()
 }
 
 /* create a buffer in the winsys */
-bool rvid_create_buffer(struct radeon_winsys *ws, struct rvid_buffer *buffer, unsigned size)
+bool rvid_create_buffer(struct radeon_winsys *ws, struct rvid_buffer *buffer,
+			unsigned size, enum radeon_bo_domain domain)
 {
-	buffer->buf = ws->buffer_create(ws, size, 4096, false, RADEON_DOMAIN_GTT | RADEON_DOMAIN_VRAM);
+	buffer->domain = domain;
+
+	buffer->buf = ws->buffer_create(ws, size, 4096, false, domain);
 	if (!buffer->buf)
 		return false;
 
@@ -87,7 +90,7 @@ bool rvid_resize_buffer(struct radeon_winsys *ws, struct radeon_winsys_cs *cs,
 	struct rvid_buffer old_buf = *new_buf;
 	void *src = NULL, *dst = NULL;
 
-	if (!rvid_create_buffer(ws, new_buf, new_size))
+	if (!rvid_create_buffer(ws, new_buf, new_size, new_buf->domain))
 		goto error;
 
 	src = ws->buffer_map(old_buf.cs_handle, cs, PIPE_TRANSFER_READ);
diff --git a/src/gallium/drivers/radeon/radeon_video.h b/src/gallium/drivers/radeon/radeon_video.h
index 7833ddc..55d2ca4 100644
--- a/src/gallium/drivers/radeon/radeon_video.h
+++ b/src/gallium/drivers/radeon/radeon_video.h
@@ -43,6 +43,7 @@
 /* video buffer representation */
 struct rvid_buffer
 {
+	enum radeon_bo_domain		domain;
 	struct pb_buffer*		buf;
 	struct radeon_winsys_cs_handle*	cs_handle;
 };
@@ -51,7 +52,8 @@ struct rvid_buffer
 unsigned rvid_alloc_stream_handle(void);
 
 /* create a buffer in the winsys */
-bool rvid_create_buffer(struct radeon_winsys *ws, struct rvid_buffer *buffer, unsigned size);
+bool rvid_create_buffer(struct radeon_winsys *ws, struct rvid_buffer *buffer,
+			unsigned size, enum radeon_bo_domain domain);
 
 /* destroy a buffer */
 void rvid_destroy_buffer(struct rvid_buffer *buffer);
-- 
1.8.3.2



More information about the mesa-dev mailing list