summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Whitwell <keithw@vmware.com>2010-04-10 12:48:43 +0100
committerKeith Whitwell <keithw@vmware.com>2010-04-10 12:49:29 +0100
commit0189cb2fde9f5d7326fd4bfbc2e52db4cce73b3e (patch)
treea3c1d20522d0ba4a259a5c83e2126affd7aba83c
parent65bc6f88fd9ce8ff90175b250e580bef2739ea35 (diff)
gallium: don't use generic get_transfer func for texturesgallium-resources
It doesn't know and can't fill in the stride value.
-rw-r--r--src/gallium/auxiliary/util/u_transfer.c4
-rw-r--r--src/gallium/drivers/i915/i915_resource_texture.c22
-rw-r--r--src/gallium/drivers/i965/brw_resource_texture.c25
3 files changed, 49 insertions, 2 deletions
diff --git a/src/gallium/auxiliary/util/u_transfer.c b/src/gallium/auxiliary/util/u_transfer.c
index 02e714f51b..bedace3b1d 100644
--- a/src/gallium/auxiliary/util/u_transfer.c
+++ b/src/gallium/auxiliary/util/u_transfer.c
@@ -90,6 +90,10 @@ struct pipe_transfer * u_default_get_transfer(struct pipe_context *context,
transfer->sr = sr;
transfer->usage = usage;
transfer->box = *box;
+
+ /* Note strides are zero, this is ok for buffers, but not for
+ * textures 2d & higher at least.
+ */
return transfer;
}
diff --git a/src/gallium/drivers/i915/i915_resource_texture.c b/src/gallium/drivers/i915/i915_resource_texture.c
index 82c8fe2e40..b259968835 100644
--- a/src/gallium/drivers/i915/i915_resource_texture.c
+++ b/src/gallium/drivers/i915/i915_resource_texture.c
@@ -653,6 +653,26 @@ i915_texture_destroy(struct pipe_screen *screen,
FREE(tex);
}
+static struct pipe_transfer *
+i915_texture_get_transfer(struct pipe_context *context,
+ struct pipe_resource *resource,
+ struct pipe_subresource sr,
+ unsigned usage,
+ const struct pipe_box *box)
+{
+ struct i915_texture *tex = i915_texture(resource);
+ struct pipe_transfer *transfer = CALLOC_STRUCT(pipe_transfer);
+ if (transfer == NULL)
+ return NULL;
+
+ transfer->resource = resource;
+ transfer->sr = sr;
+ transfer->usage = usage;
+ transfer->box = *box;
+ transfer->stride = tex->stride;
+
+ return transfer;
+}
static void *
@@ -707,7 +727,7 @@ struct u_resource_vtbl i915_texture_vtbl =
i915_texture_get_handle, /* get_handle */
i915_texture_destroy, /* resource_destroy */
NULL, /* is_resource_referenced */
- u_default_get_transfer, /* get_transfer */
+ i915_texture_get_transfer, /* get_transfer */
u_default_transfer_destroy, /* transfer_destroy */
i915_texture_transfer_map, /* transfer_map */
u_default_transfer_flush_region, /* transfer_flush_region */
diff --git a/src/gallium/drivers/i965/brw_resource_texture.c b/src/gallium/drivers/i965/brw_resource_texture.c
index b42aae4304..a6f27b8a41 100644
--- a/src/gallium/drivers/i965/brw_resource_texture.c
+++ b/src/gallium/drivers/i965/brw_resource_texture.c
@@ -270,6 +270,29 @@ static unsigned brw_texture_is_referenced( struct pipe_context *pipe,
* Transfer functions
*/
+
+static struct pipe_transfer *
+brw_texture_get_transfer(struct pipe_context *context,
+ struct pipe_resource *resource,
+ struct pipe_subresource sr,
+ unsigned usage,
+ const struct pipe_box *box)
+{
+ struct brw_texture *tex = brw_texture(resource);
+ struct pipe_transfer *transfer = CALLOC_STRUCT(pipe_transfer);
+ if (transfer == NULL)
+ return NULL;
+
+ transfer->resource = resource;
+ transfer->sr = sr;
+ transfer->usage = usage;
+ transfer->box = *box;
+ transfer->stride = tex->pitch * tex->cpp;
+
+ return transfer;
+}
+
+
static void *
brw_texture_transfer_map(struct pipe_context *pipe,
struct pipe_transfer *transfer)
@@ -331,7 +354,7 @@ struct u_resource_vtbl brw_texture_vtbl =
brw_texture_get_handle, /* get_handle */
brw_texture_destroy, /* resource_destroy */
brw_texture_is_referenced, /* is_resource_referenced */
- u_default_get_transfer, /* get_transfer */
+ brw_texture_get_transfer, /* get_transfer */
u_default_transfer_destroy, /* transfer_destroy */
brw_texture_transfer_map, /* transfer_map */
u_default_transfer_flush_region, /* transfer_flush_region */