dec->pipe->set_vertex_buffers(dec->pipe, 2, buf->vertex_bufs.all);
for (i = 0; i < VL_MAX_PLANES; ++i) {
- bool first = true;
-
- vl_mc_set_surface(i == 0 ? &dec->mc_y : &dec->mc_c, surfaces[i]);
+ vl_mc_set_surface(&buf->mc[i], surfaces[i]);
for (j = 0; j < 2; ++j) {
if (sv[j] == NULL) continue;
dec->pipe->bind_vertex_elements_state(dec->pipe, dec->ves_mv[j]);
- vl_mc_render_ref(&buf->mc[i], sv[j][i], first, ne_start, ne_num, e_start, e_num);
- first = false;
+ vl_mc_render_ref(&buf->mc[i], sv[j][i], ne_start, ne_num, e_start, e_num);
}
dec->pipe->bind_blend_state(dec->pipe, dec->blend);
if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT)
vl_idct_flush(i == 0 ? &dec->idct_y : &dec->idct_c, &buf->idct[i], ne_num);
- vl_mc_render_ycbcr(&buf->mc[i], first, ne_start, ne_num);
+ vl_mc_render_ycbcr(&buf->mc[i], ne_start, ne_num);
}
dec->pipe->flush(dec->pipe, fence);
assert(r);
- r->viewport.scale[2] = 1;
- r->viewport.scale[3] = 1;
- r->viewport.translate[0] = 0;
- r->viewport.translate[1] = 0;
- r->viewport.translate[2] = 0;
- r->viewport.translate[3] = 0;
-
- r->fb_state.nr_cbufs = 1;
- r->fb_state.zsbuf = NULL;
-
memset(&sampler, 0, sizeof(sampler));
sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
buffer->renderer = renderer;
+ buffer->viewport.scale[2] = 1;
+ buffer->viewport.scale[3] = 1;
+ buffer->viewport.translate[0] = 0;
+ buffer->viewport.translate[1] = 0;
+ buffer->viewport.translate[2] = 0;
+ buffer->viewport.translate[3] = 0;
+
+ buffer->fb_state.nr_cbufs = 1;
+ buffer->fb_state.zsbuf = NULL;
+
pipe_sampler_view_reference(&buffer->source, source);
return true;
}
void
-vl_mc_set_surface(struct vl_mpeg12_mc_renderer *renderer, struct pipe_surface *surface)
+vl_mc_set_surface(struct vl_mpeg12_mc_buffer *buffer, struct pipe_surface *surface)
+{
+ assert(buffer && surface);
+
+ buffer->surface_cleared = false;
+
+ buffer->viewport.scale[0] = surface->width;
+ buffer->viewport.scale[1] = surface->height;
+
+ buffer->fb_state.width = surface->width;
+ buffer->fb_state.height = surface->height;
+ buffer->fb_state.cbufs[0] = surface;
+}
+
+static void
+prepare_pipe_4_rendering(struct vl_mpeg12_mc_buffer *buffer)
{
- assert(renderer && surface);
+ struct vl_mpeg12_mc_renderer *renderer;
+
+ assert(buffer);
- renderer->viewport.scale[0] = surface->width;
- renderer->viewport.scale[1] = surface->height;
+ renderer = buffer->renderer;
+ renderer->pipe->bind_rasterizer_state(renderer->pipe, renderer->rs_state);
- renderer->fb_state.width = surface->width;
- renderer->fb_state.height = surface->height;
- renderer->fb_state.cbufs[0] = surface;
+ if (buffer->surface_cleared)
+ renderer->pipe->bind_blend_state(renderer->pipe, renderer->blend_add);
+ else {
+ renderer->pipe->bind_blend_state(renderer->pipe, renderer->blend_clear);
+ buffer->surface_cleared = true;
+ }
+
+ renderer->pipe->set_framebuffer_state(renderer->pipe, &buffer->fb_state);
+ renderer->pipe->set_viewport_state(renderer->pipe, &buffer->viewport);
}
void
-vl_mc_render_ref(struct vl_mpeg12_mc_buffer *buffer,
- struct pipe_sampler_view *ref, bool first,
+vl_mc_render_ref(struct vl_mpeg12_mc_buffer *buffer, struct pipe_sampler_view *ref,
unsigned not_empty_start_instance, unsigned not_empty_num_instances,
unsigned empty_start_instance, unsigned empty_num_instances)
{
if (not_empty_num_instances == 0 && empty_num_instances == 0)
return;
+ prepare_pipe_4_rendering(buffer);
+
renderer = buffer->renderer;
- 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);
- renderer->pipe->bind_blend_state(renderer->pipe, first ? renderer->blend_clear : renderer->blend_add);
renderer->pipe->bind_vs_state(renderer->pipe, renderer->vs_ref);
renderer->pipe->bind_fs_state(renderer->pipe, renderer->fs_ref);
}
void
-vl_mc_render_ycbcr(struct vl_mpeg12_mc_buffer *buffer, bool first,
+vl_mc_render_ycbcr(struct vl_mpeg12_mc_buffer *buffer,
unsigned not_empty_start_instance, unsigned not_empty_num_instances)
{
struct vl_mpeg12_mc_renderer *renderer;
if (not_empty_num_instances == 0)
return;
+ prepare_pipe_4_rendering(buffer);
+
renderer = buffer->renderer;
- 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);
- renderer->pipe->bind_blend_state(renderer->pipe, first ? renderer->blend_clear : renderer->blend_add);
renderer->pipe->bind_vs_state(renderer->pipe, renderer->vs_ycbcr);
renderer->pipe->bind_fs_state(renderer->pipe, renderer->fs_ycbcr);
unsigned buffer_width;
unsigned buffer_height;
- struct pipe_viewport_state viewport;
- struct pipe_framebuffer_state fb_state;
-
void *rs_state;
void *blend_clear, *blend_add;
struct vl_mpeg12_mc_buffer
{
struct vl_mpeg12_mc_renderer *renderer;
+
+ bool surface_cleared;
+
+ struct pipe_viewport_state viewport;
+ struct pipe_framebuffer_state fb_state;
+
struct pipe_sampler_view *source;
};
void vl_mc_cleanup_buffer(struct vl_mpeg12_mc_buffer *buffer);
-void vl_mc_set_surface(struct vl_mpeg12_mc_renderer *renderer, struct pipe_surface *surface);
+void vl_mc_set_surface(struct vl_mpeg12_mc_buffer *buffer, struct pipe_surface *surface);
-void vl_mc_render_ref(struct vl_mpeg12_mc_buffer *buffer,
- struct pipe_sampler_view *ref, bool first,
+void vl_mc_render_ref(struct vl_mpeg12_mc_buffer *buffer, struct pipe_sampler_view *ref,
unsigned not_empty_start_instance, unsigned not_empty_num_instances,
unsigned empty_start_instance, unsigned empty_num_instances);
-void vl_mc_render_ycbcr(struct vl_mpeg12_mc_buffer *buffer, bool first,
+void vl_mc_render_ycbcr(struct vl_mpeg12_mc_buffer *buffer,
unsigned not_empty_start_instance, unsigned not_empty_num_instances);
#endif /* vl_mpeg12_mc_renderer_h */