Lines Matching defs:upload
44 unsigned default_size; /* Minimum size of the upload buffer, in bytes. */
50 struct pipe_resource *buffer; /* Upload buffer. */
51 struct pipe_transfer *transfer; /* Transfer object for the upload buffer. */
52 uint8_t *map; /* Pointer to the mapped upload buffer. */
53 unsigned offset; /* Aligned offset to the upload buffer, pointing
62 struct u_upload_mgr *upload = CALLOC_STRUCT( u_upload_mgr );
63 if (!upload)
66 upload->pipe = pipe;
67 upload->default_size = default_size;
68 upload->bind = bind;
69 upload->usage = usage;
71 upload->map_persistent =
75 if (upload->map_persistent) {
76 upload->map_flags = PIPE_TRANSFER_WRITE |
81 upload->map_flags = PIPE_TRANSFER_WRITE |
86 return upload;
90 static void upload_unmap_internal(struct u_upload_mgr *upload, boolean destroying)
92 if (!destroying && upload->map_persistent)
95 if (upload->transfer) {
96 struct pipe_box *box = &upload->transfer->box;
98 if (!upload->map_persistent && (int) upload->offset > box->x) {
99 pipe_buffer_flush_mapped_range(upload->pipe, upload->transfer,
100 box->x, upload->offset - box->x);
103 pipe_transfer_unmap(upload->pipe, upload->transfer);
104 upload->transfer = NULL;
105 upload->map = NULL;
110 void u_upload_unmap( struct u_upload_mgr *upload )
112 upload_unmap_internal(upload, FALSE);
116 static void u_upload_release_buffer(struct u_upload_mgr *upload)
118 /* Unmap and unreference the upload buffer. */
119 upload_unmap_internal(upload, TRUE);
120 pipe_resource_reference( &upload->buffer, NULL );
124 void u_upload_destroy( struct u_upload_mgr *upload )
126 u_upload_release_buffer( upload );
127 FREE( upload );
132 u_upload_alloc_buffer(struct u_upload_mgr *upload,
135 struct pipe_screen *screen = upload->pipe->screen;
141 u_upload_release_buffer( upload );
145 size = align(MAX2(upload->default_size, min_size), 4096);
150 buffer.bind = upload->bind;
151 buffer.usage = upload->usage;
157 if (upload->map_persistent) {
162 upload->buffer = screen->resource_create(screen, &buffer);
163 if (upload->buffer == NULL)
167 upload->map = pipe_buffer_map_range(upload->pipe, upload->buffer,
168 0, size, upload->map_flags,
169 &upload->transfer);
170 if (upload->map == NULL) {
171 upload->transfer = NULL;
172 pipe_resource_reference(&upload->buffer, NULL);
176 upload->offset = 0;
180 u_upload_alloc(struct u_upload_mgr *upload,
188 unsigned buffer_size = upload->buffer ? upload->buffer->width0 : 0;
193 offset = align(upload->offset, alignment);
196 /* Make sure we have enough space in the upload buffer
199 if (unlikely(!upload->buffer || offset + size > buffer_size)) {
200 u_upload_alloc_buffer(upload, min_out_offset + size);
202 if (unlikely(!upload->buffer)) {
210 buffer_size = upload->buffer->width0;
213 if (unlikely(!upload->map)) {
214 upload->map = pipe_buffer_map_range(upload->pipe, upload->buffer,
217 upload->map_flags,
218 &upload->transfer);
219 if (unlikely(!upload->map)) {
220 upload->transfer = NULL;
227 upload->map -= offset;
235 *ptr = upload->map + offset;
236 pipe_resource_reference(outbuf, upload->buffer);
239 upload->offset = offset + size;
242 void u_upload_data(struct u_upload_mgr *upload,
252 u_upload_alloc(upload, min_out_offset, size, alignment,
260 void u_upload_buffer(struct u_upload_mgr *upload,
272 map = (const char *)pipe_buffer_map_range(upload->pipe,
284 debug_printf("upload ptr %p ofs %d sz %d\n", map, offset, size);
286 u_upload_data(upload, min_out_offset, size, alignment,
288 pipe_buffer_unmap( upload->pipe, transfer );