1 /**************************************************************************
3 * Copyright 2010 Thomas Balling Sørensen.
4 * Copyright 2011 Christian König.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sub license, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
15 * The above copyright notice and this permission notice (including the
16 * next paragraph) shall be included in all copies or substantial portions
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
22 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
23 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 **************************************************************************/
29 #include <vdpau/vdpau.h>
31 #include <util/u_debug.h>
32 #include <util/u_memory.h>
34 #include "vdpau_private.h"
37 vlVdpOutputSurfaceCreate(VdpDevice device
,
38 VdpRGBAFormat rgba_format
,
39 uint32_t width
, uint32_t height
,
40 VdpOutputSurface
*surface
)
42 struct pipe_video_context
*context
;
43 struct pipe_resource res_tmpl
, *res
;
44 struct pipe_sampler_view sv_templ
;
45 struct pipe_surface surf_templ
;
47 vlVdpOutputSurface
*vlsurface
= NULL
;
49 debug_printf("[VDPAU] Creating output surface\n");
50 if (!(width
&& height
))
51 return VDP_STATUS_INVALID_SIZE
;
53 vlVdpDevice
*dev
= vlGetDataHTAB(device
);
55 return VDP_STATUS_INVALID_HANDLE
;
57 context
= dev
->context
->vpipe
;
59 return VDP_STATUS_INVALID_HANDLE
;
61 vlsurface
= CALLOC(1, sizeof(vlVdpOutputSurface
));
63 return VDP_STATUS_RESOURCES
;
65 memset(&res_tmpl
, 0, sizeof(res_tmpl
));
67 res_tmpl
.target
= PIPE_TEXTURE_2D
;
68 res_tmpl
.format
= FormatRGBAToPipe(rgba_format
);
69 res_tmpl
.width0
= width
;
70 res_tmpl
.height0
= height
;
72 res_tmpl
.array_size
= 1;
73 res_tmpl
.bind
= PIPE_BIND_SAMPLER_VIEW
| PIPE_BIND_RENDER_TARGET
;
74 res_tmpl
.usage
= PIPE_USAGE_STATIC
;
76 res
= context
->screen
->resource_create(context
->screen
, &res_tmpl
);
79 return VDP_STATUS_ERROR
;
82 memset(&sv_templ
, 0, sizeof(sv_templ
));
83 u_sampler_view_default_template(&sv_templ
, res
, res
->format
);
84 vlsurface
->sampler_view
= context
->create_sampler_view(context
, res
, &sv_templ
);
85 if (!vlsurface
->sampler_view
) {
87 return VDP_STATUS_ERROR
;
90 memset(&surf_templ
, 0, sizeof(surf_templ
));
91 surf_templ
.format
= res
->format
;
92 surf_templ
.usage
= PIPE_BIND_SAMPLER_VIEW
| PIPE_BIND_RENDER_TARGET
;
93 vlsurface
->surface
= context
->create_surface(context
, res
, &surf_templ
);
94 if (!vlsurface
->surface
) {
96 return VDP_STATUS_ERROR
;
99 *surface
= vlAddDataHTAB(vlsurface
);
102 return VDP_STATUS_ERROR
;
105 return VDP_STATUS_OK
;
109 vlVdpOutputSurfaceDestroy(VdpOutputSurface surface
)
111 return VDP_STATUS_NO_IMPLEMENTATION
;
115 vlVdpOutputSurfaceGetParameters(VdpOutputSurface surface
,
116 VdpRGBAFormat
*rgba_format
,
117 uint32_t *width
, uint32_t *height
)
119 return VDP_STATUS_NO_IMPLEMENTATION
;
123 vlVdpOutputSurfaceGetBitsNative(VdpOutputSurface surface
,
124 VdpRect
const *source_rect
,
125 void *const *destination_data
,
126 uint32_t const *destination_pitches
)
128 return VDP_STATUS_NO_IMPLEMENTATION
;
132 vlVdpOutputSurfacePutBitsNative(VdpOutputSurface surface
,
133 void const *const *source_data
,
134 uint32_t const *source_pitches
,
135 VdpRect
const *destination_rect
)
137 return VDP_STATUS_NO_IMPLEMENTATION
;
141 vlVdpOutputSurfacePutBitsIndexed(VdpOutputSurface surface
,
142 VdpIndexedFormat source_indexed_format
,
143 void const *const *source_data
,
144 uint32_t const *source_pitch
,
145 VdpRect
const *destination_rect
,
146 VdpColorTableFormat color_table_format
,
147 void const *color_table
)
149 return VDP_STATUS_NO_IMPLEMENTATION
;
153 vlVdpOutputSurfacePutBitsYCbCr(VdpOutputSurface surface
,
154 VdpYCbCrFormat source_ycbcr_format
,
155 void const *const *source_data
,
156 uint32_t const *source_pitches
,
157 VdpRect
const *destination_rect
,
158 VdpCSCMatrix
const *csc_matrix
)
160 return VDP_STATUS_NO_IMPLEMENTATION
;
164 vlVdpOutputSurfaceRenderOutputSurface(VdpOutputSurface destination_surface
,
165 VdpRect
const *destination_rect
,
166 VdpOutputSurface source_surface
,
167 VdpRect
const *source_rect
,
168 VdpColor
const *colors
,
169 VdpOutputSurfaceRenderBlendState
const *blend_state
,
172 return VDP_STATUS_NO_IMPLEMENTATION
;
176 vlVdpOutputSurfaceRenderBitmapSurface(VdpOutputSurface destination_surface
,
177 VdpRect
const *destination_rect
,
178 VdpBitmapSurface source_surface
,
179 VdpRect
const *source_rect
,
180 VdpColor
const *colors
,
181 VdpOutputSurfaceRenderBlendState
const *blend_state
,
184 return VDP_STATUS_NO_IMPLEMENTATION
;