**************************************************************************/
#include <stdio.h>
-#include <time.h>
-#include <sys/timeb.h>
-
#include <vdpau/vdpau.h>
#include "util/u_debug.h"
pq->device = dev;
pq->drawable = pqt->drawable;
+ pipe_mutex_lock(dev->mutex);
if (!vl_compositor_init_state(&pq->cstate, dev->context)) {
+ pipe_mutex_unlock(dev->mutex);
ret = VDP_STATUS_ERROR;
goto no_compositor;
}
+ pipe_mutex_unlock(dev->mutex);
*presentation_queue = vlAddDataHTAB(pq);
if (*presentation_queue == 0) {
if (!pq)
return VDP_STATUS_INVALID_HANDLE;
+ pipe_mutex_lock(pq->device->mutex);
vl_compositor_cleanup_state(&pq->cstate);
+ pipe_mutex_unlock(pq->device->mutex);
vlRemoveDataHTAB(presentation_queue);
FREE(pq);
color.f[2] = background_color->blue;
color.f[3] = background_color->alpha;
+ pipe_mutex_lock(pq->device->mutex);
vl_compositor_set_clear_color(&pq->cstate, &color);
+ pipe_mutex_unlock(pq->device->mutex);
return VDP_STATUS_OK;
}
if (!pq)
return VDP_STATUS_INVALID_HANDLE;
+ pipe_mutex_lock(pq->device->mutex);
vl_compositor_get_clear_color(&pq->cstate, &color);
+ pipe_mutex_unlock(pq->device->mutex);
background_color->red = color.f[0];
background_color->green = color.f[1];
VdpTime *current_time)
{
vlVdpPresentationQueue *pq;
- struct timespec ts;
if (!current_time)
return VDP_STATUS_INVALID_POINTER;
if (!pq)
return VDP_STATUS_INVALID_HANDLE;
- clock_gettime(CLOCK_REALTIME, &ts);
- *current_time = (uint64_t)ts.tv_sec * 1000000000LL + (uint64_t)ts.tv_nsec;
+ pipe_mutex_lock(pq->device->mutex);
+ *current_time = vl_screen_get_timestamp(pq->device->vscreen, pq->drawable);
+ pipe_mutex_unlock(pq->device->mutex);
return VDP_STATUS_OK;
}
if (!pq)
return VDP_STATUS_INVALID_HANDLE;
+ surf = vlGetDataHTAB(surface);
+ if (!surf)
+ return VDP_STATUS_INVALID_HANDLE;
pipe = pq->device->context;
compositor = &pq->device->compositor;
cstate = &pq->cstate;
+ pipe_mutex_lock(pq->device->mutex);
tex = vl_screen_texture_from_drawable(pq->device->vscreen, pq->drawable);
- if (!tex)
+ if (!tex) {
+ pipe_mutex_unlock(pq->device->mutex);
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;
surf_draw = pipe->create_surface(pipe, tex, &surf_templ);
- surf = vlGetDataHTAB(surface);
- if (!surf)
- return VDP_STATUS_INVALID_HANDLE;
-
surf->timestamp = (vlVdpTime)earliest_presentation_time;
dst_clip.x0 = 0;
vl_compositor_render(cstate, compositor, surf_draw, dirty_area);
}
+ vl_screen_set_next_timestamp(pq->device->vscreen, earliest_presentation_time);
pipe->screen->flush_frontbuffer
(
pipe->screen, tex, 0, 0,
);
pipe->screen->fence_reference(pipe->screen, &surf->fence, NULL);
- pipe->flush(pipe, &surf->fence);
+ pipe->flush(pipe, &surf->fence, 0);
if (dump_window == -1) {
dump_window = debug_get_num_option("VDPAU_DUMP", 0);
static unsigned int framenum = 0;
char cmd[256];
- sprintf(cmd, "xwd -id %d -out vdpau_frame_%08d.xwd", (int)pq->drawable, ++framenum);
- if (system(cmd) != 0)
- VDPAU_MSG(VDPAU_ERR, "[VDPAU] Dumping surface %d failed.\n", surface);
+ if (framenum) {
+ sprintf(cmd, "xwd -id %d -silent -out vdpau_frame_%08d.xwd", (int)pq->drawable, framenum);
+ if (system(cmd) != 0)
+ VDPAU_MSG(VDPAU_ERR, "[VDPAU] Dumping surface %d failed.\n", surface);
+ }
+ framenum++;
}
pipe_resource_reference(&tex, NULL);
pipe_surface_reference(&surf_draw, NULL);
+ pipe_mutex_unlock(pq->device->mutex);
return VDP_STATUS_OK;
}
if (!surf)
return VDP_STATUS_INVALID_HANDLE;
+ pipe_mutex_lock(pq->device->mutex);
if (surf->fence) {
screen = pq->device->vscreen->pscreen;
screen->fence_finish(screen, surf->fence, 0);
}
+ pipe_mutex_unlock(pq->device->mutex);
- // We actually need to query the timestamp of the last VSYNC event from the hardware
- vlVdpPresentationQueueGetTime(presentation_queue, first_presentation_time);
-
- return VDP_STATUS_OK;
+ return vlVdpPresentationQueueGetTime(presentation_queue, first_presentation_time);
}
/**
if (!surf->fence) {
*status = VDP_PRESENTATION_QUEUE_STATUS_IDLE;
} else {
+ pipe_mutex_lock(pq->device->mutex);
screen = pq->device->vscreen->pscreen;
if (screen->fence_signalled(screen, surf->fence)) {
screen->fence_reference(screen, &surf->fence, NULL);
*status = VDP_PRESENTATION_QUEUE_STATUS_VISIBLE;
+ pipe_mutex_unlock(pq->device->mutex);
// We actually need to query the timestamp of the last VSYNC event from the hardware
vlVdpPresentationQueueGetTime(presentation_queue, first_presentation_time);
*first_presentation_time += 1;
} else {
*status = VDP_PRESENTATION_QUEUE_STATUS_QUEUED;
+ pipe_mutex_unlock(pq->device->mutex);
}
}