Merge branch '7.8'
[mesa.git] / src / gallium / auxiliary / util / u_upload_mgr.h
1 /**************************************************************************
2 *
3 * Copyright 2009 VMware, Inc.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 /* Helper utility for uploading user buffers & other data, and
29 * coalescing small buffers into larger ones.
30 */
31
32 #ifndef U_UPLOAD_MGR_H
33 #define U_UPLOAD_MGR_H
34
35 #include "pipe/p_defines.h"
36
37 struct pipe_screen;
38 struct pipe_resource;
39 struct u_upload_mgr;
40
41
42 struct u_upload_mgr *u_upload_create( struct pipe_context *pipe,
43 unsigned default_size,
44 unsigned alignment,
45 unsigned usage );
46
47 void u_upload_destroy( struct u_upload_mgr *upload );
48
49 /* Unmap and release old buffer.
50 *
51 * This must usually be called prior to firing the command stream
52 * which references the upload buffer, as many memory managers either
53 * don't like firing a mapped buffer or cause subsequent maps of a
54 * fired buffer to wait. For now, it's easiest just to grab a new
55 * buffer.
56 */
57 void u_upload_flush( struct u_upload_mgr *upload );
58
59
60 enum pipe_error u_upload_data( struct u_upload_mgr *upload,
61 unsigned size,
62 const void *data,
63 unsigned *out_offset,
64 struct pipe_resource **outbuf );
65
66
67 enum pipe_error u_upload_buffer( struct u_upload_mgr *upload,
68 unsigned offset,
69 unsigned size,
70 struct pipe_resource *inbuf,
71 unsigned *out_offset,
72 struct pipe_resource **outbuf );
73
74
75
76 #endif
77