u_staging.h revision 5f2deba9f3f3f9230a9fdd2848e20c1e23e98b8f
184bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner/**************************************************************************
284bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner *
384bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner * Copyright 2010 Luca Barbieri
484bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner *
584bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner * Permission is hereby granted, free of charge, to any person obtaining
684bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner * a copy of this software and associated documentation files (the
784bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner * "Software"), to deal in the Software without restriction, including
884bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner * without limitation the rights to use, copy, modify, merge, publish,
984bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner * distribute, sublicense, and/or sell copies of the Software, and to
1084bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner * permit persons to whom the Software is furnished to do so, subject to
1184bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner * the following conditions:
1284bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner *
1384bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner * The above copyright notice and this permission notice (including the
1484bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner * next paragraph) shall be included in all copies or substantial
1584bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner * portions of the Software.
1684bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner *
176f0d024a534af18d9e60b3ea757376cd8a3a980eDan Gohman * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1884bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1984bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
2084bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
2184bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
2284bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
231213d672653d7fee471d91d05b559e137d70ba56Chris Lattner * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
241213d672653d7fee471d91d05b559e137d70ba56Chris Lattner *
251213d672653d7fee471d91d05b559e137d70ba56Chris Lattner **************************************************************************/
2684bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner
2784bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner/* Direct3D 10/11 has no concept of transfers. Applications instead
2884bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner * create resources with a STAGING or DYNAMIC usage, copy between them
296f0d024a534af18d9e60b3ea757376cd8a3a980eDan Gohman * and the real resource and use Map to map the STAGING/DYNAMIC resource.
3062ed6b9ade63bf01717ce5274fa11e93e873d245Chris Lattner *
3162ed6b9ade63bf01717ce5274fa11e93e873d245Chris Lattner * This util module allows to implement Gallium drivers as a Direct3D
3262ed6b9ade63bf01717ce5274fa11e93e873d245Chris Lattner * driver would be implemented: transfers allocate a resource with
3362ed6b9ade63bf01717ce5274fa11e93e873d245Chris Lattner * PIPE_USAGE_STAGING, and copy the data between it and the real resource
3411a26f3697ea6520022ea6d3fa6a07b3c1b988cdEvan Cheng * with resource_copy_region.
3511a26f3697ea6520022ea6d3fa6a07b3c1b988cdEvan Cheng */
3611a26f3697ea6520022ea6d3fa6a07b3c1b988cdEvan Cheng
3711a26f3697ea6520022ea6d3fa6a07b3c1b988cdEvan Cheng#ifndef U_STAGING_H
38a606d955de3b0f777131d74162eb6f11b5f95d75Dan Gohman#define U_STAGING_H
3990f95f88c6ce09c6744777dc9d140c3c77203b92Evan Cheng
4090f95f88c6ce09c6744777dc9d140c3c77203b92Evan Cheng#include "pipe/p_state.h"
41358dec51804ee52e47ea3a47c9248086e458ad7cEvan Cheng
42358dec51804ee52e47ea3a47c9248086e458ad7cEvan Chengstruct util_staging_transfer {
43358dec51804ee52e47ea3a47c9248086e458ad7cEvan Cheng   struct pipe_transfer base;
44358dec51804ee52e47ea3a47c9248086e458ad7cEvan Cheng
45358dec51804ee52e47ea3a47c9248086e458ad7cEvan Cheng   /* if direct, same as base.resource, otherwise the temporary staging resource */
4690f95f88c6ce09c6744777dc9d140c3c77203b92Evan Cheng   struct pipe_resource *staging_resource;
47358dec51804ee52e47ea3a47c9248086e458ad7cEvan Cheng};
4862ed6b9ade63bf01717ce5274fa11e93e873d245Chris Lattner
4962ed6b9ade63bf01717ce5274fa11e93e873d245Chris Lattner/* user must be stride, slice_stride and offset */
5062ed6b9ade63bf01717ce5274fa11e93e873d245Chris Lattner/* pt->usage == PIPE_USAGE_DYNAMIC || pt->usage == PIPE_USAGE_STAGING should be a good value to pass for direct */
5162ed6b9ade63bf01717ce5274fa11e93e873d245Chris Lattner/* staging resource is currently created with PIPE_USAGE_STAGING */
5284bc5427d6883f73cfeae3da640acd011d35c006Chris Lattnerstruct util_staging_transfer *
5384bc5427d6883f73cfeae3da640acd011d35c006Chris Lattnerutil_staging_transfer_init(struct pipe_context *pipe,
5484bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner           struct pipe_resource *pt,
5584bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner           unsigned level,
5684bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner           unsigned usage,
5784bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner           const struct pipe_box *box,
5884bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner           boolean direct, struct util_staging_transfer *tx);
5984bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner
6084bc5427d6883f73cfeae3da640acd011d35c006Chris Lattnervoid
6184bc5427d6883f73cfeae3da640acd011d35c006Chris Lattnerutil_staging_transfer_destroy(struct pipe_context *pipe, struct pipe_transfer *ptx);
6284bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner
6384bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner#endif
6484bc5427d6883f73cfeae3da640acd011d35c006Chris Lattner