From 4a666488c4e3067eed984e272149411cc2198c77 Mon Sep 17 00:00:00 2001 From: Daniel Vetter Date: Sun, 21 Nov 2010 20:34:44 +0100 Subject: i915g: add winsys function to create tiled buffers Different kernels have different restrictions for tiled buffers. Hence use the libdrm abstraction to calculate the necessary stride and height alignment requirements. Not yet used. v2: Incorporate review comments from Jakob Bornecrantz Signed-off-by: Daniel Vetter Reviewed-by: Jakob Bornecrantz Signed-off-by: Jakob Bornecrantz --- src/gallium/winsys/i915/sw/i915_sw_buffer.c | 31 ++++++++++++++++++++++++++++- src/gallium/winsys/i915/sw/i915_sw_winsys.h | 3 ++- 2 files changed, 32 insertions(+), 2 deletions(-) (limited to 'src/gallium/winsys/i915/sw') diff --git a/src/gallium/winsys/i915/sw/i915_sw_buffer.c b/src/gallium/winsys/i915/sw/i915_sw_buffer.c index 321ef90d265..44466d1c661 100644 --- a/src/gallium/winsys/i915/sw/i915_sw_buffer.c +++ b/src/gallium/winsys/i915/sw/i915_sw_buffer.c @@ -27,6 +27,34 @@ err: return NULL; } +static struct i915_winsys_buffer * +i915_sw_buffer_create_tiled(struct i915_winsys *iws, + unsigned *stride, unsigned height, + enum i915_winsys_buffer_tile *tiling, + enum i915_winsys_buffer_type type) +{ + struct i915_sw_buffer *buf = CALLOC_STRUCT(i915_sw_buffer); + + if (!buf) + return NULL; + + buf->magic = 0xDEAD1337; + buf->type = type; + buf->ptr = CALLOC(*stride * height, 1); + buf->tiling = *tiling; + buf->stride = *stride; + + if (!buf->ptr) + goto err; + + return (struct i915_winsys_buffer *)buf; + +err: + assert(0); + FREE(buf); + return NULL; +} + static int i915_sw_buffer_set_fence_reg(struct i915_winsys *iws, struct i915_winsys_buffer *buffer, @@ -39,7 +67,7 @@ i915_sw_buffer_set_fence_reg(struct i915_winsys *iws, assert(buf->map_count == 0); } - buf->tile = tile; + buf->tiling = tile; return 0; } @@ -95,6 +123,7 @@ void i915_sw_winsys_init_buffer_functions(struct i915_sw_winsys *isws) { isws->base.buffer_create = i915_sw_buffer_create; + isws->base.buffer_create_tiled = i915_sw_buffer_create_tiled; isws->base.buffer_set_fence_reg = i915_sw_buffer_set_fence_reg; isws->base.buffer_map = i915_sw_buffer_map; isws->base.buffer_unmap = i915_sw_buffer_unmap; diff --git a/src/gallium/winsys/i915/sw/i915_sw_winsys.h b/src/gallium/winsys/i915/sw/i915_sw_winsys.h index cd2eebd1799..3af2548419e 100644 --- a/src/gallium/winsys/i915/sw/i915_sw_winsys.h +++ b/src/gallium/winsys/i915/sw/i915_sw_winsys.h @@ -43,7 +43,8 @@ struct i915_sw_buffer { void *ptr; unsigned map_count; enum i915_winsys_buffer_type type; - enum i915_winsys_buffer_tile tile; + enum i915_winsys_buffer_tile tiling; + unsigned stride; }; static INLINE struct i915_sw_buffer * -- cgit v1.2.3