{
struct ureg_program *shader;
struct ureg_src tc;
- struct ureg_src csc[4];
- struct ureg_src sampler;
+ struct ureg_src csc[3];
+ struct ureg_src sampler[3];
struct ureg_dst texel;
struct ureg_dst fragment;
unsigned i;
return false;
tc = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, 1, TGSI_INTERPOLATE_LINEAR);
- for (i = 0; i < 4; ++i)
+ for (i = 0; i < 3; ++i) {
csc[i] = ureg_DECL_constant(shader, i);
- sampler = ureg_DECL_sampler(shader, 0);
+ sampler[i] = ureg_DECL_sampler(shader, i);
+ }
texel = ureg_DECL_temporary(shader);
fragment = ureg_DECL_output(shader, TGSI_SEMANTIC_COLOR, 0);
/*
- * texel = tex(tc, sampler)
+ * texel.xyz = tex(tc, sampler[i])
* fragment = csc * texel
*/
- ureg_TEX(shader, texel, TGSI_TEXTURE_2D, tc, sampler);
+ for (i = 0; i < 3; ++i)
+ ureg_TEX(shader, ureg_writemask(texel, TGSI_WRITEMASK_X << i), TGSI_TEXTURE_2D, tc, sampler[i]);
+
+ ureg_MOV(shader, ureg_writemask(texel, TGSI_WRITEMASK_W), ureg_imm1f(shader, 1.0f));
+
for (i = 0; i < 3; ++i)
ureg_DP4(shader, ureg_writemask(fragment, TGSI_WRITEMASK_X << i), csc[i], ureg_src(texel));
+
ureg_MOV(shader, ureg_writemask(fragment, TGSI_WRITEMASK_W), ureg_imm1f(shader, 1.0f));
ureg_release_temporary(shader, texel);
}
static void draw_layers(struct vl_compositor *c,
- struct pipe_sampler_view *src_surface,
+ struct vl_ycbcr_sampler_views *src_sampler,
struct pipe_video_rect *src_rect,
struct pipe_video_rect *dst_rect)
{
unsigned i;
assert(c);
- assert(src_surface);
+ assert(src_sampler);
assert(src_rect);
assert(dst_rect);
- num_rects = gen_data(c, src_surface, src_rect, dst_rect, surfaces, frag_shaders);
+ num_rects = gen_data(c, src_sampler->y, src_rect, dst_rect, surfaces, frag_shaders);
c->pipe->bind_blend_state(c->pipe, c->blend);
for (i = 0; i < num_rects; ++i) {
c->pipe->bind_fs_state(c->pipe, frag_shaders[i]);
- c->pipe->set_fragment_sampler_views(c->pipe, surfaces[i][1] ? 2 : 1, &surfaces[i][0]);
+ if (i == 0) {
+ c->pipe->set_fragment_sampler_views(c->pipe, 3, &src_sampler->y);
+ } else {
+ c->pipe->set_fragment_sampler_views(c->pipe, surfaces[i][1] ? 2 : 1, &surfaces[i][0]);
+ }
util_draw_arrays(c->pipe, PIPE_PRIM_QUADS, i * 4, 4);
}
}
void vl_compositor_render(struct vl_compositor *compositor,
- struct pipe_sampler_view *src_surface,
- enum pipe_mpeg12_picture_type picture_type,
+ struct vl_ycbcr_sampler_views *src_sampler,
struct pipe_video_rect *src_area,
struct pipe_surface *dst_surface,
struct pipe_video_rect *dst_area,
struct pipe_fence_handle **fence)
{
- void *samplers[2];
+ void *samplers[3];
assert(compositor);
- assert(src_surface);
+ assert(src_sampler);
assert(src_area);
assert(dst_surface);
assert(dst_area);
- assert(picture_type == PIPE_MPEG12_PICTURE_TYPE_FRAME);
if (compositor->fb_state.width != dst_surface->width) {
compositor->fb_inv_size.x = 1.0f / dst_surface->width;
compositor->viewport.translate[2] = 0;
compositor->viewport.translate[3] = 0;
- samplers[0] = samplers[1] = compositor->sampler;
+ samplers[0] = samplers[1] = samplers[2] = compositor->sampler;
compositor->pipe->set_framebuffer_state(compositor->pipe, &compositor->fb_state);
compositor->pipe->set_viewport_state(compositor->pipe, &compositor->viewport);
- compositor->pipe->bind_fragment_sampler_states(compositor->pipe, 2, &samplers[0]);
+ compositor->pipe->bind_fragment_sampler_states(compositor->pipe, 3, &samplers[0]);
compositor->pipe->bind_vs_state(compositor->pipe, compositor->vertex_shader);
compositor->pipe->set_vertex_buffers(compositor->pipe, 1, &compositor->vertex_buf);
compositor->pipe->bind_vertex_elements_state(compositor->pipe, compositor->vertex_elems_state);
compositor->pipe->set_constant_buffer(compositor->pipe, PIPE_SHADER_FRAGMENT, 0, compositor->fs_const_buf);
- draw_layers(compositor, src_surface, src_area, dst_area);
+ draw_layers(compositor, src_sampler, src_area, dst_area);
assert(!compositor->dirty_layers);
compositor->pipe->flush(compositor->pipe, fence);
#include <pipe/p_state.h>
#include <pipe/p_video_state.h>
#include "vl_types.h"
+#include "vl_ycbcr_buffer.h"
struct pipe_context;
struct keymap;
unsigned num_layers);
void vl_compositor_render(struct vl_compositor *compositor,
- struct pipe_sampler_view *src_surface,
- enum pipe_mpeg12_picture_type picture_type,
+ struct vl_ycbcr_sampler_views *src_sampler,
struct pipe_video_rect *src_area,
struct pipe_surface *dst_surface,
struct pipe_video_rect *dst_area,
struct vl_mpeg12_context *ctx = (struct vl_mpeg12_context*)buf->base.context;
assert(buf && ctx);
+ vl_ycbcr_buffer_cleanup(&buf->idct_source);
+ vl_ycbcr_buffer_cleanup(&buf->idct_2_mc);
+ vl_ycbcr_buffer_cleanup(&buf->render_result);
vl_vb_cleanup(&buf->vertex_stream);
vl_idct_cleanup_buffer(&ctx->idct_y, &buf->idct_y);
vl_idct_cleanup_buffer(&ctx->idct_cb, &buf->idct_cb);
vl_idct_cleanup_buffer(&ctx->idct_cr, &buf->idct_cr);
- vl_mpeg12_mc_cleanup_buffer(&buf->mc);
- pipe_surface_reference(&buf->surface, NULL);
- pipe_sampler_view_reference(&buf->sampler_view, NULL);
+ vl_mpeg12_mc_cleanup_buffer(&buf->mc_y);
+ vl_mpeg12_mc_cleanup_buffer(&buf->mc_cb);
+ vl_mpeg12_mc_cleanup_buffer(&buf->mc_cr);
FREE(buf);
}
struct vl_mpeg12_buffer *past = (struct vl_mpeg12_buffer *)refs[0];
struct vl_mpeg12_buffer *future = (struct vl_mpeg12_buffer *)refs[1];
+ struct vl_ycbcr_surfaces *surfaces;
+ struct vl_ycbcr_sampler_views *sv_past;
+ struct vl_ycbcr_sampler_views *sv_future;
+
struct pipe_sampler_view *sv_refs[2];
unsigned ne_start, ne_num, e_start, e_num;
struct vl_mpeg12_context *ctx;
vl_idct_flush(&ctx->idct_cr, &buf->idct_cr, ne_num);
vl_idct_flush(&ctx->idct_cb, &buf->idct_cb, ne_num);
- sv_refs[0] = past ? past->sampler_view : NULL;
- sv_refs[1] = future ? future->sampler_view : NULL;
+ surfaces = vl_ycbcr_get_surfaces(&buf->render_result);
+
+ sv_past = past ? vl_ycbcr_get_sampler_views(&past->render_result) : NULL;
+ sv_future = future ? vl_ycbcr_get_sampler_views(&future->render_result) : NULL;
+
+ sv_refs[0] = sv_past ? sv_past->y : NULL;
+ sv_refs[1] = sv_future ? sv_future->y : NULL;
+
+ vl_mpeg12_mc_renderer_flush(&ctx->mc_y, &buf->mc_y, surfaces->y,
+ sv_refs, ne_start, ne_num, e_start, e_num, fence);
- vl_mpeg12_mc_renderer_flush(&ctx->mc_renderer, &buf->mc,
- buf->surface, sv_refs,
- ne_start, ne_num, e_start, e_num,
- fence);
+ sv_refs[0] = sv_past ? sv_past->cb : NULL;
+ sv_refs[1] = sv_future ? sv_future->cb : NULL;
+
+ vl_mpeg12_mc_renderer_flush(&ctx->mc_cb, &buf->mc_cb, surfaces->cb,
+ sv_refs, ne_start, ne_num, e_start, e_num, fence);
+
+ sv_refs[0] = sv_past ? sv_past->cr : NULL;
+ sv_refs[1] = sv_future ? sv_future->cr : NULL;
+
+ vl_mpeg12_mc_renderer_flush(&ctx->mc_cr, &buf->mc_cr, surfaces->cr,
+ sv_refs, ne_start, ne_num, e_start, e_num, fence);
}
static void
ctx->pipe->delete_depth_stencil_alpha_state(ctx->pipe, ctx->dsa);
vl_compositor_cleanup(&ctx->compositor);
- vl_mpeg12_mc_renderer_cleanup(&ctx->mc_renderer);
+ vl_mpeg12_mc_renderer_cleanup(&ctx->mc_y);
+ vl_mpeg12_mc_renderer_cleanup(&ctx->mc_cb);
+ vl_mpeg12_mc_renderer_cleanup(&ctx->mc_cr);
vl_idct_cleanup(&ctx->idct_y);
vl_idct_cleanup(&ctx->idct_cr);
vl_idct_cleanup(&ctx->idct_cb);
struct vl_mpeg12_context *ctx = (struct vl_mpeg12_context*)vpipe;
struct vl_mpeg12_buffer *buffer;
- struct pipe_resource res_template, *resource;
- struct pipe_surface surf_template;
- struct pipe_sampler_view sv_template;
- struct vl_ycbcr_sampler_views *idct_views;
+ struct vl_ycbcr_sampler_views *idct_views, *mc_views;
struct vl_ycbcr_surfaces *idct_surfaces;
assert(ctx);
buffer->base.unmap = vl_mpeg12_buffer_unmap;
buffer->base.flush = vl_mpeg12_buffer_flush;
- memset(&res_template, 0, sizeof(res_template));
- res_template.target = PIPE_TEXTURE_2D;
- res_template.format = ctx->decode_format;
- res_template.last_level = 0;
- res_template.width0 = ctx->buffer_width;
- res_template.height0 = ctx->buffer_height;
- res_template.depth0 = 1;
- res_template.array_size = 1;
- res_template.usage = PIPE_USAGE_DEFAULT;
- res_template.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
- res_template.flags = 0;
- resource = ctx->pipe->screen->resource_create(ctx->pipe->screen, &res_template);
- if (!resource) {
- FREE(buffer);
- return NULL;
- }
-
- memset(&surf_template, 0, sizeof(surf_template));
- surf_template.format = resource->format;
- surf_template.usage = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
- buffer->surface = ctx->pipe->create_surface(ctx->pipe, resource, &surf_template);
- if (!buffer->surface) {
- FREE(buffer);
- return NULL;
- }
-
- u_sampler_view_default_template(&sv_template, resource, resource->format);
- buffer->sampler_view = ctx->pipe->create_sampler_view(ctx->pipe, resource, &sv_template);
- if (!buffer->sampler_view) {
- FREE(buffer);
- return NULL;
- }
-
- pipe_resource_reference(&resource, NULL);
-
buffer->vertex_bufs.individual.quad.stride = ctx->quads.stride;
buffer->vertex_bufs.individual.quad.buffer_offset = ctx->quads.buffer_offset;
pipe_resource_reference(&buffer->vertex_bufs.individual.quad.buffer, ctx->quads.buffer);
return NULL;
}
+ if (!vl_ycbcr_buffer_init(&buffer->render_result, ctx->pipe,
+ ctx->buffer_width, ctx->buffer_height,
+ ctx->base.chroma_format,
+ PIPE_FORMAT_R8_SNORM,
+ PIPE_USAGE_STATIC)) {
+ FREE(buffer);
+ return NULL;
+ }
+
idct_views = vl_ycbcr_get_sampler_views(&buffer->idct_source);
idct_surfaces = vl_ycbcr_get_surfaces(&buffer->idct_2_mc);
return NULL;
}
- if(!vl_mpeg12_mc_init_buffer(&ctx->mc_renderer, &buffer->mc,
- buffer->idct_2_mc.resources.y,
- buffer->idct_2_mc.resources.cb,
- buffer->idct_2_mc.resources.cr)) {
+ mc_views = vl_ycbcr_get_sampler_views(&buffer->idct_2_mc);
+
+ if(!vl_mpeg12_mc_init_buffer(&ctx->mc_y, &buffer->mc_y, mc_views->y)) {
+ FREE(buffer);
+ return NULL;
+ }
+
+ if(!vl_mpeg12_mc_init_buffer(&ctx->mc_cb, &buffer->mc_cb, mc_views->cb)) {
+ FREE(buffer);
+ return NULL;
+ }
+
+ if(!vl_mpeg12_mc_init_buffer(&ctx->mc_cr, &buffer->mc_cr, mc_views->cr)) {
FREE(buffer);
return NULL;
}
{
struct vl_mpeg12_context *ctx = (struct vl_mpeg12_context*)vpipe;
struct vl_mpeg12_buffer *buf = (struct vl_mpeg12_buffer*)src_surface;
+ struct vl_ycbcr_sampler_views *sampler_views;
assert(vpipe);
assert(src_surface);
assert(dst_surface);
assert(dst_area);
- vl_compositor_render(&ctx->compositor, buf->sampler_view,
- picture_type, src_area,
+ sampler_views = vl_ycbcr_get_sampler_views(&buf->render_result);
+
+ vl_compositor_render(&ctx->compositor, sampler_views, src_area,
dst_surface, dst_area, fence);
}
chroma_blocks_y = 2;
}
- if(!vl_idct_init(&ctx->idct_cr, ctx->pipe, chroma_width, chroma_height,
- chroma_blocks_x, chroma_blocks_y, TGSI_SWIZZLE_Z, idct_matrix))
- return false;
-
if(!vl_idct_init(&ctx->idct_cb, ctx->pipe, chroma_width, chroma_height,
chroma_blocks_x, chroma_blocks_y, TGSI_SWIZZLE_Y, idct_matrix))
return false;
+ if(!vl_idct_init(&ctx->idct_cr, ctx->pipe, chroma_width, chroma_height,
+ chroma_blocks_x, chroma_blocks_y, TGSI_SWIZZLE_Z, idct_matrix))
+ return false;
+
return true;
}
return NULL;
}
- if (!vl_mpeg12_mc_renderer_init(&ctx->mc_renderer, ctx->pipe,
+ if (!vl_mpeg12_mc_renderer_init(&ctx->mc_y, ctx->pipe,
+ ctx->buffer_width, ctx->buffer_height,
+ chroma_format, TGSI_SWIZZLE_X)) {
+ vl_idct_cleanup(&ctx->idct_y);
+ vl_idct_cleanup(&ctx->idct_cr);
+ vl_idct_cleanup(&ctx->idct_cb);
+ ctx->pipe->destroy(ctx->pipe);
+ FREE(ctx);
+ return NULL;
+ }
+
+ if (!vl_mpeg12_mc_renderer_init(&ctx->mc_cb, ctx->pipe,
+ ctx->buffer_width, ctx->buffer_height,
+ chroma_format, TGSI_SWIZZLE_Y)) {
+ vl_idct_cleanup(&ctx->idct_y);
+ vl_idct_cleanup(&ctx->idct_cr);
+ vl_idct_cleanup(&ctx->idct_cb);
+ ctx->pipe->destroy(ctx->pipe);
+ FREE(ctx);
+ return NULL;
+ }
+
+ if (!vl_mpeg12_mc_renderer_init(&ctx->mc_cr, ctx->pipe,
ctx->buffer_width, ctx->buffer_height,
- chroma_format)) {
+ chroma_format, TGSI_SWIZZLE_Z)) {
vl_idct_cleanup(&ctx->idct_y);
vl_idct_cleanup(&ctx->idct_cr);
vl_idct_cleanup(&ctx->idct_cb);
vl_idct_cleanup(&ctx->idct_y);
vl_idct_cleanup(&ctx->idct_cr);
vl_idct_cleanup(&ctx->idct_cb);
- vl_mpeg12_mc_renderer_cleanup(&ctx->mc_renderer);
+ vl_mpeg12_mc_renderer_cleanup(&ctx->mc_y);
+ vl_mpeg12_mc_renderer_cleanup(&ctx->mc_cb);
+ vl_mpeg12_mc_renderer_cleanup(&ctx->mc_cr);
ctx->pipe->destroy(ctx->pipe);
FREE(ctx);
return NULL;
vl_idct_cleanup(&ctx->idct_y);
vl_idct_cleanup(&ctx->idct_cr);
vl_idct_cleanup(&ctx->idct_cb);
- vl_mpeg12_mc_renderer_cleanup(&ctx->mc_renderer);
+ vl_mpeg12_mc_renderer_cleanup(&ctx->mc_y);
+ vl_mpeg12_mc_renderer_cleanup(&ctx->mc_cb);
+ vl_mpeg12_mc_renderer_cleanup(&ctx->mc_cr);
vl_compositor_cleanup(&ctx->compositor);
ctx->pipe->destroy(ctx->pipe);
FREE(ctx);
unsigned vertex_buffer_size;
void *vertex_elems_state;
- struct vl_idct idct_y, idct_cr, idct_cb;
- struct vl_mpeg12_mc_renderer mc_renderer;
+ struct vl_idct idct_y, idct_cb, idct_cr;
+ struct vl_mpeg12_mc_renderer mc_y, mc_cb, mc_cr;
struct vl_compositor compositor;
void *rast;
struct vl_ycbcr_buffer idct_source;
struct vl_ycbcr_buffer idct_2_mc;
-
- struct pipe_surface *surface;
- struct pipe_sampler_view *sampler_view;
+ struct vl_ycbcr_buffer render_result;
struct vl_vertex_buffer vertex_stream;
} vertex_bufs;
struct vl_idct_buffer idct_y, idct_cb, idct_cr;
-
- struct vl_mpeg12_mc_buffer mc;
+ struct vl_mpeg12_mc_buffer mc_y, mc_cb, mc_cr;
};
/* drivers can call this function in their pipe_video_context constructors and pass it
}
static struct ureg_dst
-fetch_ycbcr(struct vl_mpeg12_mc_renderer *r, struct ureg_program *shader, struct ureg_dst field)
+fetch_ycbcr(struct vl_mpeg12_mc_renderer *r, struct ureg_program *shader, struct ureg_dst field, unsigned color_swizzle)
{
- struct ureg_src tc[3], sampler[3], eb[2];
+ struct ureg_src tc[3], sampler, eb[2];
struct ureg_dst texel, t_tc, t_eb_info;
- unsigned i, label;
+ unsigned label;
texel = ureg_DECL_temporary(shader);
t_tc = ureg_DECL_temporary(shader);
eb[0] = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_EB_0, TGSI_INTERPOLATE_CONSTANT);
eb[1] = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_EB_1, TGSI_INTERPOLATE_CONSTANT);
- for (i = 0; i < 3; ++i) {
- sampler[i] = ureg_DECL_sampler(shader, i);
- }
+ //for (i = 0; i < 3; ++i) {
+ // sampler[i] = ureg_DECL_sampler(shader, i);
+ //}
+ sampler = ureg_DECL_sampler(shader, 0);
/*
* texel.y = tex(field.y ? tc[1] : tc[0], sampler[0])
ureg_SLT(shader, ureg_writemask(t_eb_info, TGSI_WRITEMASK_XYZ), ureg_src(t_eb_info), ureg_imm1f(shader, 0.5f));
ureg_MOV(shader, ureg_writemask(texel, TGSI_WRITEMASK_XYZ), ureg_imm1f(shader, 0.0f));
- for (i = 0; i < 3; ++i) {
- ureg_IF(shader, ureg_scalar(ureg_src(t_eb_info), TGSI_SWIZZLE_X + i), &label);
+ ureg_IF(shader, ureg_scalar(ureg_src(t_eb_info), color_swizzle), &label);
- /* Nouveau can't writemask tex dst regs (yet?), so this won't work anymore on nvidia hardware */
- if(i==0 || r->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_444) {
- ureg_TEX(shader, ureg_writemask(texel, TGSI_WRITEMASK_X << i), TGSI_TEXTURE_3D, ureg_src(t_tc), sampler[i]);
- } else {
- ureg_TEX(shader, ureg_writemask(texel, TGSI_WRITEMASK_X << i), TGSI_TEXTURE_3D, tc[2], sampler[i]);
- }
+ if(color_swizzle==TGSI_SWIZZLE_X || r->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_444) {
+ ureg_TEX(shader, texel, TGSI_TEXTURE_3D, ureg_src(t_tc), sampler);
+ } else {
+ ureg_TEX(shader, texel, TGSI_TEXTURE_3D, tc[2], sampler);
+ }
- ureg_fixup_label(shader, label, ureg_get_instruction_number(shader));
- ureg_ENDIF(shader);
- }
+ ureg_fixup_label(shader, label, ureg_get_instruction_number(shader));
+ ureg_ENDIF(shader);
ureg_release_temporary(shader, t_tc);
ureg_release_temporary(shader, t_eb_info);
tc[i] = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_MV0 + i, TGSI_INTERPOLATE_LINEAR);
for (i = 0; i < 2; ++i) {
- sampler[i] = ureg_DECL_sampler(shader, i + 3);
+ sampler[i] = ureg_DECL_sampler(shader, i + 1);
ref[i] = ureg_DECL_temporary(shader);
}
result = ureg_DECL_temporary(shader);
- ureg_MOV(shader, ureg_writemask(result, TGSI_WRITEMASK_XYZ), ureg_imm1f(shader, 0.5f));
+ ureg_MOV(shader, result, ureg_imm1f(shader, 0.5f));
ureg_IF(shader, ureg_scalar(info, TGSI_SWIZZLE_X), &intra_label);
/*
ureg_TEX(shader, ref[0], TGSI_TEXTURE_2D, ureg_src(ref[0]), sampler[0]);
ureg_TEX(shader, ref[1], TGSI_TEXTURE_2D, ureg_src(ref[1]), sampler[1]);
- ureg_LRP(shader, ureg_writemask(result, TGSI_WRITEMASK_XYZ),
+ ureg_LRP(shader, result,
ureg_scalar(info, TGSI_SWIZZLE_Y),
ureg_src(ref[1]), ureg_src(ref[0]));
}
static void *
-create_frag_shader(struct vl_mpeg12_mc_renderer *r)
+create_frag_shader(struct vl_mpeg12_mc_renderer *r, unsigned color_swizzle)
{
struct ureg_program *shader;
struct ureg_dst result;
fragment = ureg_DECL_output(shader, TGSI_SEMANTIC_COLOR, 0);
field = calc_field(shader);
- texel = fetch_ycbcr(r, shader, field);
+ texel = fetch_ycbcr(r, shader, field, color_swizzle);
result = fetch_ref(shader, field);
- ureg_ADD(shader, ureg_writemask(fragment, TGSI_WRITEMASK_XYZ), ureg_src(texel), ureg_src(result));
+ ureg_ADD(shader, fragment, ureg_src(texel), ureg_src(result));
ureg_release_temporary(shader, field);
ureg_release_temporary(shader, texel);
{
struct pipe_sampler_state sampler;
struct pipe_rasterizer_state rs_state;
- unsigned filters[5];
+ unsigned filters[3];
unsigned i;
assert(r);
- r->viewport.scale[0] = r->buffer_width;
- r->viewport.scale[1] = r->buffer_height;
r->viewport.scale[2] = 1;
r->viewport.scale[3] = 1;
r->viewport.translate[0] = 0;
r->viewport.translate[2] = 0;
r->viewport.translate[3] = 0;
- r->fb_state.width = r->buffer_width;
- r->fb_state.height = r->buffer_height;
r->fb_state.nr_cbufs = 1;
r->fb_state.zsbuf = NULL;
- /* Luma filter */
+ /* source filter */
filters[0] = PIPE_TEX_FILTER_NEAREST;
- /* Chroma filters */
- if (r->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_444 || true) { //TODO
- filters[1] = PIPE_TEX_FILTER_NEAREST;
- filters[2] = PIPE_TEX_FILTER_NEAREST;
- }
- else {
- filters[1] = PIPE_TEX_FILTER_LINEAR;
- filters[2] = PIPE_TEX_FILTER_LINEAR;
- }
+
/* Fwd, bkwd ref filters */
- filters[3] = PIPE_TEX_FILTER_LINEAR;
- filters[4] = PIPE_TEX_FILTER_LINEAR;
+ filters[1] = PIPE_TEX_FILTER_LINEAR;
+ filters[2] = PIPE_TEX_FILTER_LINEAR;
- for (i = 0; i < 5; ++i) {
+ for (i = 0; i < 3; ++i) {
memset(&sampler, 0, sizeof(sampler));
sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
assert(r);
- for (i = 0; i < 5; ++i)
+ for (i = 0; i < 3; ++i)
r->pipe->delete_sampler_state(r->pipe, r->samplers.all[i]);
r->pipe->delete_rasterizer_state(r->pipe, r->rs_state);
struct pipe_context *pipe,
unsigned buffer_width,
unsigned buffer_height,
- enum pipe_video_chroma_format chroma_format)
+ enum pipe_video_chroma_format chroma_format,
+ unsigned color_swizzle)
{
struct pipe_resource tex_templ, *tex_dummy;
struct pipe_sampler_view sampler_view;
if (!renderer->vs)
goto error_vs_shaders;
- renderer->fs = create_frag_shader(renderer);
+ renderer->fs = create_frag_shader(renderer, color_swizzle);
if (!renderer->fs)
goto error_fs_shaders;
bool
vl_mpeg12_mc_init_buffer(struct vl_mpeg12_mc_renderer *renderer, struct vl_mpeg12_mc_buffer *buffer,
- struct pipe_resource *y, struct pipe_resource *cb, struct pipe_resource *cr)
+ struct pipe_sampler_view *source)
{
- struct pipe_sampler_view sampler_view;
- struct pipe_resource *res[3];
-
- unsigned i;
-
assert(renderer && buffer);
- assert(y && cb && cr);
+ assert(source);
- res[0] = y;
- res[1] = cb;
- res[2] = cr;
-
- for (i = 0; i < 3; ++i) {
- memset(&sampler_view, 0, sizeof(sampler_view));
- u_sampler_view_default_template(&sampler_view, res[i], res[i]->format);
- sampler_view.swizzle_r = i == 0 ? PIPE_SWIZZLE_RED : PIPE_SWIZZLE_ZERO;
- sampler_view.swizzle_g = i == 1 ? PIPE_SWIZZLE_RED : PIPE_SWIZZLE_ZERO;
- sampler_view.swizzle_b = i == 2 ? PIPE_SWIZZLE_RED : PIPE_SWIZZLE_ZERO;
- sampler_view.swizzle_a = PIPE_SWIZZLE_ONE;
- buffer->sampler_views.all[i] = renderer->pipe->create_sampler_view(
- renderer->pipe, res[i], &sampler_view);
- if (!buffer->sampler_views.all[i])
- goto error_samplers;
- }
+ pipe_sampler_view_reference(&buffer->sampler_views.individual.source, source);
return true;
-
-error_samplers:
- for (i = 0; i < 3; ++i)
- pipe_sampler_view_reference(&buffer->sampler_views.all[i], NULL);
-
- return false;
}
void
assert(buffer);
- for (i = 0; i < 5; ++i)
+ for (i = 0; i < 3; ++i)
pipe_sampler_view_reference(&buffer->sampler_views.all[i], NULL);
}
if (not_empty_num_instances == 0 && empty_num_instances == 0)
return;
+ renderer->viewport.scale[0] = surface->width;
+ renderer->viewport.scale[1] = surface->height;
+
+ renderer->fb_state.width = surface->width;
+ renderer->fb_state.height = surface->height;
renderer->fb_state.cbufs[0] = surface;
+
+
renderer->pipe->bind_rasterizer_state(renderer->pipe, renderer->rs_state);
renderer->pipe->set_framebuffer_state(renderer->pipe, &renderer->fb_state);
renderer->pipe->set_viewport_state(renderer->pipe, &renderer->viewport);
pipe_sampler_view_reference(&buffer->sampler_views.individual.ref[1],
ref[1] ? ref[1] : renderer->dummy);
- renderer->pipe->set_fragment_sampler_views(renderer->pipe, 5, buffer->sampler_views.all);
- renderer->pipe->bind_fragment_sampler_states(renderer->pipe, 5, renderer->samplers.all);
+ renderer->pipe->set_fragment_sampler_views(renderer->pipe, 3, buffer->sampler_views.all);
+ renderer->pipe->bind_fragment_sampler_states(renderer->pipe, 3, renderer->samplers.all);
renderer->pipe->bind_vs_state(renderer->pipe, renderer->vs);
renderer->pipe->bind_fs_state(renderer->pipe, renderer->fs);
union
{
- void *all[5];
- struct { void *y, *cb, *cr, *ref[2]; } individual;
+ void *all[3];
+ struct { void *source, *ref[2]; } individual;
} samplers;
struct pipe_sampler_view *dummy;
{
union
{
- struct pipe_sampler_view *all[5];
- struct { struct pipe_sampler_view *y, *cb, *cr, *ref[2]; } individual;
+ struct pipe_sampler_view *all[3];
+ struct { struct pipe_sampler_view *source, *ref[2]; } individual;
} sampler_views;
};
struct pipe_context *pipe,
unsigned picture_width,
unsigned picture_height,
- enum pipe_video_chroma_format chroma_format);
+ enum pipe_video_chroma_format chroma_format,
+ unsigned color_swizzle);
void vl_mpeg12_mc_renderer_cleanup(struct vl_mpeg12_mc_renderer *renderer);
bool vl_mpeg12_mc_init_buffer(struct vl_mpeg12_mc_renderer *renderer, struct vl_mpeg12_mc_buffer *buffer,
- struct pipe_resource *y, struct pipe_resource *cb, struct pipe_resource *cr);
+ struct pipe_sampler_view *source);
void vl_mpeg12_mc_cleanup_buffer(struct vl_mpeg12_mc_buffer *buffer);
pipe = buffer->pipe;
+ memset(&sv_templ, 0, sizeof(sv_templ));
+ u_sampler_view_default_template(&sv_templ, buffer->resources.y, buffer->resources.y->format);
+
+ // Workaround
+ if (util_format_get_nr_components(buffer->resources.y->format) == 1) {
+ sv_templ.swizzle_r = PIPE_SWIZZLE_RED;
+ sv_templ.swizzle_g = PIPE_SWIZZLE_RED;
+ sv_templ.swizzle_b = PIPE_SWIZZLE_RED;
+ }
+
if (!buffer->sampler_views.y) {
- memset(&sv_templ, 0, sizeof(sv_templ));
- u_sampler_view_default_template(&sv_templ, buffer->resources.y, buffer->resources.y->format);
buffer->sampler_views.y = pipe->create_sampler_view(pipe, buffer->resources.y, &sv_templ);
if (!buffer->sampler_views.y)
goto error;
}
if (!buffer->sampler_views.cb) {
- memset(&sv_templ, 0, sizeof(sv_templ));
- u_sampler_view_default_template(&sv_templ, buffer->resources.cb, buffer->resources.cb->format);
buffer->sampler_views.cb = pipe->create_sampler_view(pipe, buffer->resources.cb, &sv_templ);
if (!buffer->sampler_views.cb)
goto error;
}
if (!buffer->sampler_views.cr) {
- memset(&sv_templ, 0, sizeof(sv_templ));
- u_sampler_view_default_template(&sv_templ, buffer->resources.cr, buffer->resources.cr->format);
buffer->sampler_views.cr = pipe->create_sampler_view(pipe, buffer->resources.cr, &sv_templ);
if (!buffer->sampler_views.cr)
goto error;