1 /**************************************************************************
3 * Copyright 2009 VMware, Inc.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
26 **************************************************************************/
28 /* Helper utility for uploading user buffers & other data, and
29 * coalescing small buffers into larger ones.
32 #ifndef U_UPLOAD_MGR_H
33 #define U_UPLOAD_MGR_H
35 #include "pipe/p_compiler.h"
41 struct u_upload_mgr
*u_upload_create( struct pipe_context
*pipe
,
42 unsigned default_size
,
46 void u_upload_destroy( struct u_upload_mgr
*upload
);
48 /* Unmap and release old buffer.
50 * This must usually be called prior to firing the command stream
51 * which references the upload buffer, as many memory managers either
52 * don't like firing a mapped buffer or cause subsequent maps of a
53 * fired buffer to wait. For now, it's easiest just to grab a new
56 void u_upload_flush( struct u_upload_mgr
*upload
);
59 * Sub-allocate new memory from the upload buffer.
61 * \param upload Upload manager
62 * \param min_out_offset Minimum offset that should be returned in out_offset.
63 * \param size Size of the allocation.
64 * \param out_offset Pointer to where the new buffer offset will be returned.
65 * \param outbuf Pointer to where the upload buffer will be returned.
66 * \param flushed Whether the upload buffer was flushed.
67 * \param ptr Pointer to the allocated memory that is returned.
69 enum pipe_error
u_upload_alloc( struct u_upload_mgr
*upload
,
70 unsigned min_out_offset
,
73 struct pipe_resource
**outbuf
,
79 * Allocate and write data to the upload buffer.
81 * Same as u_upload_alloc, but in addition to that, it copies "data"
82 * to the pointer returned from u_upload_alloc.
84 enum pipe_error
u_upload_data( struct u_upload_mgr
*upload
,
85 unsigned min_out_offset
,
89 struct pipe_resource
**outbuf
,
94 * Allocate and copy an input buffer to the upload buffer.
96 * Same as u_upload_data, except that the input data comes from a buffer
97 * instead of a user pointer.
99 enum pipe_error
u_upload_buffer( struct u_upload_mgr
*upload
,
100 unsigned min_out_offset
,
103 struct pipe_resource
*inbuf
,
104 unsigned *out_offset
,
105 struct pipe_resource
**outbuf
,