summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/i915simple/i915_screen.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/i915simple/i915_screen.c')
-rw-r--r--src/gallium/drivers/i915simple/i915_screen.c83
1 files changed, 71 insertions, 12 deletions
diff --git a/src/gallium/drivers/i915simple/i915_screen.c b/src/gallium/drivers/i915simple/i915_screen.c
index 39e48105b3..f4aa8e60d8 100644
--- a/src/gallium/drivers/i915simple/i915_screen.c
+++ b/src/gallium/drivers/i915simple/i915_screen.c
@@ -36,6 +36,7 @@
#include "i915_context.h"
#include "i915_screen.h"
#include "i915_texture.h"
+#include "i915_winsys.h"
static const char *
@@ -204,17 +205,71 @@ i915_destroy_screen( struct pipe_screen *screen )
}
+static struct pipe_transfer*
+i915_get_tex_transfer(struct pipe_screen *screen,
+ struct pipe_texture *texture,
+ unsigned face, unsigned level, unsigned zslice,
+ enum pipe_transfer_usage usage, unsigned x, unsigned y,
+ unsigned w, unsigned h)
+{
+ struct i915_texture *tex = (struct i915_texture *)texture;
+ struct i915_transfer *trans;
+ unsigned offset; /* in bytes */
+
+ if (texture->target == PIPE_TEXTURE_CUBE) {
+ offset = tex->image_offset[level][face];
+ }
+ else if (texture->target == PIPE_TEXTURE_3D) {
+ offset = tex->image_offset[level][zslice];
+ }
+ else {
+ offset = tex->image_offset[level][0];
+ assert(face == 0);
+ assert(zslice == 0);
+ }
+
+ trans = CALLOC_STRUCT(i915_transfer);
+ if (trans) {
+ pipe_texture_reference(&trans->base.texture, texture);
+ trans->base.format = trans->base.format;
+ trans->base.width = w;
+ trans->base.height = h;
+ trans->base.block = texture->block;
+ trans->base.nblocksx = texture->nblocksx[level];
+ trans->base.nblocksy = texture->nblocksy[level];
+ trans->base.stride = tex->stride;
+ trans->offset = offset;
+ trans->base.usage = usage;
+ }
+ return &trans->base;
+}
+
+static void
+i915_tex_transfer_destroy(struct pipe_transfer *trans)
+{
+ pipe_texture_reference(&trans->texture, NULL);
+ FREE(trans);
+}
+
static void *
-i915_surface_map( struct pipe_screen *screen,
- struct pipe_surface *surface,
- unsigned flags )
+i915_transfer_map( struct pipe_screen *screen,
+ struct pipe_transfer *transfer )
{
- struct i915_texture *tex = (struct i915_texture *)surface->texture;
- char *map = pipe_buffer_map( screen, tex->buffer, flags );
+ struct i915_texture *tex = (struct i915_texture *)transfer->texture;
+ char *map;
+ unsigned flags = 0;
+
+ if (transfer->usage != PIPE_TRANSFER_WRITE)
+ flags |= PIPE_BUFFER_USAGE_CPU_READ;
+
+ if (transfer->usage != PIPE_TRANSFER_READ)
+ flags |= PIPE_BUFFER_USAGE_CPU_WRITE;
+
+ map = pipe_buffer_map( screen, tex->buffer, flags );
if (map == NULL)
return NULL;
- if (surface->texture &&
+ if (transfer->texture &&
(flags & PIPE_BUFFER_USAGE_CPU_WRITE))
{
/* Do something to notify contexts of a texture change.
@@ -222,14 +277,16 @@ i915_surface_map( struct pipe_screen *screen,
/* i915_screen(screen)->timestamp++; */
}
- return map + surface->offset;
+ return map + i915_transfer(transfer)->offset +
+ transfer->y / transfer->block.height * transfer->stride +
+ transfer->x / transfer->block.width * transfer->block.size;
}
static void
-i915_surface_unmap(struct pipe_screen *screen,
- struct pipe_surface *surface)
+i915_transfer_unmap(struct pipe_screen *screen,
+ struct pipe_transfer *transfer)
{
- struct i915_texture *tex = (struct i915_texture *)surface->texture;
+ struct i915_texture *tex = (struct i915_texture *)transfer->texture;
pipe_buffer_unmap( screen, tex->buffer );
}
@@ -278,8 +335,10 @@ i915_create_screen(struct pipe_winsys *winsys, uint pci_id)
i915screen->screen.get_param = i915_get_param;
i915screen->screen.get_paramf = i915_get_paramf;
i915screen->screen.is_format_supported = i915_is_format_supported;
- i915screen->screen.surface_map = i915_surface_map;
- i915screen->screen.surface_unmap = i915_surface_unmap;
+ i915screen->screen.get_tex_transfer = i915_get_tex_transfer;
+ i915screen->screen.tex_transfer_destroy = i915_tex_transfer_destroy;
+ i915screen->screen.transfer_map = i915_transfer_map;
+ i915screen->screen.transfer_unmap = i915_transfer_unmap;
i915_init_screen_texture_functions(&i915screen->screen);
u_simple_screen_init(&i915screen->screen);