mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-20 04:48:07 +02:00
[g3dvl] make resource format selection a public interface
This commit is contained in:
parent
ccc80d2c09
commit
4f3fb1586a
7 changed files with 28 additions and 17 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue