[Mesa-dev] [PATCH] radeonsi: Fallback to shader decoding if UVD isn't available

Andreas Boll andreas.boll.dev at gmail.com
Wed Apr 3 11:51:28 PDT 2013


Cc: Christian König <deathsimple at vodafone.de>
---

Note: Compile tested only

 src/gallium/drivers/radeonsi/radeonsi_pipe.c |   39 ++++++++++++++++++++++++--
 src/gallium/drivers/radeonsi/radeonsi_pipe.h |    1 +
 2 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/radeonsi_pipe.c b/src/gallium/drivers/radeonsi/radeonsi_pipe.c
index 23197f2..1b83e40 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_pipe.c
+++ b/src/gallium/drivers/radeonsi/radeonsi_pipe.c
@@ -219,8 +219,13 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, void
 	r600_init_context_resource_functions(rctx);
 	si_init_surface_functions(rctx);
 
-	rctx->context.create_video_decoder = radeonsi_uvd_create_decoder;
-	rctx->context.create_video_buffer = radeonsi_video_buffer_create;
+	if (rscreen->has_uvd) {
+		rctx->context.create_video_decoder = radeonsi_uvd_create_decoder;
+		rctx->context.create_video_buffer = radeonsi_video_buffer_create;
+	} else {
+		rctx->context.create_video_decoder = vl_create_decoder;
+		rctx->context.create_video_buffer = vl_video_buffer_create;
+	}
 
 	switch (rctx->chip_class) {
 	case TAHITI:
@@ -534,6 +539,25 @@ static int r600_get_video_param(struct pipe_screen *screen,
 	}
 }
 
+static int r600_get_video_param_fallback(struct pipe_screen *screen,
+				enum pipe_video_profile profile,
+				enum pipe_video_cap param)
+{
+	switch (param) {
+	case PIPE_VIDEO_CAP_SUPPORTED:
+		return vl_profile_supported(screen, profile);
+	case PIPE_VIDEO_CAP_NPOT_TEXTURES:
+		return 1;
+	case PIPE_VIDEO_CAP_MAX_WIDTH:
+	case PIPE_VIDEO_CAP_MAX_HEIGHT:
+		return vl_video_buffer_max_size(screen);
+	case PIPE_VIDEO_CAP_PREFERED_FORMAT:
+		return PIPE_FORMAT_NV12;
+	default:
+		return 0;
+	}
+}
+
 static void r600_destroy_screen(struct pipe_screen* pscreen)
 {
 	struct r600_screen *rscreen = (struct r600_screen *)pscreen;
@@ -733,6 +757,9 @@ struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws)
 		return NULL;
 	}
 
+	/* UVD support. */
+	rscreen->has_uvd = rscreen->info.drm_minor >= 31;
+
 	if (r600_init_tiling(rscreen)) {
 		FREE(rscreen);
 		return NULL;
@@ -744,7 +771,13 @@ struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws)
 	rscreen->screen.get_param = r600_get_param;
 	rscreen->screen.get_shader_param = r600_get_shader_param;
 	rscreen->screen.get_paramf = r600_get_paramf;
-	rscreen->screen.get_video_param = r600_get_video_param;
+
+	if (rscreen->has_uvd) {
+		rscreen->screen.get_video_param = r600_get_video_param;
+	} else {
+		rscreen->screen.get_video_param = r600_get_video_param_fallback;
+	}
+
 	rscreen->screen.is_format_supported = si_is_format_supported;
 	rscreen->screen.is_video_format_supported = vl_video_buffer_is_format_supported;
 	rscreen->screen.context_create = r600_create_context;
diff --git a/src/gallium/drivers/radeonsi/radeonsi_pipe.h b/src/gallium/drivers/radeonsi/radeonsi_pipe.h
index d0e91c8..4dcb2de 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_pipe.h
+++ b/src/gallium/drivers/radeonsi/radeonsi_pipe.h
@@ -67,6 +67,7 @@ struct r600_screen {
 	unsigned			family;
 	enum chip_class			chip_class;
 	struct radeon_info		info;
+	bool				has_uvd;
 	struct r600_tiling_info		tiling_info;
 	struct util_slab_mempool	pool_buffers;
 	struct r600_pipe_fences		fences;
-- 
1.7.10.4



More information about the mesa-dev mailing list