* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
struct pipe_context *pipe;
struct pipe_resource res_tmpl, *res;
struct pipe_sampler_view sv_templ;
+ VdpStatus ret;
vlVdpBitmapSurface *vlsurface = NULL;
if (!vlsurface)
return VDP_STATUS_RESOURCES;
- vlsurface->device = dev;
+ DeviceReference(&vlsurface->device, dev);
memset(&res_tmpl, 0, sizeof(res_tmpl));
-
res_tmpl.target = PIPE_TEXTURE_2D;
- res_tmpl.format = FormatRGBAToPipe(rgba_format);
+ res_tmpl.format = VdpFormatRGBAToPipe(rgba_format);
res_tmpl.width0 = width;
res_tmpl.height0 = height;
res_tmpl.depth0 = 1;
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;
+ res_tmpl.usage = frequently_accessed ? PIPE_USAGE_DYNAMIC : PIPE_USAGE_DEFAULT;
+
+ mtx_lock(&dev->mutex);
+
+ if (!CheckSurfaceParams(pipe->screen, &res_tmpl)) {
+ ret = VDP_STATUS_RESOURCES;
+ goto err_unlock;
+ }
+
res = pipe->screen->resource_create(pipe->screen, &res_tmpl);
if (!res) {
- FREE(dev);
- return VDP_STATUS_RESOURCES;
+ ret = VDP_STATUS_RESOURCES;
+ goto err_unlock;
}
vlVdpDefaultSamplerViewTemplate(&sv_templ, res);
vlsurface->sampler_view = pipe->create_sampler_view(pipe, res, &sv_templ);
+
+ pipe_resource_reference(&res, NULL);
+
if (!vlsurface->sampler_view) {
- pipe_resource_reference(&res, NULL);
- FREE(dev);
- return VDP_STATUS_RESOURCES;
+ ret = VDP_STATUS_RESOURCES;
+ goto err_unlock;
}
+ mtx_unlock(&dev->mutex);
+
*surface = vlAddDataHTAB(vlsurface);
if (*surface == 0) {
- pipe_resource_reference(&res, NULL);
- FREE(dev);
- return VDP_STATUS_ERROR;
+ mtx_lock(&dev->mutex);
+ ret = VDP_STATUS_ERROR;
+ goto err_sampler;
}
- pipe_resource_reference(&res, NULL);
-
return VDP_STATUS_OK;
+
+err_sampler:
+ pipe_sampler_view_reference(&vlsurface->sampler_view, NULL);
+err_unlock:
+ mtx_unlock(&dev->mutex);
+ DeviceReference(&vlsurface->device, NULL);
+ FREE(vlsurface);
+ return ret;
}
/**
if (!vlsurface)
return VDP_STATUS_INVALID_HANDLE;
- vlVdpResolveDelayedRendering(vlsurface->device, NULL, NULL);
-
+ mtx_lock(&vlsurface->device->mutex);
pipe_sampler_view_reference(&vlsurface->sampler_view, NULL);
+ mtx_unlock(&vlsurface->device->mutex);
vlRemoveDataHTAB(surface);
+ DeviceReference(&vlsurface->device, NULL);
FREE(vlsurface);
return VDP_STATUS_OK;
pipe = vlsurface->device->context;
- vlVdpResolveDelayedRendering(vlsurface->device, NULL, NULL);
+ mtx_lock(&vlsurface->device->mutex);
- dst_box.x = 0;
- dst_box.y = 0;
- dst_box.z = 0;
- dst_box.width = vlsurface->sampler_view->texture->width0;
- dst_box.height = vlsurface->sampler_view->texture->height0;
- dst_box.depth = 1;
+ dst_box = RectToPipeBox(destination_rect, vlsurface->sampler_view->texture);
+ pipe->texture_subdata(pipe, vlsurface->sampler_view->texture, 0,
+ PIPE_TRANSFER_WRITE, &dst_box, *source_data,
+ *source_pitches, 0);
- if (destination_rect) {
- dst_box.x = MIN2(destination_rect->x0, destination_rect->x1);
- dst_box.y = MIN2(destination_rect->y0, destination_rect->y1);
- dst_box.width = abs(destination_rect->x1 - destination_rect->x0);
- dst_box.height = abs(destination_rect->y1 - destination_rect->y0);
- }
+ mtx_unlock(&vlsurface->device->mutex);
- pipe->transfer_inline_write(pipe, vlsurface->sampler_view->texture, 0,
- PIPE_TRANSFER_WRITE, &dst_box, *source_data,
- *source_pitches, 0);
return VDP_STATUS_OK;
}