X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fdrivers%2Fi915%2Fi915_resource_buffer.c;h=24c954cae34fb3fa0e1b8c01218a15ca8701aed8;hb=31da39ddc92e780dc539bf34d2de7f82fc65fa86;hp=0744cc926ae3eac45028b7f17e1b357e51b5be43;hpb=8f3bdeaad610d7d5a5c6e73e1e9c721219595754;p=mesa.git diff --git a/src/gallium/drivers/i915/i915_resource_buffer.c b/src/gallium/drivers/i915/i915_resource_buffer.c index 0744cc926ae..24c954cae34 100644 --- a/src/gallium/drivers/i915/i915_resource_buffer.c +++ b/src/gallium/drivers/i915/i915_resource_buffer.c @@ -1,6 +1,6 @@ /************************************************************************** * - * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas. + * Copyright 2006 VMware, Inc. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -18,7 +18,7 @@ * 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. @@ -26,8 +26,8 @@ **************************************************************************/ /* * Authors: - * Keith Whitwell - * Michel Dänzer + * Keith Whitwell + * Michel Dänzer */ #include "pipe/p_context.h" @@ -61,29 +61,46 @@ i915_buffer_destroy(struct pipe_screen *screen, static void * -i915_buffer_transfer_map( struct pipe_context *pipe, - struct pipe_transfer *transfer ) +i915_buffer_transfer_map(struct pipe_context *pipe, + struct pipe_resource *resource, + unsigned level, + unsigned usage, + const struct pipe_box *box, + struct pipe_transfer **ptransfer) { - struct i915_buffer *buffer = i915_buffer(transfer->resource); + struct i915_context *i915 = i915_context(pipe); + struct i915_buffer *buffer = i915_buffer(resource); + struct pipe_transfer *transfer = util_slab_alloc(&i915->transfer_pool); + + if (!transfer) + return NULL; + + transfer->resource = resource; + transfer->level = level; + transfer->usage = usage; + transfer->box = *box; + *ptransfer = transfer; + return buffer->data + transfer->box.x; } - static void -i915_buffer_transfer_inline_write( struct pipe_context *rm_ctx, - struct pipe_resource *resource, - struct pipe_subresource sr, - unsigned usage, - const struct pipe_box *box, - const void *data, - unsigned stride, - unsigned slice_stride) +i915_buffer_transfer_unmap(struct pipe_context *pipe, + struct pipe_transfer *transfer) +{ + struct i915_context *i915 = i915_context(pipe); + util_slab_free(&i915->transfer_pool, transfer); +} + +void +i915_buffer_subdata(struct pipe_context *rm_ctx, + struct pipe_resource *resource, + unsigned usage, unsigned offset, + unsigned size, const void *data) { struct i915_buffer *buffer = i915_buffer(resource); - memcpy(buffer->data + box->x, - data, - box->width); + memcpy(buffer->data + offset, data, size); } @@ -91,13 +108,9 @@ struct u_resource_vtbl i915_buffer_vtbl = { i915_buffer_get_handle, /* get_handle */ i915_buffer_destroy, /* resource_destroy */ - NULL, /* is_resource_referenced */ - u_default_get_transfer, /* get_transfer */ - u_default_transfer_destroy, /* transfer_destroy */ i915_buffer_transfer_map, /* transfer_map */ u_default_transfer_flush_region, /* transfer_flush_region */ - u_default_transfer_unmap, /* transfer_unmap */ - i915_buffer_transfer_inline_write /* transfer_inline_write */ + i915_buffer_transfer_unmap, /* transfer_unmap */ }; @@ -115,8 +128,7 @@ i915_buffer_create(struct pipe_screen *screen, buf->b.vtbl = &i915_buffer_vtbl; pipe_reference_init(&buf->b.b.reference, 1); buf->b.b.screen = screen; - - buf->data = MALLOC(template->width0); + buf->data = align_malloc(template->width0, 64); buf->free_on_destroy = TRUE; if (!buf->data) @@ -135,7 +147,7 @@ struct pipe_resource * i915_user_buffer_create(struct pipe_screen *screen, void *ptr, unsigned bytes, - unsigned bind) + unsigned bind) { struct i915_buffer *buf = CALLOC_STRUCT(i915_buffer); @@ -146,12 +158,13 @@ i915_user_buffer_create(struct pipe_screen *screen, buf->b.vtbl = &i915_buffer_vtbl; buf->b.b.screen = screen; buf->b.b.format = PIPE_FORMAT_R8_UNORM; /* ?? */ - buf->b.b._usage = PIPE_USAGE_IMMUTABLE; + buf->b.b.usage = PIPE_USAGE_IMMUTABLE; buf->b.b.bind = bind; buf->b.b.flags = 0; buf->b.b.width0 = bytes; buf->b.b.height0 = 1; buf->b.b.depth0 = 1; + buf->b.b.array_size = 1; buf->data = ptr; buf->free_on_destroy = FALSE;