Fixing uninitialized areas in SwapBuffers mode.
Signed-off-by: Christian König <deathsimple@vodafone.de>
goto no_compositor;
}
- vl_compositor_reset_dirty_area(&pq->dirty_area);
-
*presentation_queue = vlAddDataHTAB(pq);
if (*presentation_queue == 0) {
ret = VDP_STATUS_ERROR;
struct pipe_resource *tex;
struct pipe_surface surf_templ, *surf_draw;
struct pipe_video_rect src_rect, dst_clip;
+ struct u_rect *dirty_area;
pq = vlGetDataHTAB(presentation_queue);
if (!pq)
if (!tex)
return VDP_STATUS_INVALID_HANDLE;
+ dirty_area = vl_screen_get_dirty_area(pq->device->vscreen);
+
memset(&surf_templ, 0, sizeof(surf_templ));
surf_templ.format = tex->format;
surf_templ.usage = PIPE_BIND_RENDER_TARGET;
vl_compositor_clear_layers(&pq->compositor);
vl_compositor_set_rgba_layer(&pq->compositor, 0, surf->sampler_view, &src_rect, NULL);
- vl_compositor_render(&pq->compositor, surf_draw, NULL, &dst_clip, &pq->dirty_area);
+ vl_compositor_render(&pq->compositor, surf_draw, NULL, &dst_clip, dirty_area);
pipe->screen->flush_frontbuffer
(
vlVdpDevice *device;
Drawable drawable;
struct vl_compositor compositor;
- struct u_rect dirty_area;
} vlVdpPresentationQueue;
typedef struct
struct pipe_resource *tex;
struct pipe_surface surf_templ, *surf;
+ struct u_rect *dirty_area;
XVMC_MSG(XVMC_TRACE, "[XvMC] Displaying surface %p.\n", surface);
compositor = &context_priv->compositor;
tex = vl_screen_texture_from_drawable(context_priv->vscreen, drawable);
+ dirty_area = vl_screen_get_dirty_area(context_priv->vscreen);
+
memset(&surf_templ, 0, sizeof(surf_templ));
surf_templ.format = tex->format;
surf_templ.usage = PIPE_BIND_RENDER_TARGET;
// Workaround for r600g, there seems to be a bug in the fence refcounting code
pipe->screen->fence_reference(pipe->screen, &surface_priv->fence, NULL);
- vl_compositor_render(compositor, surf, &dst_rect, NULL, &context_priv->dirty_area);
+ vl_compositor_render(compositor, surf, &dst_rect, NULL, dirty_area);
pipe->flush(pipe, &surface_priv->fence);
#include "util/u_debug.h"
#include "util/u_math.h"
-#include "util/u_rect.h"
#include "vl/vl_csc.h"
#include "vl/vl_compositor.h"
unsigned short subpicture_max_width;
unsigned short subpicture_max_height;
- struct u_rect dirty_area;
-
} XvMCContextPrivate;
typedef struct
#include "util/u_hash_table.h"
#include "util/u_inlines.h"
+#include "vl/vl_compositor.h"
#include "vl_winsys.h"
struct vl_dri_screen
xcb_connection_t *conn;
xcb_drawable_t drawable;
+ unsigned width, height;
+
+ bool current_buffer;
+ uint32_t buffer_names[2];
+ struct u_rect dirty_areas[2];
+
bool flushed;
xcb_dri2_swap_buffers_cookie_t swap_cookie;
xcb_dri2_wait_sbc_cookie_t wait_cookie;
scrn->swap_cookie = xcb_dri2_swap_buffers_unchecked(scrn->conn, scrn->drawable, 0, 0, 0, 0, 0, 0);
scrn->wait_cookie = xcb_dri2_wait_sbc_unchecked(scrn->conn, scrn->drawable, 0, 0);
scrn->buffers_cookie = xcb_dri2_get_buffers_unchecked(scrn->conn, scrn->drawable, 1, 1, attachments);
+
+ scrn->current_buffer = !scrn->current_buffer;
}
static void
if (scrn->drawable != drawable) {
vl_dri2_destroy_drawable(scrn);
xcb_dri2_create_drawable(scrn->conn, drawable);
+ scrn->current_buffer = false;
+ vl_compositor_reset_dirty_area(&scrn->dirty_areas[0]);
+ vl_compositor_reset_dirty_area(&scrn->dirty_areas[1]);
scrn->drawable = drawable;
if (scrn->flushed) {
assert(reply->count == 1);
+ if (reply->width != scrn->width || reply->height != scrn->height) {
+ vl_compositor_reset_dirty_area(&scrn->dirty_areas[0]);
+ vl_compositor_reset_dirty_area(&scrn->dirty_areas[1]);
+ scrn->width = reply->width;
+ scrn->height = reply->height;
+
+ } else if (buffers[0].name != scrn->buffer_names[scrn->current_buffer]) {
+ vl_compositor_reset_dirty_area(&scrn->dirty_areas[scrn->current_buffer]);
+ scrn->buffer_names[scrn->current_buffer] = buffers[0].name;
+ }
+
memset(&dri2_front_handle, 0, sizeof(dri2_front_handle));
dri2_front_handle.type = DRM_API_HANDLE_TYPE_SHARED;
dri2_front_handle.handle = buffers[0].name;
return tex;
}
+struct u_rect *
+vl_screen_get_dirty_area(struct vl_screen *vscreen)
+{
+ struct vl_dri_screen *scrn = (struct vl_dri_screen*)vscreen;
+ assert(scrn);
+ return &scrn->dirty_areas[scrn->current_buffer];
+}
+
void*
vl_screen_get_private(struct vl_screen *vscreen)
{
goto free_screen;
scrn->base.pscreen->flush_frontbuffer = vl_dri2_flush_frontbuffer;
+ vl_compositor_reset_dirty_area(&scrn->dirty_areas[0]);
+ vl_compositor_reset_dirty_area(&scrn->dirty_areas[1]);
free(dri2_query);
free(connect);
struct pipe_resource*
vl_screen_texture_from_drawable(struct vl_screen *vscreen, Drawable drawable);
+struct u_rect *
+vl_screen_get_dirty_area(struct vl_screen *vscreen);
+
void*
vl_screen_get_private(struct vl_screen *vscreen);
#include "state_tracker/xlib_sw_winsys.h"
#include "softpipe/sp_public.h"
+#include "vl/vl_compositor.h"
#include "vl_winsys.h"
struct vl_xsp_screen
Visual visual;
struct xlib_drawable xdraw;
struct pipe_resource *tex;
+ struct u_rect dirty_area;
};
struct pipe_resource*
if (xsp_screen->tex) {
if (xsp_screen->tex->width0 == width && xsp_screen->tex->height0 == height)
return xsp_screen->tex;
- else
- pipe_resource_reference(&xsp_screen->tex, NULL);
+ pipe_resource_reference(&xsp_screen->tex, NULL);
+ vl_compositor_reset_dirty_area(&xsp_screen->dirty_area);
}
memset(&templat, 0, sizeof(struct pipe_resource));
return xsp_screen->tex;
}
+struct u_rect *
+vl_screen_get_dirty_area(struct vl_screen *vscreen)
+{
+ struct vl_xsp_screen *xsp_screen = (struct vl_xsp_screen*)vscreen;
+ return &xsp_screen->dirty_area;
+}
+
void*
vl_screen_get_private(struct vl_screen *vscreen)
{
xsp_screen->display = display;
xsp_screen->screen = screen;
xsp_screen->xdraw.visual = XDefaultVisual(display, screen);
+ vl_compositor_reset_dirty_area(&xsp_screen->dirty_area);
return &xsp_screen->base;
}