};
const enum pipe_format *
-vl_video_buffer_formats(struct pipe_context *pipe, enum pipe_format format)
+vl_video_buffer_formats(struct pipe_screen *screen, enum pipe_format format)
{
switch(format) {
case PIPE_FORMAT_YV12:
}
}
+boolean
+vl_video_buffer_is_format_supported(struct pipe_screen *screen,
+ enum pipe_format format,
+ enum pipe_video_profile profile)
+{
+ const enum pipe_format *resource_formats;
+ unsigned i;
+
+ resource_formats = vl_video_buffer_formats(screen, format);
+ if (!resource_formats)
+ return false;
+
+ for(i = 0; i < VL_MAX_PLANES; ++i) {
+ if (!resource_formats[i])
+ continue;
+
+ if (!screen->is_format_supported(screen, resource_formats[i], PIPE_TEXTURE_2D, 0, PIPE_USAGE_STATIC))
+ return false;
+ }
+
+ 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)
{
pipe_sampler_view_reference(&buf->sampler_view_components[i], NULL);
pipe_resource_reference(&buf->resources[i], NULL);
}
+
+ FREE(buffer);
}
static struct pipe_sampler_view **
assert(buf);
- pipe = buf->pipe;
+ pipe = buf->base.context;
for (i = 0; i < buf->num_planes; ++i ) {
if (!buf->sampler_view_planes[i]) {
assert(buf);
- pipe = buf->pipe;
+ pipe = buf->base.context;
for (component = 0, i = 0; i < buf->num_planes; ++i ) {
unsigned nr_components = util_format_get_nr_components(buf->resources[i]->format);
assert(buf);
- pipe = buf->pipe;
+ pipe = buf->base.context;
for (i = 0; i < buf->num_planes; ++i ) {
if (!buf->surfaces[i]) {
}
struct pipe_video_buffer *
-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,
- const enum pipe_format resource_formats[VL_MAX_PLANES],
- unsigned usage)
+vl_video_buffer_create(struct pipe_context *pipe,
+ enum pipe_format buffer_format,
+ enum pipe_video_chroma_format chroma_format,
+ unsigned width, unsigned height)
+{
+ const enum pipe_format *resource_formats;
+ struct pipe_video_buffer *result;
+ unsigned buffer_width, buffer_height;
+ bool pot_buffers;
+
+ assert(pipe);
+ assert(width > 0 && height > 0);
+
+ pot_buffers = !pipe->screen->get_video_param
+ (
+ pipe->screen,
+ PIPE_VIDEO_PROFILE_UNKNOWN,
+ PIPE_VIDEO_CAP_NPOT_TEXTURES
+ );
+
+ resource_formats = vl_video_buffer_formats(pipe->screen, buffer_format);
+ if (!resource_formats)
+ return NULL;
+
+ buffer_width = pot_buffers ? util_next_power_of_two(width) : align(width, MACROBLOCK_WIDTH);
+ buffer_height = pot_buffers ? util_next_power_of_two(height) : align(height, MACROBLOCK_HEIGHT);
+
+ result = vl_video_buffer_create_ex
+ (
+ pipe, buffer_width, buffer_height, 1,
+ chroma_format, resource_formats, PIPE_USAGE_STATIC
+ );
+ if (result)
+ result->buffer_format = buffer_format;
+
+ return result;
+}
+
+struct pipe_video_buffer *
+vl_video_buffer_create_ex(struct pipe_context *pipe,
+ unsigned width, unsigned height, unsigned depth,
+ enum pipe_video_chroma_format chroma_format,
+ const enum pipe_format resource_formats[VL_MAX_PLANES],
+ unsigned usage)
{
struct vl_video_buffer *buffer;
struct pipe_resource templ;
unsigned i;
- assert(context && pipe);
+ assert(pipe);
buffer = CALLOC_STRUCT(vl_video_buffer);
+ buffer->base.context = pipe;
buffer->base.destroy = vl_video_buffer_destroy;
buffer->base.get_sampler_view_planes = vl_video_buffer_sampler_view_planes;
buffer->base.get_sampler_view_components = vl_video_buffer_sampler_view_components;
buffer->base.chroma_format = chroma_format;
buffer->base.width = width;
buffer->base.height = height;
- buffer->pipe = pipe;
buffer->num_planes = 1;
memset(&templ, 0, sizeof(templ));