From 4f3fb1586aebfe248321e935651b5af92b5a8261 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Christian=20K=C3=B6nig?= Date: Tue, 12 Apr 2011 19:21:07 +0200 Subject: [PATCH] [g3dvl] make resource format selection a public interface --- src/gallium/auxiliary/vl/vl_context.c | 9 ++------- src/gallium/auxiliary/vl/vl_mpeg12_decoder.c | 6 +++--- src/gallium/auxiliary/vl/vl_video_buffer.c | 14 ++++++++------ src/gallium/auxiliary/vl/vl_video_buffer.h | 1 - src/gallium/include/pipe/p_video_context.h | 1 + src/gallium/state_trackers/vdpau/surface.c | 7 +++++++ src/gallium/state_trackers/xorg/xvmc/surface.c | 7 +++++++ 7 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/gallium/auxiliary/vl/vl_context.c b/src/gallium/auxiliary/vl/vl_context.c index 2bc027f..ba73254 100644 --- a/src/gallium/auxiliary/vl/vl_context.c +++ b/src/gallium/auxiliary/vl/vl_context.c @@ -199,15 +199,10 @@ vl_context_create_decoder(struct pipe_video_context *context, static struct pipe_video_buffer * vl_context_create_buffer(struct pipe_video_context *context, enum pipe_format buffer_format, + enum pipe_format resource_formats[3], enum pipe_video_chroma_format chroma_format, unsigned width, unsigned height) { - const enum pipe_format resource_formats[3] = { - PIPE_FORMAT_R8_SNORM, - PIPE_FORMAT_R8_SNORM, - PIPE_FORMAT_R8_SNORM - }; - struct vl_context *ctx = (struct vl_context*)context; struct pipe_video_buffer *result; unsigned buffer_width, buffer_height; @@ -221,7 +216,7 @@ vl_context_create_buffer(struct pipe_video_context *context, result = vl_video_buffer_init(context, ctx->pipe, buffer_width, buffer_height, 1, - chroma_format, 3, + chroma_format, resource_formats, PIPE_USAGE_STATIC); if (result) // TODO move format handling into vl_video_buffer diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c index 40a1b74..ce03938 100644 --- a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c +++ b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c @@ -309,7 +309,7 @@ init_idct_buffer(struct vl_mpeg12_buffer *buffer) formats[0] = formats[1] = formats[2] = dec->idct_source_format; buffer->idct_source = vl_video_buffer_init(dec->base.context, dec->pipe, dec->base.width / 4, dec->base.height, 1, - dec->base.chroma_format, 3, + dec->base.chroma_format, formats, PIPE_USAGE_STREAM); if (!buffer->idct_source) goto error_source; @@ -318,7 +318,7 @@ init_idct_buffer(struct vl_mpeg12_buffer *buffer) buffer->idct_intermediate = vl_video_buffer_init(dec->base.context, dec->pipe, dec->base.width / dec->nr_of_idct_render_targets, dec->base.height / 4, dec->nr_of_idct_render_targets, - dec->base.chroma_format, 3, + dec->base.chroma_format, formats, PIPE_USAGE_STATIC); if (!buffer->idct_intermediate) @@ -395,7 +395,7 @@ vl_mpeg12_create_buffer(struct pipe_video_decoder *decoder) formats[0] = formats[1] = formats[2] =dec->mc_source_format; buffer->mc_source = vl_video_buffer_init(dec->base.context, dec->pipe, dec->base.width, dec->base.height, 1, - dec->base.chroma_format, 3, + dec->base.chroma_format, formats, PIPE_USAGE_STATIC); if (!buffer->mc_source) diff --git a/src/gallium/auxiliary/vl/vl_video_buffer.c b/src/gallium/auxiliary/vl/vl_video_buffer.c index b1d8fd8..dad8dd2 100644 --- a/src/gallium/auxiliary/vl/vl_video_buffer.c +++ b/src/gallium/auxiliary/vl/vl_video_buffer.c @@ -133,7 +133,6 @@ vl_video_buffer_init(struct pipe_video_context *context, struct pipe_context *pipe, unsigned width, unsigned height, unsigned depth, enum pipe_video_chroma_format chroma_format, - unsigned num_planes, const enum pipe_format resource_formats[VL_MAX_PLANES], unsigned usage) { @@ -142,7 +141,6 @@ vl_video_buffer_init(struct pipe_video_context *context, unsigned i; assert(context && pipe); - assert(num_planes > 0 && num_planes <= VL_MAX_PLANES); buffer = CALLOC_STRUCT(vl_video_buffer); @@ -150,7 +148,7 @@ vl_video_buffer_init(struct pipe_video_context *context, buffer->base.get_sampler_views = vl_video_buffer_sampler_views; buffer->base.get_surfaces = vl_video_buffer_surfaces; buffer->pipe = pipe; - buffer->num_planes = num_planes; + buffer->num_planes = 1; memset(&templ, 0, sizeof(templ)); templ.target = depth > 1 ? PIPE_TEXTURE_3D : PIPE_TEXTURE_2D; @@ -166,10 +164,12 @@ vl_video_buffer_init(struct pipe_video_context *context, if (!buffer->resources[0]) goto error; - if (num_planes == 1) { + if (resource_formats[1] == PIPE_FORMAT_NONE) { assert(chroma_format == PIPE_VIDEO_CHROMA_FORMAT_444); + assert(resource_formats[2] == PIPE_FORMAT_NONE); return &buffer->base; - } + } else + buffer->num_planes = 2; templ.format = resource_formats[1]; if (chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420) { @@ -183,8 +183,10 @@ vl_video_buffer_init(struct pipe_video_context *context, if (!buffer->resources[1]) goto error; - if (num_planes == 2) + if (resource_formats[2] == PIPE_FORMAT_NONE) return &buffer->base; + else + buffer->num_planes = 3; templ.format = resource_formats[2]; buffer->resources[2] = pipe->screen->resource_create(pipe->screen, &templ); diff --git a/src/gallium/auxiliary/vl/vl_video_buffer.h b/src/gallium/auxiliary/vl/vl_video_buffer.h index 3f462ac..f5c424c 100644 --- a/src/gallium/auxiliary/vl/vl_video_buffer.h +++ b/src/gallium/auxiliary/vl/vl_video_buffer.h @@ -56,7 +56,6 @@ vl_video_buffer_init(struct pipe_video_context *context, struct pipe_context *pipe, unsigned width, unsigned height, unsigned depth, enum pipe_video_chroma_format chroma_format, - unsigned num_planes, const enum pipe_format resource_formats[VL_MAX_PLANES], unsigned usage); #endif /* vl_ycbcr_buffer_h */ diff --git a/src/gallium/include/pipe/p_video_context.h b/src/gallium/include/pipe/p_video_context.h index 21d0581..22203b6 100644 --- a/src/gallium/include/pipe/p_video_context.h +++ b/src/gallium/include/pipe/p_video_context.h @@ -121,6 +121,7 @@ struct pipe_video_context */ struct pipe_video_buffer *(*create_buffer)(struct pipe_video_context *context, enum pipe_format buffer_format, + enum pipe_format resource_formats[3], enum pipe_video_chroma_format chroma_format, unsigned width, unsigned height); diff --git a/src/gallium/state_trackers/vdpau/surface.c b/src/gallium/state_trackers/vdpau/surface.c index f0aafae..2b1eb04 100644 --- a/src/gallium/state_trackers/vdpau/surface.c +++ b/src/gallium/state_trackers/vdpau/surface.c @@ -41,6 +41,12 @@ vlVdpVideoSurfaceCreate(VdpDevice device, VdpChromaType chroma_type, uint32_t width, uint32_t height, VdpVideoSurface *surface) { + const enum pipe_format resource_formats[3] = { + PIPE_FORMAT_R8_UNORM, + PIPE_FORMAT_R8_UNORM, + PIPE_FORMAT_R8_UNORM + }; + vlVdpSurface *p_surf; VdpStatus ret; @@ -71,6 +77,7 @@ vlVdpVideoSurfaceCreate(VdpDevice device, VdpChromaType chroma_type, p_surf->device = dev; p_surf->video_buffer = dev->context->vpipe->create_buffer(dev->context->vpipe, PIPE_FORMAT_YV12, // most common used + resource_formats, ChromaToPipe(chroma_type), width, height); diff --git a/src/gallium/state_trackers/xorg/xvmc/surface.c b/src/gallium/state_trackers/xorg/xvmc/surface.c index 68d003e..1070185 100644 --- a/src/gallium/state_trackers/xorg/xvmc/surface.c +++ b/src/gallium/state_trackers/xorg/xvmc/surface.c @@ -197,6 +197,12 @@ unmap_and_flush_surface(XvMCSurfacePrivate *surface) PUBLIC Status XvMCCreateSurface(Display *dpy, XvMCContext *context, XvMCSurface *surface) { + const enum pipe_format resource_formats[3] = { + PIPE_FORMAT_R8_SNORM, + PIPE_FORMAT_R8_SNORM, + PIPE_FORMAT_R8_SNORM + }; + XvMCContextPrivate *context_priv; struct pipe_video_context *vpipe; XvMCSurfacePrivate *surface_priv; @@ -219,6 +225,7 @@ Status XvMCCreateSurface(Display *dpy, XvMCContext *context, XvMCSurface *surfac surface_priv->decode_buffer = context_priv->decoder->create_buffer(context_priv->decoder); surface_priv->video_buffer = vpipe->create_buffer(vpipe, PIPE_FORMAT_YV12, //TODO + resource_formats, context_priv->decoder->chroma_format, context_priv->decoder->width, context_priv->decoder->height); -- 2.7.4