aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/vl/vl_video_buffer.c
diff options
context:
space:
mode:
authorChristian König <[email protected]>2011-04-24 19:20:33 +0200
committerChristian König <[email protected]>2011-04-24 19:29:34 +0200
commit3ea7e2713c836f23d59c4034385609e371a94c8d (patch)
tree523a78de983e49e031a566873703f5db2edf3d2d /src/gallium/auxiliary/vl/vl_video_buffer.c
parentb54909910c04313fb45c4e8f39091ad73ec329f3 (diff)
[g3dvl] start supporting different render target formats
Let's start with NV12, but anything else shouldn't be much of a problem any more.
Diffstat (limited to 'src/gallium/auxiliary/vl/vl_video_buffer.c')
-rw-r--r--src/gallium/auxiliary/vl/vl_video_buffer.c73
1 files changed, 53 insertions, 20 deletions
diff --git a/src/gallium/auxiliary/vl/vl_video_buffer.c b/src/gallium/auxiliary/vl/vl_video_buffer.c
index dad8dd2c9ae..dccd7e93945 100644
--- a/src/gallium/auxiliary/vl/vl_video_buffer.c
+++ b/src/gallium/auxiliary/vl/vl_video_buffer.c
@@ -38,17 +38,6 @@
#include "vl_video_buffer.h"
-static inline void
-adjust_swizzle(struct pipe_sampler_view *sv_templ)
-{
- if (util_format_get_nr_components(sv_templ->format) == 1) {
- sv_templ->swizzle_r = PIPE_SWIZZLE_RED;
- sv_templ->swizzle_g = PIPE_SWIZZLE_RED;
- sv_templ->swizzle_b = PIPE_SWIZZLE_RED;
- sv_templ->swizzle_a = PIPE_SWIZZLE_RED;
- }
-}
-
static void
vl_video_buffer_destroy(struct pipe_video_buffer *buffer)
{
@@ -59,13 +48,14 @@ vl_video_buffer_destroy(struct pipe_video_buffer *buffer)
for (i = 0; i < VL_MAX_PLANES; ++i) {
pipe_surface_reference(&buf->surfaces[i], NULL);
- pipe_sampler_view_reference(&buf->sampler_views[i], NULL);
+ pipe_sampler_view_reference(&buf->sampler_view_planes[i], NULL);
+ pipe_sampler_view_reference(&buf->sampler_view_components[i], NULL);
pipe_resource_reference(&buf->resources[i], NULL);
}
}
static struct pipe_sampler_view **
-vl_video_buffer_sampler_views(struct pipe_video_buffer *buffer)
+vl_video_buffer_sampler_view_planes(struct pipe_video_buffer *buffer)
{
struct vl_video_buffer *buf = (struct vl_video_buffer *)buffer;
struct pipe_sampler_view sv_templ;
@@ -77,21 +67,63 @@ vl_video_buffer_sampler_views(struct pipe_video_buffer *buffer)
pipe = buf->pipe;
for (i = 0; i < buf->num_planes; ++i ) {
- if (!buf->sampler_views[i]) {
+ if (!buf->sampler_view_planes[i]) {
memset(&sv_templ, 0, sizeof(sv_templ));
u_sampler_view_default_template(&sv_templ, buf->resources[i], buf->resources[i]->format);
- adjust_swizzle(&sv_templ);
- buf->sampler_views[i] = pipe->create_sampler_view(pipe, buf->resources[i], &sv_templ);
- if (!buf->sampler_views[i])
+
+ if (util_format_get_nr_components(buf->resources[i]->format) == 1)
+ sv_templ.swizzle_r = sv_templ.swizzle_g = sv_templ.swizzle_b = sv_templ.swizzle_a = PIPE_SWIZZLE_RED;
+
+ buf->sampler_view_planes[i] = pipe->create_sampler_view(pipe, buf->resources[i], &sv_templ);
+ if (!buf->sampler_view_planes[i])
goto error;
}
}
- return buf->sampler_views;
+ return buf->sampler_view_planes;
error:
for (i = 0; i < buf->num_planes; ++i )
- pipe_sampler_view_reference(&buf->sampler_views[i], NULL);
+ pipe_sampler_view_reference(&buf->sampler_view_planes[i], NULL);
+
+ return NULL;
+}
+
+static struct pipe_sampler_view **
+vl_video_buffer_sampler_view_components(struct pipe_video_buffer *buffer)
+{
+ struct vl_video_buffer *buf = (struct vl_video_buffer *)buffer;
+ struct pipe_sampler_view sv_templ;
+ struct pipe_context *pipe;
+ unsigned i, j, component;
+
+ assert(buf);
+
+ pipe = buf->pipe;
+
+ for (component = 0, i = 0; i < buf->num_planes; ++i ) {
+ unsigned nr_components = util_format_get_nr_components(buf->resources[i]->format);
+
+ for (j = 0; j < nr_components; ++j, ++component) {
+ assert(component < VL_MAX_PLANES);
+
+ if (!buf->sampler_view_components[component]) {
+ memset(&sv_templ, 0, sizeof(sv_templ));
+ u_sampler_view_default_template(&sv_templ, buf->resources[i], buf->resources[i]->format);
+ sv_templ.swizzle_r = sv_templ.swizzle_g = sv_templ.swizzle_b = PIPE_SWIZZLE_RED + j;
+ sv_templ.swizzle_a = PIPE_SWIZZLE_ONE;
+ buf->sampler_view_components[component] = pipe->create_sampler_view(pipe, buf->resources[i], &sv_templ);
+ if (!buf->sampler_view_components[component])
+ goto error;
+ }
+ }
+ }
+
+ return buf->sampler_view_components;
+
+error:
+ for (i = 0; i < VL_MAX_PLANES; ++i )
+ pipe_sampler_view_reference(&buf->sampler_view_components[i], NULL);
return NULL;
}
@@ -145,7 +177,8 @@ vl_video_buffer_init(struct pipe_video_context *context,
buffer = CALLOC_STRUCT(vl_video_buffer);
buffer->base.destroy = vl_video_buffer_destroy;
- buffer->base.get_sampler_views = vl_video_buffer_sampler_views;
+ 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.get_surfaces = vl_video_buffer_surfaces;
buffer->pipe = pipe;
buffer->num_planes = 1;