diff options
author | Christian König <[email protected]> | 2012-03-01 23:03:09 +0100 |
---|---|---|
committer | Christian König <[email protected]> | 2012-03-05 16:51:32 +0100 |
commit | 05579339c0da442669ea75749651e8cf4f9ec39b (patch) | |
tree | 037f8eefbd874395d2dcb2b4c7b79a4498f1285f /src/gallium/state_trackers/vdpau/bitmap.c | |
parent | 1d0c357a9733238985cbe029b174173ef927ac70 (diff) |
st/vdpau: make the interface thread save
Signed-off-by: Christian König <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers/vdpau/bitmap.c')
-rw-r--r-- | src/gallium/state_trackers/vdpau/bitmap.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/gallium/state_trackers/vdpau/bitmap.c b/src/gallium/state_trackers/vdpau/bitmap.c index a02bb941ff4..ecc5b158a9b 100644 --- a/src/gallium/state_trackers/vdpau/bitmap.c +++ b/src/gallium/state_trackers/vdpau/bitmap.c @@ -69,7 +69,6 @@ vlVdpBitmapSurfaceCreate(VdpDevice device, vlsurface->device = dev; memset(&res_tmpl, 0, sizeof(res_tmpl)); - res_tmpl.target = PIPE_TEXTURE_2D; res_tmpl.format = FormatRGBAToPipe(rgba_format); res_tmpl.width0 = width; @@ -78,29 +77,32 @@ vlVdpBitmapSurfaceCreate(VdpDevice device, res_tmpl.array_size = 1; res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET; res_tmpl.usage = frequently_accessed ? PIPE_USAGE_DYNAMIC : PIPE_USAGE_STATIC; + + pipe_mutex_lock(dev->mutex); res = pipe->screen->resource_create(pipe->screen, &res_tmpl); if (!res) { + pipe_mutex_unlock(dev->mutex); FREE(dev); return VDP_STATUS_RESOURCES; } vlVdpDefaultSamplerViewTemplate(&sv_templ, res); vlsurface->sampler_view = pipe->create_sampler_view(pipe, res, &sv_templ); + + pipe_resource_reference(&res, NULL); + pipe_mutex_unlock(dev->mutex); + if (!vlsurface->sampler_view) { - pipe_resource_reference(&res, NULL); FREE(dev); return VDP_STATUS_RESOURCES; } *surface = vlAddDataHTAB(vlsurface); if (*surface == 0) { - pipe_resource_reference(&res, NULL); FREE(dev); return VDP_STATUS_ERROR; } - pipe_resource_reference(&res, NULL); - return VDP_STATUS_OK; } @@ -116,9 +118,9 @@ vlVdpBitmapSurfaceDestroy(VdpBitmapSurface surface) if (!vlsurface) return VDP_STATUS_INVALID_HANDLE; - vlVdpResolveDelayedRendering(vlsurface->device, NULL, NULL); - + pipe_mutex_lock(vlsurface->device->mutex); pipe_sampler_view_reference(&vlsurface->sampler_view, NULL); + pipe_mutex_unlock(vlsurface->device->mutex); vlRemoveDataHTAB(surface); FREE(vlsurface); @@ -177,11 +179,16 @@ vlVdpBitmapSurfacePutBitsNative(VdpBitmapSurface surface, pipe = vlsurface->device->context; + pipe_mutex_lock(vlsurface->device->mutex); + vlVdpResolveDelayedRendering(vlsurface->device, NULL, NULL); dst_box = RectToPipeBox(destination_rect, vlsurface->sampler_view->texture); pipe->transfer_inline_write(pipe, vlsurface->sampler_view->texture, 0, PIPE_TRANSFER_WRITE, &dst_box, *source_data, *source_pitches, 0); + + pipe_mutex_unlock(vlsurface->device->mutex); + return VDP_STATUS_OK; } |