summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/i915
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/i915')
-rw-r--r--src/gallium/drivers/i915/i915_resource.c2
-rw-r--r--src/gallium/drivers/i915/i915_resource_buffer.c37
-rw-r--r--src/gallium/drivers/i915/i915_resource_texture.c92
3 files changed, 50 insertions, 81 deletions
diff --git a/src/gallium/drivers/i915/i915_resource.c b/src/gallium/drivers/i915/i915_resource.c
index 253c7d06233..314ebe9551e 100644
--- a/src/gallium/drivers/i915/i915_resource.c
+++ b/src/gallium/drivers/i915/i915_resource.c
@@ -31,11 +31,9 @@ i915_resource_from_handle(struct pipe_screen * screen,
void
i915_init_resource_functions(struct i915_context *i915 )
{
- i915->base.get_transfer = u_get_transfer_vtbl;
i915->base.transfer_map = u_transfer_map_vtbl;
i915->base.transfer_flush_region = u_transfer_flush_region_vtbl;
i915->base.transfer_unmap = u_transfer_unmap_vtbl;
- i915->base.transfer_destroy = u_transfer_destroy_vtbl;
i915->base.transfer_inline_write = u_transfer_inline_write_vtbl;
}
diff --git a/src/gallium/drivers/i915/i915_resource_buffer.c b/src/gallium/drivers/i915/i915_resource_buffer.c
index 77c03450b3a..80ec43a41eb 100644
--- a/src/gallium/drivers/i915/i915_resource_buffer.c
+++ b/src/gallium/drivers/i915/i915_resource_buffer.c
@@ -60,14 +60,16 @@ i915_buffer_destroy(struct pipe_screen *screen,
}
-static struct pipe_transfer *
-i915_get_transfer(struct pipe_context *pipe,
- struct pipe_resource *resource,
- unsigned level,
- unsigned usage,
- const struct pipe_box *box)
+static void *
+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_context *i915 = i915_context(pipe);
+ struct i915_buffer *buffer = i915_buffer(resource);
struct pipe_transfer *transfer = util_slab_alloc(&i915->transfer_pool);
if (transfer == NULL)
@@ -77,30 +79,19 @@ i915_get_transfer(struct pipe_context *pipe,
transfer->level = level;
transfer->usage = usage;
transfer->box = *box;
+ *ptransfer = transfer;
- /* Note strides are zero, this is ok for buffers, but not for
- * textures 2d & higher at least.
- */
- return transfer;
+ return buffer->data + transfer->box.x;
}
static void
-i915_transfer_destroy(struct pipe_context *pipe,
- struct pipe_transfer *transfer)
+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);
}
-static void *
-i915_buffer_transfer_map( struct pipe_context *pipe,
- struct pipe_transfer *transfer )
-{
- struct i915_buffer *buffer = i915_buffer(transfer->resource);
- return buffer->data + transfer->box.x;
-}
-
-
static void
i915_buffer_transfer_inline_write( struct pipe_context *rm_ctx,
struct pipe_resource *resource,
@@ -123,11 +114,9 @@ struct u_resource_vtbl i915_buffer_vtbl =
{
i915_buffer_get_handle, /* get_handle */
i915_buffer_destroy, /* resource_destroy */
- i915_get_transfer, /* get_transfer */
- i915_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_unmap, /* transfer_unmap */
i915_buffer_transfer_inline_write /* transfer_inline_write */
};
diff --git a/src/gallium/drivers/i915/i915_resource_texture.c b/src/gallium/drivers/i915/i915_resource_texture.c
index 83437af371a..52ef776b3ce 100644
--- a/src/gallium/drivers/i915/i915_resource_texture.c
+++ b/src/gallium/drivers/i915/i915_resource_texture.c
@@ -705,17 +705,22 @@ i915_texture_destroy(struct pipe_screen *screen,
FREE(tex);
}
-static struct pipe_transfer *
-i915_texture_get_transfer(struct pipe_context *pipe,
+static void *
+i915_texture_transfer_map(struct pipe_context *pipe,
struct pipe_resource *resource,
unsigned level,
unsigned usage,
- const struct pipe_box *box)
+ const struct pipe_box *box,
+ struct pipe_transfer **ptransfer)
{
struct i915_context *i915 = i915_context(pipe);
struct i915_texture *tex = i915_texture(resource);
struct i915_transfer *transfer = util_slab_alloc(&i915->texture_transfer_pool);
boolean use_staging_texture = FALSE;
+ struct i915_winsys *iws = i915_screen(pipe->screen)->iws;
+ enum pipe_format format = resource->format;
+ unsigned offset;
+ char *map;
if (transfer == NULL)
return NULL;
@@ -749,67 +754,32 @@ i915_texture_get_transfer(struct pipe_context *pipe,
transfer->staging_texture = i915_texture_create(pipe->screen, resource, TRUE);
}
- return (struct pipe_transfer*)transfer;
-}
-
-static void
-i915_transfer_destroy(struct pipe_context *pipe,
- struct pipe_transfer *transfer)
-{
- struct i915_context *i915 = i915_context(pipe);
- struct i915_transfer *itransfer = (struct i915_transfer*)transfer;
-
- if ((itransfer->staging_texture) &&
- (transfer->usage & PIPE_TRANSFER_WRITE)) {
- struct pipe_box sbox;
-
- u_box_origin_2d(itransfer->b.box.width, itransfer->b.box.height, &sbox);
- pipe->resource_copy_region(pipe, itransfer->b.resource, itransfer->b.level,
- itransfer->b.box.x, itransfer->b.box.y, itransfer->b.box.z,
- itransfer->staging_texture,
- 0, &sbox);
- pipe->flush(pipe, NULL);
- pipe_resource_reference(&itransfer->staging_texture, NULL);
- }
-
- util_slab_free(&i915->texture_transfer_pool, itransfer);
-}
-
-static void *
-i915_texture_transfer_map(struct pipe_context *pipe,
- struct pipe_transfer *transfer)
-{
- struct i915_transfer *itransfer = (struct i915_transfer*)transfer;
- struct pipe_resource *resource = itransfer->b.resource;
- struct i915_texture *tex = NULL;
- struct i915_winsys *iws = i915_screen(pipe->screen)->iws;
- struct pipe_box *box = &itransfer->b.box;
- enum pipe_format format = resource->format;
- unsigned offset;
- char *map;
-
if (resource->target != PIPE_TEXTURE_3D &&
resource->target != PIPE_TEXTURE_CUBE)
assert(box->z == 0);
- if (itransfer->staging_texture) {
- tex = i915_texture(itransfer->staging_texture);
+ if (transfer->staging_texture) {
+ tex = i915_texture(transfer->staging_texture);
} else {
/* TODO this is a sledgehammer */
tex = i915_texture(resource);
pipe->flush(pipe, NULL);
}
- offset = i915_texture_offset(tex, itransfer->b.level, box->z);
+ offset = i915_texture_offset(tex, transfer->b.level, box->z);
map = iws->buffer_map(iws, tex->buffer,
- (itransfer->b.usage & PIPE_TRANSFER_WRITE) ? TRUE : FALSE);
+ (transfer->b.usage & PIPE_TRANSFER_WRITE) ? TRUE : FALSE);
if (map == NULL) {
+ pipe_resource_reference(&transfer->staging_texture, NULL);
+ FREE(transfer);
return NULL;
}
+ *ptransfer = &transfer->b;
+
return map + offset +
- box->y / util_format_get_blockheight(format) * itransfer->b.stride +
+ box->y / util_format_get_blockheight(format) * transfer->b.stride +
box->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
}
@@ -817,6 +787,7 @@ static void
i915_texture_transfer_unmap(struct pipe_context *pipe,
struct pipe_transfer *transfer)
{
+ struct i915_context *i915 = i915_context(pipe);
struct i915_transfer *itransfer = (struct i915_transfer*)transfer;
struct i915_texture *tex = i915_texture(itransfer->b.resource);
struct i915_winsys *iws = i915_screen(tex->b.b.screen)->iws;
@@ -825,8 +796,24 @@ i915_texture_transfer_unmap(struct pipe_context *pipe,
tex = i915_texture(itransfer->staging_texture);
iws->buffer_unmap(iws, tex->buffer);
+
+ if ((itransfer->staging_texture) &&
+ (transfer->usage & PIPE_TRANSFER_WRITE)) {
+ struct pipe_box sbox;
+
+ u_box_origin_2d(itransfer->b.box.width, itransfer->b.box.height, &sbox);
+ pipe->resource_copy_region(pipe, itransfer->b.resource, itransfer->b.level,
+ itransfer->b.box.x, itransfer->b.box.y, itransfer->b.box.z,
+ itransfer->staging_texture,
+ 0, &sbox);
+ pipe->flush(pipe, NULL);
+ pipe_resource_reference(&itransfer->staging_texture, NULL);
+ }
+
+ util_slab_free(&i915->texture_transfer_pool, itransfer);
}
+#if 0
static void i915_transfer_inline_write( struct pipe_context *pipe,
struct pipe_resource *resource,
unsigned level,
@@ -841,7 +828,7 @@ static void i915_transfer_inline_write( struct pipe_context *pipe,
const uint8_t *src_data = data;
unsigned i;
- transfer = pipe->get_transfer(pipe,
+ transfer = pipe->transfer_get(pipe,
resource,
level,
usage,
@@ -913,24 +900,19 @@ out:
if (itransfer)
pipe_transfer_destroy(pipe, &itransfer->b);
}
-
-
+#endif
struct u_resource_vtbl i915_texture_vtbl =
{
i915_texture_get_handle, /* get_handle */
i915_texture_destroy, /* resource_destroy */
- i915_texture_get_transfer, /* get_transfer */
- i915_transfer_destroy, /* transfer_destroy */
i915_texture_transfer_map, /* transfer_map */
u_default_transfer_flush_region, /* transfer_flush_region */
i915_texture_transfer_unmap, /* transfer_unmap */
- i915_transfer_inline_write /* transfer_inline_write */
+ u_default_transfer_inline_write /* transfer_inline_write */
};
-
-
struct pipe_resource *
i915_texture_create(struct pipe_screen *screen,
const struct pipe_resource *template,