From efc7fda4627919b5355952d955ee4a2c98505e56 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Christian=20K=C3=B6nig?= Date: Tue, 12 Jul 2011 00:12:12 +0200 Subject: [PATCH] [g3dvl] add some more PIPE_VIDEO_CAPs --- src/gallium/auxiliary/vl/vl_decoder.c | 12 ++++++++ src/gallium/auxiliary/vl/vl_decoder.h | 6 ++++ src/gallium/auxiliary/vl/vl_video_buffer.c | 10 +++++++ src/gallium/auxiliary/vl/vl_video_buffer.h | 6 ++++ src/gallium/drivers/nvfx/nvfx_screen.c | 6 ++++ src/gallium/drivers/r300/r300_screen.c | 18 ++++++++---- src/gallium/drivers/r600/r600_pipe.c | 5 ++++ src/gallium/drivers/softpipe/sp_screen.c | 6 ++++ src/gallium/include/pipe/p_defines.h | 5 +++- src/gallium/state_trackers/vdpau/query.c | 32 ++++++++-------------- 10 files changed, 79 insertions(+), 27 deletions(-) diff --git a/src/gallium/auxiliary/vl/vl_decoder.c b/src/gallium/auxiliary/vl/vl_decoder.c index 2be5c17ed3e..fac03359a0f 100644 --- a/src/gallium/auxiliary/vl/vl_decoder.c +++ b/src/gallium/auxiliary/vl/vl_decoder.c @@ -32,6 +32,18 @@ #include "vl_decoder.h" #include "vl_mpeg12_decoder.h" +bool +vl_profile_supported(struct pipe_screen *screen, enum pipe_video_profile profile) +{ + assert(screen); + switch (u_reduce_video_profile(profile)) { + case PIPE_VIDEO_CODEC_MPEG12: + return true; + default: + return false; + } +} + struct pipe_video_decoder * vl_create_decoder(struct pipe_context *pipe, enum pipe_video_profile profile, diff --git a/src/gallium/auxiliary/vl/vl_decoder.h b/src/gallium/auxiliary/vl/vl_decoder.h index 440f5ecfb04..0e9280dbfa2 100644 --- a/src/gallium/auxiliary/vl/vl_decoder.h +++ b/src/gallium/auxiliary/vl/vl_decoder.h @@ -31,6 +31,12 @@ #include +/** + * check if a given profile is supported with shader based decoding + */ +bool +vl_profile_supported(struct pipe_screen *screen, enum pipe_video_profile profile); + /** * standard implementation of pipe->create_video_decoder */ diff --git a/src/gallium/auxiliary/vl/vl_video_buffer.c b/src/gallium/auxiliary/vl/vl_video_buffer.c index 8b05749659f..4d8b6649dd2 100644 --- a/src/gallium/auxiliary/vl/vl_video_buffer.c +++ b/src/gallium/auxiliary/vl/vl_video_buffer.c @@ -88,6 +88,16 @@ vl_video_buffer_is_format_supported(struct pipe_screen *screen, return true; } +unsigned +vl_video_buffer_max_size(struct pipe_screen *screen) +{ + uint32_t max_2d_texture_level; + + max_2d_texture_level = screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS); + + return 1 << (max_2d_texture_level-1); +} + static void vl_video_buffer_destroy(struct pipe_video_buffer *buffer) { diff --git a/src/gallium/auxiliary/vl/vl_video_buffer.h b/src/gallium/auxiliary/vl/vl_video_buffer.h index 78aac3fa0f2..291d15c1e9d 100644 --- a/src/gallium/auxiliary/vl/vl_video_buffer.h +++ b/src/gallium/auxiliary/vl/vl_video_buffer.h @@ -54,6 +54,12 @@ struct vl_video_buffer const enum pipe_format * vl_video_buffer_formats(struct pipe_screen *screen, enum pipe_format format); +/** + * get maximum size of video buffers + */ +unsigned +vl_video_buffer_max_size(struct pipe_screen *screen); + /** * check if video buffer format is supported for a codec/profile * can be used as default implementation of screen->is_video_format_supported diff --git a/src/gallium/drivers/nvfx/nvfx_screen.c b/src/gallium/drivers/nvfx/nvfx_screen.c index 4901e3b2bf7..d85c0a6da41 100644 --- a/src/gallium/drivers/nvfx/nvfx_screen.c +++ b/src/gallium/drivers/nvfx/nvfx_screen.c @@ -3,6 +3,7 @@ #include "util/u_format.h" #include "util/u_format_s3tc.h" #include "util/u_simple_screen.h" +#include "vl/vl_decoder.h" #include "vl/vl_video_buffer.h" #include "nouveau/nouveau_screen.h" @@ -213,8 +214,13 @@ nvfx_screen_get_video_param(struct pipe_screen *screen, 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 0; + case PIPE_VIDEO_CAP_MAX_WIDTH: + case PIPE_VIDEO_CAP_MAX_HEIGHT: + return vl_video_buffer_max_size(screen); default: return 0; } diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index 19b273f4f49..c8df45fb3e7 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -25,6 +25,7 @@ #include "util/u_format_s3tc.h" #include "util/u_memory.h" #include "os/os_time.h" +#include "vl/vl_decoder.h" #include "vl/vl_video_buffer.h" #include "r300_context.h" @@ -307,12 +308,17 @@ static int r300_get_video_param(struct pipe_screen *screen, enum pipe_video_profile profile, enum pipe_video_cap param) { - switch (param) { - case PIPE_VIDEO_CAP_NPOT_TEXTURES: - return 0; - default: - return 0; - } + switch (param) { + case PIPE_VIDEO_CAP_SUPPORTED: + return vl_profile_supported(screen, profile); + case PIPE_VIDEO_CAP_NPOT_TEXTURES: + return 0; + case PIPE_VIDEO_CAP_MAX_WIDTH: + case PIPE_VIDEO_CAP_MAX_HEIGHT: + return vl_video_buffer_max_size(screen); + default: + return 0; + } } static boolean r300_is_format_supported(struct pipe_screen* screen, diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c index 8e492787235..65b12de79b1 100644 --- a/src/gallium/drivers/r600/r600_pipe.c +++ b/src/gallium/drivers/r600/r600_pipe.c @@ -491,8 +491,13 @@ static int r600_get_video_param(struct pipe_screen *screen, 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); default: return 0; } diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c index f952e6046f0..1e58d27be88 100644 --- a/src/gallium/drivers/softpipe/sp_screen.c +++ b/src/gallium/drivers/softpipe/sp_screen.c @@ -33,6 +33,7 @@ #include "pipe/p_defines.h" #include "pipe/p_screen.h" #include "draw/draw_context.h" +#include "vl/vl_decoder.h" #include "vl/vl_video_buffer.h" #include "state_tracker/sw_winsys.h" @@ -177,8 +178,13 @@ softpipe_get_video_param(struct pipe_screen *screen, 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 0; + case PIPE_VIDEO_CAP_MAX_WIDTH: + case PIPE_VIDEO_CAP_MAX_HEIGHT: + return vl_video_buffer_max_size(screen); default: return 0; } diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index d8b1a9e171f..7f1bf0dee68 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -496,7 +496,10 @@ enum pipe_shader_cap /* Video caps, can be different for each codec/profile */ enum pipe_video_cap { - PIPE_VIDEO_CAP_NPOT_TEXTURES = 0, + PIPE_VIDEO_CAP_SUPPORTED = 0, + PIPE_VIDEO_CAP_NPOT_TEXTURES = 1, + PIPE_VIDEO_CAP_MAX_WIDTH = 2, + PIPE_VIDEO_CAP_MAX_HEIGHT = 3, }; enum pipe_video_codec diff --git a/src/gallium/state_trackers/vdpau/query.c b/src/gallium/state_trackers/vdpau/query.c index a32fd406bf5..ec17e59118f 100644 --- a/src/gallium/state_trackers/vdpau/query.c +++ b/src/gallium/state_trackers/vdpau/query.c @@ -128,11 +128,7 @@ vlVdpDecoderQueryCapabilities(VdpDevice device, VdpDecoderProfile profile, { vlVdpDevice *dev; struct pipe_screen *pscreen; - enum pipe_video_profile p_profile; - uint32_t max_decode_width; - uint32_t max_decode_height; - uint32_t max_2d_texture_level; VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying decoder\n"); @@ -152,24 +148,20 @@ vlVdpDecoderQueryCapabilities(VdpDevice device, VdpDecoderProfile profile, *is_supported = false; return VDP_STATUS_OK; } - - if (p_profile != PIPE_VIDEO_PROFILE_MPEG2_SIMPLE && p_profile != PIPE_VIDEO_PROFILE_MPEG2_MAIN) { - *is_supported = false; - return VDP_STATUS_OK; + + *is_supported = pscreen->get_video_param(pscreen, p_profile, PIPE_VIDEO_CAP_SUPPORTED); + if (*is_supported) { + *max_width = pscreen->get_video_param(pscreen, p_profile, PIPE_VIDEO_CAP_MAX_WIDTH); + *max_height = pscreen->get_video_param(pscreen, p_profile, PIPE_VIDEO_CAP_MAX_HEIGHT); + *max_level = 16; + *max_macroblocks = (*max_width/16)*(*max_height/16); + } else { + *max_width = 0; + *max_height = 0; + *max_level = 0; + *max_macroblocks = 0; } - /* XXX hack, need to implement something more sane when the decoders have been implemented */ - max_2d_texture_level = pscreen->get_param(pscreen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS); - max_decode_width = max_decode_height = pow(2,max_2d_texture_level-2); - if (!(max_decode_width && max_decode_height)) - return VDP_STATUS_RESOURCES; - - *is_supported = true; - *max_width = max_decode_width; - *max_height = max_decode_height; - *max_level = 16; - *max_macroblocks = (max_decode_width/16) * (max_decode_height/16); - return VDP_STATUS_OK; } -- 2.30.2